[issue6504] infinite recursion from calling builtins.open()

kai zhu report at bugs.python.org
Fri Jul 17 17:36:09 CEST 2009


New submission from kai zhu <kaizhu256 at gmail.com>:

# copy this to test.py
# > touch foo.txt
# > python3.1 -c "import test; import collections"
# > ...
# >   File "test.py", line 5, in find_module
# >     def find_module(self, mname, path = None): open("foo.txt")
# >   File "test.py", line 5, in find_module
# >     def find_module(self, mname, path = None): open("foo.txt")
# >   File "test.py", line 5, in find_module
# >     def find_module(self, mname, path = None): open("foo.txt")
# >   File "test.py", line 5, in find_module
# >     def find_module(self, mname, path = None): open("foo.txt")
# > RuntimeError: maximum recursion depth exceeded while calling a
# > Python object
class importer(object):
  def find_module(self, mname, path = None): open("foo.txt")
import sys; sys.meta_path.append(importer)

***

# note recursion behavior stops if we don't call open()
class importer(object):
  def find_module(self, mname, path = None): pass
import sys; sys.meta_path.append(importer)

----------
components: IO, Interpreter Core
messages: 90627
nosy: kaizhu
severity: normal
status: open
title: infinite recursion from calling builtins.open()
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6504>
_______________________________________


More information about the Python-bugs-list mailing list