You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2016-09-13.00:12:44.319>created_at=<Date2016-09-08.17:30:58.793>labels= ['3.7', 'library']
title='fileinput causes RecursionErrors when dealing with large numbers of empty files'updated_at=<Date2016-09-13.00:12:44.319>user='https://github.com/MojoVampire'
Accidentally discovered this while running code that processes a whole bunch of files, when it turned out the files were empty. The readline method of fileinput.input will make a recursive call to continue processing when it reaches the end of a file. This is fine when files aren't empty, but if you have sufficient (~1000) empty files being processed, this causes recursion errors.
Simple example:
>>> for i inrange(10000):
... withopen('test{}'.format(i), 'wb'):
... pass
...
>>> import fileinput, glob
>>> ''.join(fileinput.input(glob.glob('./test*')))
Traceback ...
... (almost all the levels are showing the self.readline() call at the end of readline) ...
RecursionError: maximum recursion depth exceeded
Admittedly a niche case, but a relatively simple switch from recursion to iteration would solve it. Same problem appears in all versions of Python.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: