summaryrefslogtreecommitdiffstats
path: root/Lib/bz2.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-01-17 23:57:14 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-01-17 23:57:14 (GMT)
commit72750a85f970dc7d79c44c63fd02157634984762 (patch)
tree2ab726420e409a5cf764d96f1f1a6efb688ba4a5 /Lib/bz2.py
parent7422b22e5e2b5462908b4f5f45574ef2de7961c6 (diff)
downloadcpython-72750a85f970dc7d79c44c63fd02157634984762.zip
cpython-72750a85f970dc7d79c44c63fd02157634984762.tar.gz
cpython-72750a85f970dc7d79c44c63fd02157634984762.tar.bz2
Issue #13809: Make bz2 module work with threads disabled.
Original patch by Amaury Forgeot d'Arc.
Diffstat (limited to 'Lib/bz2.py')
-rw-r--r--Lib/bz2.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/bz2.py b/Lib/bz2.py
index 5c59a9e..36e5558 100644
--- a/Lib/bz2.py
+++ b/Lib/bz2.py
@@ -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