Raymond Hettinger <[email protected]> added the comment:
[Kristján]
> a = map(add, a, b) also crashes this.
> ... What's happening here is just simple c recursion
> trough function pointers, ending in stack overflow, ...
Thanks for the analysis. ISTM, this bug report is getting less and less
interesting (or at least, less actionable without heavy-handed interventions in
multiple tools).
One other thought, the OPs isn't really recursive in the sense of a function
calling itself repeatedly. Instead, the OPs explicitly creates a heavily
nested pile of distinct iterator objects and then runs the entire chain. This
isn't much different from someone writing: os.system('cat somefile | ' + ' |
'.join(['sort']*100000)).
The existing sys.max_recursion_depth was put in as a defense against the
relatively common mistake of users writing a recursive function and getting the
termination code wrong. I don't think that logic would apply to intentionally
deeply nested data structures or iterators.
Stackoverflows in C are hard to protect against. We could take every iterator
and set some limits on it, but that would be heavy handed and likely do more
harm than good (C iterators have been around almost a decade and haven't done
fine in the wild. The itertools in particular were designed to gain speed
through by-passing the eval-loop. Slowing them down would be counter to their
primary use case.)
----------
resolution: -> later
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14507>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com