Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

The "RuntimeError: maximum recursion depth exceeded" message is normally only 
triggered by pure Python recursion, so I would not have expected it here, but 
there should be some sort of graceful MemoryError or somesuch rather than a 
segfault.

The following code narrows it down to some issue in starmap():

    def gstarmap(func, iterable):
        for tup in iterable:
            yield func(*tup)

    def mylist(iterable):
        return [x for x in iterable]

    a = b = [1]
    for i in xrange(100000):

        # Things that trigger a segfault:                                       
       
        #a = starmap(add, izip(a, b))                                           
     
        #a = starmap(add, iter( (a, b)  ))                                      
     
        a = starmap(add, (a, b)  )

        # Things that exit cleanly with a RuntimeError                          
     
        #a = gstarmap(add, iter( (a, b)  ))                                     
     
        #a = (x+y   for x, y in iter( (a, b)  ))     

    mylist(a)

One possibility may be that starmap.next needs to clear StopIteration 
exceptions in the same way as PyIter_Next():

    if (result == NULL &&
        PyErr_Occurred() &&
        PyErr_ExceptionMatches(PyExc_StopIteration))
        PyErr_Clear();

----------
priority: normal -> low
title: Segfault with starmap and izip combo -> Segfault with deeply nested 
starmap calls

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14507>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to