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

2010-07-29 Thread Georg Brandl
Georg Brandl added the comment: Cannot reproduce with current 3.2 trunk, closing. -- resolution: -> out of date status: open -> closed ___ Python tracker ___ ___

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

2009-07-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yes, we conditionally import the "locale" module in order to guess the encoding when it is not specified by the caller. We can't import it at module initialization time because it would cause bootstrapping issues. The Python equivalent of the logic expressed in

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

2009-07-18 Thread kai zhu
kai zhu added the comment: current hack-around, then is to pre-import locale, which is verified to work: # beg test.py class importer(object): def find_module(self, mname, path = None): open("foo.txt") import sys, locale; sys.meta_path.append(importer) import collections # no recursion # end

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

2009-07-18 Thread Georg Brandl
Georg Brandl added the comment: First, the second bug isn't a bug since that restriction has been lifted in Python 3. The original issue occurs because open() for text modes imports the "locale" module. This is kind of nasty, because calling open() is well within what a find_module() implementa

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

2009-07-17 Thread kai zhu
kai zhu added the comment: recursion also goes away if we open as raw bytes: open("foo.txt", "rb"). modes "r+" & "w" also give infinite recursion, while "rb+" & "wb" do not. note found another bug: instance method find_module should raise exception anyway, since its class was uninstantiated i

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

2009-07-17 Thread kai zhu
New submission from kai zhu : # 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 # > de