Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
72750a85
Commit
72750a85
authored
Jan 18, 2012
by
Nadeem Vawda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13809: Make bz2 module work with threads disabled.
Original patch by Amaury Forgeot d'Arc.
parent
7422b22e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
Lib/bz2.py
Lib/bz2.py
+6
-2
Lib/test/test_bz2.py
Lib/test/test_bz2.py
+7
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/bz2.py
View file @
72750a85
...
...
@@ -10,9 +10,13 @@ __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "compress",
__author__
=
"Nadeem Vawda <nadeem.vawda@gmail.com>"
import
io
import
threading
import
warnings
try
:
from
threading
import
RLock
except
ImportError
:
from
dummy_threading
import
RLock
from
_bz2
import
BZ2Compressor
,
BZ2Decompressor
...
...
@@ -53,7 +57,7 @@ class BZ2File(io.BufferedIOBase):
"""
# This lock must be recursive, so that BufferedIOBase's
# readline(), readlines() and writelines() don't deadlock.
self
.
_lock
=
threading
.
RLock
()
self
.
_lock
=
RLock
()
self
.
_fp
=
None
self
.
_closefp
=
False
self
.
_mode
=
_MODE_CLOSED
...
...
Lib/test/test_bz2.py
View file @
72750a85
...
...
@@ -463,6 +463,13 @@ class BZ2FileTest(BaseTest):
for
t
in
threads
:
t
.
join
()
def
testWithoutThreading
(
self
):
bz2
=
support
.
import_fresh_module
(
"bz2"
,
blocked
=
(
"threading"
,))
with
bz2
.
BZ2File
(
self
.
filename
,
"wb"
)
as
f
:
f
.
write
(
b"abc"
)
with
bz2
.
BZ2File
(
self
.
filename
,
"rb"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
b"abc"
)
def
testMixedIterationAndReads
(
self
):
self
.
createTempFile
()
linelen
=
len
(
self
.
TEXT_LINES
[
0
])
...
...
Misc/NEWS
View file @
72750a85
...
...
@@ -447,6 +447,9 @@ Core and Builtins
Library
-------
-
Issue
#
13809
:
Fix
regression
where
bz2
module
wouldn
't work when threads are
disabled. Original patch by Amaury Forgeot d'
Arc
.
-
Issue
#
13589
:
Fix
some
serialization
primitives
in
the
aifc
module
.
Patch
by
Oleg
Plakhotnyuk
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment