[issue5328] Crash when doing some list iteration

2009-02-20 Thread qwjqwj

New submission from qwjqwj :

I am using the python 2.5.4 in redhat enterprise. 

My project is a big one with turbogears and sqlobject. The python core
dumped sometime when iterating list. It occurs randomly and cannot be
reproduced.

After using gdb, I found python core dumped at this line in the lambda
unnamed function:
newsfeeds = filter(lambda x: not(x.activity==0 and
x.value.get('uid')==sess.user.id),n)[:5]

The core dump info is as followed:


#0  listiter_next (it=0xa2988ecc) at Objects/listobject.c:2819
#1  0x08079e56 in listextend (self=0xa91f90c, b=)
at Objects/listobject.c:823
#2  0x0807a370 in list_init (self=0xa91f90c, args=0xb64c6ec, kw=0x0) at
Objects/listobject.c:2391
#3  0x0809bfe3 in type_call (type=0x8140220, args=0xb64c6ec, kwds=0x0)
at Objects/typeobject.c:436
#4  0x0805a5f7 in PyObject_Call (func=0xb47cc6c, arg=0xb64c6ec, kw=0x0)
at Objects/abstract.c:1861
#5  0x080c16a2 in PyEval_EvalFrameEx (f=0xa2649aec, throwflag=0) at
Python/ceval.c:3823
#6  0x080c7765 in PyEval_EvalCodeEx (co=0x9929a88, globals=0x9907b54,
locals=0x0, args=0xb52fe58, 
argcount=1, kws=0x9f98ae0, kwcount=2, defs=0x991ed38, defcount=2,
closure=0x0) at Python/ceval.c:2875
#7  0x0810f0ba in function_call (func=0x9f32b54, arg=0xb52fe4c,
kw=0xa27b679c)
at Objects/funcobject.c:517
#8  0x0805a5f7 in PyObject_Call (func=0xb47cc6c, arg=0xb52fe4c,
kw=0xa27b679c) at Objects/abstract.c:1861
#9  0x080c46dd in PyEval_EvalFrameEx (f=0xac6737c, throwflag=0) at
Python/ceval.c:3892
#10 0x080c7765 in PyEval_EvalCodeEx (co=0x89bce30, globals=0x8ac702c,
locals=0x0, args=0xa14d6418, 
argcount=2, kws=0xa3c2ba0, kwcount=2, defs=0x0, defcount=0,
closure=0x0) at Python/ceval.c:2875
#11 0x0810f0ba in function_call (func=0x8acf144, arg=0xa14d640c,
kw=0xa27b69bc)
at Objects/funcobject.c:517
#12 0x0805a5f7 in PyObject_Call (func=0xb47cc6c, arg=0xa14d640c,
kw=0xa27b69bc)
at Objects/abstract.c:1861
#13 0x080c46dd in PyEval_EvalFrameEx (f=0xac671ec, throwflag=0) at
Python/ceval.c:3892
#14 0x080c6410 in PyEval_EvalFrameEx (f=0xacf7c1c, throwflag=0) at
Python/ceval.c:3698
#15 0x080c7765 in PyEval_EvalCodeEx (co=0x84e1da0, globals=0x84d8acc,
locals=0x0, args=0xa0d144e8, 
argcount=4, kws=0x9d850e8, kwcount=2, defs=0x0, defcount=0,
closure=0x9f3944c) at Python/ceval.c:2875
#16 0x0810f0ba in function_call (func=0x9f32cdc, arg=0xa0d144dc,
kw=0x9a22824)
at Objects/funcobject.c:517
#17 0x0805a5f7 in PyObject_Call (func=0xb47cc6c, arg=0xa0d144dc,
kw=0x9a22824) at Objects/abstract.c:1861
#18 0x080c46dd in PyEval_EvalFrameEx (f=0xa2304ba4, throwflag=0) at
Python/ceval.c:3892
#19 0x080c7765 in PyEval_EvalCodeEx (co=0x9dcf890, globals=0x857ebdc,
locals=0x0, args=0xbb7b5b0, 
argcount=4, kws=0x9b82858, kwcount=2, defs=0x0, defcount=0,
closure=0x9ebf10c) at Python/ceval.c:2875
#20 0x0810f0ba in function_call (func=0xa40de64, arg=0xbb7b5a4,
kw=0xa27b6604)
at Objects/funcobject.c:517
#21 0x0805a5f7 in PyObject_Call (func=0xb47cc6c, arg=0xbb7b5a4,
kw=0xa27b6604) at Objects/abstract.c:1861
#22 0x080c46dd in PyEval_EvalFrameEx (f=0x9c7b0d4, throwflag=0) at
Python/ceval.c:3892
#23 0x080c7765 in PyEval_EvalCodeEx (co=0x89ade30, globals=0x89b7acc,
locals=0x0, args=0xa275a248, 
argcount=5, kws=0x9c8e838, kwcount=2, defs=0x0, defcount=0,
closure=0x0) at Python/ceval.c:2875

