[Python-checkins] cpython (3.4): Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with

serhiy.storchaka python-checkins at python.org
Wed Mar 11 16:32:53 CET 2015


https://hg.python.org/cpython/rev/383ba3699084
changeset:   94944:383ba3699084
branch:      3.4
parent:      94941:e1ec248d585f
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Wed Mar 11 17:18:03 2015 +0200
summary:
  Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with
imp.reload().  Patch by Thomas Kluyver.

files:
  Lib/bz2.py             |  3 +--
  Lib/tarfile.py         |  2 +-
  Lib/tokenize.py        |  3 +--
  Misc/NEWS              |  3 +++
  Tools/freeze/bkfile.py |  2 +-
  5 files changed, 7 insertions(+), 6 deletions(-)


diff --git a/Lib/bz2.py b/Lib/bz2.py
--- a/Lib/bz2.py
+++ b/Lib/bz2.py
@@ -9,6 +9,7 @@
 
 __author__ = "Nadeem Vawda <nadeem.vawda at gmail.com>"
 
+from builtins import open as _builtin_open
 import io
 import warnings
 
@@ -27,8 +28,6 @@
 
 _BUFFER_SIZE = 8192
 
-_builtin_open = open
-
 
 class BZ2File(io.BufferedIOBase):
 
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -38,6 +38,7 @@
 #---------
 # Imports
 #---------
+from builtins import open as bltn_open
 import sys
 import os
 import io
@@ -2421,7 +2422,6 @@
     except TarError:
         return False
 
-bltn_open = open
 open = TarFile.open
 
 
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -24,6 +24,7 @@
 __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
                'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
                'Michael Foord')
+from builtins import open as _builtin_open
 from codecs import lookup, BOM_UTF8
 import collections
 from io import TextIOWrapper
@@ -429,8 +430,6 @@
     return default, [first, second]
 
 
-_builtin_open = open
-
 def open(filename):
     """Open a file in read only mode using the encoding detected by
     detect_encoding().
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@
 Library
 -------
 
+- Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with
+  imp.reload().  Patch by Thomas Kluyver.
+
 - Issue #23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST
   flag on certificate stores when it is available.
 
diff --git a/Tools/freeze/bkfile.py b/Tools/freeze/bkfile.py
--- a/Tools/freeze/bkfile.py
+++ b/Tools/freeze/bkfile.py
@@ -1,4 +1,4 @@
-_orig_open = open
+from builtins import open as _orig_open
 
 class _BkFile:
     def __init__(self, file, mode, bufsize):

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list