Skip to content

Commit cf4a2f2

Browse files
Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with
imp.reload(). Patch by Thomas Kluyver.
1 parent 13be8c2 commit cf4a2f2

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

Lib/bz2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
__author__ = "Nadeem Vawda <[email protected]>"
1111

12+
from builtins import open as _builtin_open
1213
import io
1314
import warnings
1415

@@ -27,8 +28,6 @@
2728

2829
_BUFFER_SIZE = 8192
2930

30-
_builtin_open = open
31-
3231

3332
class BZ2File(io.BufferedIOBase):
3433

Lib/tarfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#---------
3939
# Imports
4040
#---------
41+
from builtins import open as bltn_open
4142
import sys
4243
import os
4344
import io
@@ -2421,7 +2422,6 @@ def is_tarfile(name):
24212422
except TarError:
24222423
return False
24232424

2424-
bltn_open = open
24252425
open = TarFile.open
24262426

24272427

Lib/tokenize.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
2525
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
2626
'Michael Foord')
27+
from builtins import open as _builtin_open
2728
from codecs import lookup, BOM_UTF8
2829
import collections
2930
from io import TextIOWrapper
@@ -429,8 +430,6 @@ def find_cookie(line):
429430
return default, [first, second]
430431

431432

432-
_builtin_open = open
433-
434433
def open(filename):
435434
"""Open a file in read only mode using the encoding detected by
436435
detect_encoding().

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Core and Builtins
1616
Library
1717
-------
1818

19+
- Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with
20+
imp.reload(). Patch by Thomas Kluyver.
21+
1922
- Issue #23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST
2023
flag on certificate stores when it is available.
2124

Tools/freeze/bkfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_orig_open = open
1+
from builtins import open as _orig_open
22

33
class _BkFile:
44
def __init__(self, file, mode, bufsize):

0 commit comments

Comments
 (0)