--
components: None
messages: 82522
nosy: qwjqwj
severity: normal
status: open
title: Crash when doing some list iteration
type: crash
versions: Python 2.5

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



[issue5328] Crash when doing some list iteration

2009-02-21 Thread qwjqwj

qwjqwj  added the comment:

I used the script from issue 4732 and can reproduce segfault on my RHEL
5. After that I updated the system with "yum update" and get a new
version of libc. Currently the script cannot cause segfault after
updating. Thank you for your help.

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



[issue5345] cStringIO class name typo

2009-02-21 Thread qwjqwj

New submission from qwjqwj :

It has a typo error in cStringIO.StringIO's class name "StringO":

>>> import cStringIO
>>> a=cStringIO.StringIO()
>>> a

>>> a.__class__.__name__
'StringO'

So we can't unpickle the object correctly with Python 2.5.4:

>>> import pickle
>>> pickle.loads(pickle.dumps(a))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.5/pickle.py", line 1366, in dumps
Pickler(file, protocol).dump(obj)
  File "/usr/local/lib/python2.5/pickle.py", line 224, in dump
self.save(obj)
  File "/usr/local/lib/python2.5/pickle.py", line 306, in save
rv = reduce(self.proto)
  File "/usr/local/lib/python2.5/copy_reg.py", line 69, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle StringO objects


When using multiprocess library, it also use the pickling and unpickling
of cStringIO.StringIO object

--
components: Library (Lib)
messages: 82595
nosy: qwjqwj
severity: normal
status: open
title: cStringIO class name typo
versions: Python 2.5

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



[issue5345] cStringIO class name typo

2009-02-21 Thread qwjqwj

qwjqwj  added the comment:

This bug also exists in Python 2.6.1

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

New submission from qwjqwj :

In Python 3.0,3.1a1:

>>> def f():
[(yield i) for i in range(10)]
>>> f()
>>> f() is None
True

>>> def f():
((yield i) for i in range(10))
>>> f()
>>> f() is None
True

However it is correct in Python 2.5,2.6

>>> def f():
... [(yield i) for i in range(10)]
... 
>>> f()


--
components: Interpreter Core
messages: 84257
nosy: qwjqwj
severity: normal
status: open
title: yield in iterators
type: behavior
versions: Python 3.0, Python 3.1

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

qwjqwj  added the comment:

Why should yield can be put inside the iterator? The behavior here is
very weired.

>>> x = [(yield i) for i in range(10)]
>>> print(list(x))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, [None, None, None, None, None, None,
None, None, None, None]]

--

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

qwjqwj  added the comment:

>>> x = ((yield i) for i in range(10))
>>> list(x)
[0, None, 1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None,
8, None, 9, None]

--

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

qwjqwj  added the comment:

>>> x = {(yield i) for i in range(10)}
>>> x
 at 0x02A453F0>
>>> list(x)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, {None}]

--

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

qwjqwj  added the comment:

More experiments:
The tuple pair (10,20) don't correspond to (i,i*i)
The yield order is distorted

>>> x = (((yield i),(yield i*i)) for i in range(3))
>>> x.__next__()
0
>>> x.send(10)
0
>>> x.send(20)
(10, 20)
>>> x.send(30)
1
>>> x.send(40)
1
>>> x.send(60)
(40, 60)
>>> x.send(70)
2
>>> x.send(80)
4
>>> x.send(90)
(80, 90)
>>> x.send(100)
Traceback (most recent call last):
  File "", line 1, in 
x.send(100)
StopIteration

--

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



[issue5577] yield in iterators

2009-03-27 Thread qwjqwj

qwjqwj  added the comment:

Ok, I see. Thanks.
However, I don't think yield should be consumed at the iterator's level.
It may be more useful for the outside function to consume the yield.

For example, some function want to change some data with another "thread".

def f():
...fetch data...
x = [yield i for i in data]

It should be written as belowed in Python 3.1 now
def f():
x = []
for i in data:
x.append((yield i))

--

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