mirror of
https://github.com/python/cpython
synced 2024-09-16 00:17:02 +00:00
Merged revisions 88498 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88498 | brett.cannon | 2011-02-21 19:25:12 -0800 (Mon, 21 Feb 2011) | 8 lines Issue #11074: Make 'tokenize' so it can be reloaded. The module stored away the 'open' object as found in the global namespace (which fell through to the built-in namespace) since it defined its own 'open'. Problem is that if you reloaded the module it then grabbed the 'open' defined in the previous load, leading to code that infinite recursed. Switched to simply call builtins.open directly. ........
This commit is contained in:
parent
64c9af1508
commit
45b96d373e
|
@ -24,6 +24,7 @@
|
|||
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
|
||||
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
|
||||
'Michael Foord')
|
||||
import builtins
|
||||
import re
|
||||
import sys
|
||||
from token import *
|
||||
|
@ -335,13 +336,11 @@ def find_cookie(line):
|
|||
return default, [first, second]
|
||||
|
||||
|
||||
_builtin_open = open
|
||||
|
||||
def open(filename):
|
||||
"""Open a file in read only mode using the encoding detected by
|
||||
detect_encoding().
|
||||
"""
|
||||
buffer = _builtin_open(filename, 'rb')
|
||||
buffer = builtins.open(filename, 'rb')
|
||||
encoding, lines = detect_encoding(buffer.readline)
|
||||
buffer.seek(0)
|
||||
text = TextIOWrapper(buffer, encoding, line_buffering=True)
|
||||
|
|
Loading…
Reference in a new issue