Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with

imp.reload().  Patch by Thomas Kluyver.
This commit is contained in:
Serhiy Storchaka 2015-03-11 17:18:03 +02:00
parent 13be8c2691
commit cf4a2f29ad
5 changed files with 7 additions and 6 deletions

View File

@ -9,6 +9,7 @@ __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor",
__author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>"
from builtins import open as _builtin_open
import io
import warnings
@ -27,8 +28,6 @@ _MODE_WRITE = 3
_BUFFER_SIZE = 8192
_builtin_open = open
class BZ2File(io.BufferedIOBase):

View File

@ -38,6 +38,7 @@ __credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend."
#---------
# Imports
#---------
from builtins import open as bltn_open
import sys
import os
import io
@ -2421,7 +2422,6 @@ def is_tarfile(name):
except TarError:
return False
bltn_open = open
open = TarFile.open

View File

@ -24,6 +24,7 @@ __author__ = 'Ka-Ping Yee <ping@lfw.org>'
__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 @@ def detect_encoding(readline):
return default, [first, second]
_builtin_open = open
def open(filename):
"""Open a file in read only mode using the encoding detected by
detect_encoding().

View File

@ -16,6 +16,9 @@ Core and Builtins
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.

View File

@ -1,4 +1,4 @@
_orig_open = open
from builtins import open as _orig_open
class _BkFile:
def __init__(self, file, mode, bufsize):