[issue15251] new.code and new.function crashes Python iterpretter

2012-07-04 Thread Jeffrey Harper

New submission from Jeffrey Harper jeff1.61...@gmail.com:

I've attached a script that crashes the Python interpreter.  

I can get the crash to occur under Windows Vista with this version of Python:

C:\tmp\remotec:\Python27\python.exe
Python 2.7.1 Stackless 3.1b3 060516 (release27-maint, Jan  1 2011, 13:04:37) 
[MSC v.1500 32 bit (Intel)] on win32

Also, I got it to segfault under Ubuntu Linux:

jharper@ubuntu:~$ uname -a
Linux ubuntu 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011 i686 
GNU/Linux
jharper@ubuntu:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2

Note, when I commented out the line, pprint(code_args), the script generated 
a SystemError exception instead of crashing.

--
components: Library (Lib)
files: bug3.py
messages: 164652
nosy: jeffdharper
priority: normal
severity: normal
status: open
title: new.code and new.function crashes Python iterpretter
type: crash
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file26257/bug3.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15251
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15251] new.code and new.function crashes Python iterpretter

2012-07-04 Thread Jeffrey Harper

Jeffrey Harper jeff1.61...@gmail.com added the comment:

The marshal loads and dumps don't seem to be necessary to reproduce the crash.  
On both the Windows Vista and Ubuntu Linux systems, the crash still occurred 
when I replaced:

mcopy_code = loads(dumps(code))

with:

mcopy_code = code #loads(dumps(code))

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15251
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15251] new.code and new.function crashes Python iterpretter

2012-07-04 Thread Jeffrey Harper

Jeffrey Harper jeff1.61...@gmail.com added the comment:

Martin,

Thanks for your response.  I didn't know it was possible to pass freevars and 
cellvars to new.code.  I think the documentation needs to be updated.  The 
documentation for 2.7.3 located at 
http://docs.python.org/library/new.html?highlight=new#new.code is as follows:

new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, 
varnames, filename, name, firstlineno, lnotab)

After I got your reply to this bug report I did help(new.code) and I see that 
it includes freevars and cellvars as optional arguments.

--
assignee:  - docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15251
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper

New submission from Jeffrey Harper jhar...@yapdc.com:

In Python 3.2, a tuple like (1,-2,3) will not be optimized into a constants at 
compile time.  The tuple is built at run-time.  Earlier versions of Python 
optimized these tuples at compile time.

Here's an example program.

# test.py
from dis import dis

def x(): return (1,2,3)
def y(): return (1,-2,3)

print (dis x:)
dis(x)
print()

print(dis y:)
dis(y)

The compiler in 3.2rc3 produces code for function y() that builds the tuple at 
run-time while the tuple in x() is optimized at compile time.

C:\tmpc:\python32\python --version
Python 3.2rc3

C:\tmpc:\python32\python test.py
dis x:
  3   0 LOAD_CONST   4 ((1, 2, 3))
  3 RETURN_VALUE

dis y:
  4   0 LOAD_CONST   1 (1)
  3 LOAD_CONST   4 (-2)
  6 LOAD_CONST   3 (3)
  9 BUILD_TUPLE  3
 12 RETURN_VALUE

However, under 3.1.3, the tuples in both functions are optimized at compile 
time.

C:\tmpc:\python31\python test.py
dis x:
  3   0 LOAD_CONST   4 ((1, 2, 3))
  3 RETURN_VALUE

dis y:
  4   0 LOAD_CONST   4 ((1, -2, 3))
  3 RETURN_VALUE

Although the compiled code produced 3.2rc3 is correct, it is much slower than 
the code generated by 3.1.3.

--
messages: 128795
nosy: jdharper
priority: normal
severity: normal
status: open
title: Negative tuple elements produce inefficient code.
type: performance
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper

Jeffrey Harper jhar...@yapdc.com added the comment:

I have also determined that negative elements interfere with the frozenset 
optimization described in issue6690.  http://bugs.python.org/issue6690.

Here's an example program:

# test.py
from dis import dis

def x(var): return var in {1,2,3} # Note curly braces.  These are sets.
def y(var): return var in {1,-2,3}

print (dis x:)
dis(x)
print()

print(dis y:)
dis(y)

Running this produces:

C:\tmpc:\Python32\python.exe test.py
dis x:
  3   0 LOAD_FAST0 (var)
  3 LOAD_CONST   4 (frozenset({1, 2, 3}))
  6 COMPARE_OP   6 (in)
  9 RETURN_VALUE

dis y:
  4   0 LOAD_FAST0 (var)
  3 LOAD_CONST   1 (1)
  6 LOAD_CONST   4 (-2)
  9 LOAD_CONST   3 (3)
 12 BUILD_SET3
 15 COMPARE_OP   6 (in)
 18 RETURN_VALUE

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper

Jeffrey Harper jhar...@yapdc.com added the comment:

I think r82043 may also explain why 3.1.3 can fold the expression 2 * -3 into 
-6 while 3.2rc3 cannot.

# test.py
from dis import dis

def y(): 2 * -3

print(dis y:)
dis(y)



C:\tmpc:\Python32\python.exe --version
Python 3.2rc3

C:\tmpc:\Python32\python.exe test.py
dis y:
  3   0 LOAD_CONST   1 (2)
  3 LOAD_CONST   3 (-3)
  6 BINARY_MULTIPLY
  7 POP_TOP
  8 LOAD_CONST   0 (None)
 11 RETURN_VALUE

C:\tmpc:\Python31\python.exe --version
Python 3.1.3

C:\tmpc:\Python31\python.exe test.py
dis y:
  3   0 LOAD_CONST   3 (-6)
  3 POP_TOP
  4 LOAD_CONST   0 (None)
  7 RETURN_VALUE

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper

Jeffrey Harper jhar...@yapdc.com added the comment:

Here's a patch against the version of test_peepholer.py in 3.2rc3.  It verifies 
that expressions like the following are optimized:

3*-4
(1,-2,3)
a in {1,-2,3)

--
keywords: +patch
Added file: http://bugs.python.org/file20787/test_peepholer.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11099] Bytes pickled with 3.1 not unpickled with 2.7 correctly

2011-02-02 Thread Jeffrey Harper

New submission from Jeffrey Harper jhar...@yapdc.com:

When a bytes object is pickled with 3.1 and then unpickled with 2.7, the 
results are incorrect.  The example below shows that pickling 
b'abcdefg' in 3.1 and then unpickling in 2.7 produces the string
'[97L, 98L, 99L, 100L, 101L, 102L, 103L]'

The unpickling operation should return 'abcdefg'.

C:\decompyle\jtestc:\Python31\python
Python 3.1.3 (r313:86834, Nov 27 2010, 18:30:53) [MSC v.1500 32 bit (Intel)] on
win32
Type help, copyright, credits or license for more information.
 file = open('test.pkl', 'wb')
 import pickle
 pickle.dump(b'abcdefg', file, 0)
 exit()

C:\decompyle\jtestc:\python27\python
Python 2.7 Stackless 3.1b3 060516 (release27-maint, Jul 22 2010, 18:58:18) [MSC
v.1500 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 file = open('test.pkl', 'rb')
 import pickle
 pickle.load(file)
'[97L, 98L, 99L, 100L, 101L, 102L, 103L]'


--
components: Library (Lib), Unicode
messages: 127735
nosy: jdharper
priority: normal
severity: normal
status: open
title: Bytes pickled with 3.1 not unpickled with 2.7 correctly
versions: Python 2.7, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11099
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com