[issue17718] boolop constant checking for if/while

2013-04-13 Thread Stephen Tu

New submission from Stephen Tu:

Here's a simple patch to optimize away constant boolean 
conjunctions/disjunctions. for example:

def foo():
if 1 and 0:
print("hi")

now disassembles into:
  7   0 LOAD_CONST   0 (None) 
  3 RETURN_VALUE 

while I realize more general techniques for achieving this have been proposed 
(ie http://bugs.python.org/issue1346238), this is a very simple, self-contained 
patch.

--
components: Interpreter Core
files: constcheck.patch
keywords: patch
messages: 186767
nosy: Stephen.Tu
priority: normal
severity: normal
status: open
title: boolop constant checking for if/while
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file29807/constcheck.patch

___
Python tracker 
<http://bugs.python.org/issue17718>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17708] sys.flags.hash_randomization doesn't return correct value

2013-04-13 Thread Stephen Tu

Stephen Tu added the comment:

Py_HashRandomizationFlag was not getting properly set anywhere. This patch 
fixes this. Also a test case

Behavior is now:
$ cat ~/hr.py 
import sys
print(sys.flags.hash_randomization)
$ PYTHONHASHSEED=random ./python.exe ~/hr.py 
1
$ PYTHONHASHSEED=0 ./python.exe ~/hr.py 
0
$ PYTHONHASHSEED=1 ./python.exe ~/hr.py 
0

--
keywords: +patch
nosy: +Stephen.Tu
Added file: http://bugs.python.org/file29811/hashrandomization.patch

___
Python tracker 
<http://bugs.python.org/issue17708>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17671] io.BufferedRWPair can use uninitialized members

2013-04-13 Thread Stephen Tu

Stephen Tu added the comment:

_forward_call() now checks if reader/write is NULL- if so, throws a runtime 
exception

--
keywords: +patch
nosy: +Stephen.Tu
Added file: http://bugs.python.org/file29814/bufferedio.patch

___
Python tracker 
<http://bugs.python.org/issue17671>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17575] HTTPConnection.send

2013-04-13 Thread Stephen Tu

Stephen Tu added the comment:

I don't think this is a bug anymore in the codebase- looking at 
Lib/http/client.py, if hasattr(data, "read") is true, then the branch will 
return unconditionally. 

if hasattr(data, "read") :
if self.debuglevel > 0: 
print("sendIng a read()able")
encode = False
try: 
mode = data.mode
except AttributeError:
# io.BytesIO and other file-like objects don't have a `mode`
# attribute.
pass 
else:
if "b" not in mode:
encode = True 
if self.debuglevel > 0: 
print("encoding file using iso-8859-1")
while 1:
datablock = data.read(blocksize)
if not datablock:
break
if encode:
datablock = datablock.encode("iso-8859-1")
self.sock.sendall(datablock)
return

--
nosy: +Stephen.Tu

___
Python tracker 
<http://bugs.python.org/issue17575>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17671] io.BufferedRWPair can use uninitialized members

2013-04-13 Thread Stephen Tu

Stephen Tu added the comment:

patch with test in test_io

--
Added file: http://bugs.python.org/file29835/bufferedio.withtest.patch

___
Python tracker 
<http://bugs.python.org/issue17671>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17708] sys.flags.hash_randomization doesn't return correct value

2013-04-13 Thread Stephen Tu

Stephen Tu added the comment:

But it would seem that setting PYTHONHASHSEED != "random" does disable hash 
randomization. also, not sure what the semantics of the following is:

$ PYTHONHASHSEED=1 python -R ...

right now, python3 basically ignores -R.

--

___
Python tracker 
<http://bugs.python.org/issue17708>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com