Commit Graph

42 Commits

Author SHA1 Message Date
Inada Naoki 0a4c82ddd3
bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016)
This reverts commit d2a8e69c2c.
2021-10-19 11:51:48 +09:00
Ma Lin bc6c12c72a
bpo-44439: BZ2File.write() / LZMAFile.write() handle buffer protocol correctly (GH-26764)
No longer use len() to get the length of the input data. For some buffer protocol objects,
the length obtained by using len() is wrong.
2021-06-22 10:04:23 +03:00
Inada Naoki d2a8e69c2c
bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353) 2021-04-13 13:51:49 +09:00
Inada Naoki cc2ffcdfd7
bpo-43785: Improve BZ2File performance by removing RLock (GH-25299)
Remove `RLock` from `BZ2File`. It makes `BZ2File` to thread unsafe, but
gzip and lzma don't use it too.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-04-12 14:46:53 +09:00
Inada Naoki 4827483f47
bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)
See [PEP 597](https://www.python.org/dev/peps/pep-0597/).

* Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`.
* Add EncodingWarning
* Add io.text_encoding()
* open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled.
* _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python)
* bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding().
* What's new entry
2021-03-29 12:28:14 +09:00
Victor Stinner 90549676e0
bpo-40443: Remove unused imports in the stdlib (GH-19803) 2020-04-30 11:26:33 +02:00
Victor Stinner 10fd6b2b9f
bpo-39357: Update bz2 docstring: remove buffering (GH-18036)
Thanks Karthikeyan Singaravelan for the report ;-)
2020-01-17 13:50:39 +01:00
Victor Stinner 9baf242fc7
bpo-39357: Remove buffering parameter of bz2.BZ2File (GH-18028)
Remove the buffering parameter of bz2.BZ2File. Since Python 3.0, it
was ignored and using it was emitting a DeprecationWarning. Pass an
open file object to control how the file is opened.

The compresslevel parameter becomes keyword-only.
2020-01-16 15:33:30 +01:00
Pablo Aguiar 4b5e62dbb2 bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268) 2018-11-01 12:33:35 +02:00
Matthias Bussonnier ffa198c642 bpo-33487: improve BZ2File Deprecation and documentation. (GH-6785)
Emit warning when None passed explicitly, list Python version since
deprecation in warning message and docs.
2018-09-10 18:15:56 -07:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Berker Peksag 8bdd4480c4 Issue #28225: bz2 module now supports pathlib
Initial patch by Ethan Furman.
2016-10-02 20:07:06 +03:00
Antoine Pitrou 2dbc6e6bce Issue #23529: Limit the size of decompressed data when reading from
GzipFile, BZ2File or LZMAFile.  This defeats denial of service attacks
using compressed bombs (i.e. compressed payloads which decompress to a huge
size).

Patch by Martin Panter and Nikolaus Rath.
2015-04-11 00:31:01 +02:00
Serhiy Storchaka cf4a2f29ad Issue #23615: Modules bz2, tarfile and tokenize now can be reloaded with
imp.reload().  Patch by Thomas Kluyver.
2015-03-11 17:18:03 +02:00
Nadeem Vawda ae02d07bc2 Closes #19839: Fix regression in bz2 module's handling of non-bzip2 data at EOF.
Also fix an analogous bug (not a regression) in the lzma module.
2013-12-04 23:29:51 +01:00
Nadeem Vawda 1de19ac7da #19839: Fix regression in bz2 module's handling of non-bzip2 data at EOF. 2013-12-04 23:01:15 +01:00
Nadeem Vawda 8a9e99cffc Issue #19223: Add support for the 'x' mode to the bz2 module.
Patch by Tim Heaney and Vajrasky Kok.
2013-10-19 00:11:06 +02:00
Brett Cannon cd171c8e92 Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a) 2013-07-04 17:43:24 -04:00
Brett Cannon 0a140668fa Issue #18200: Update the stdlib (except tests) to use
ModuleNotFoundError.
2013-06-13 20:57:26 -04:00
Nadeem Vawda 4907b0a2e0 bz2 module: Rewrap docstrings at 72 columns, as per PEP 8. 2012-10-08 20:31:34 +02:00
Nadeem Vawda 3b4a4f5199 Stylistic tweaks to the bz2 module to make it easier to transplant changes from
it to http://pypi.python.org/pypi/bz2file.
2012-10-08 19:20:49 +02:00
Nadeem Vawda eb70be2b46 Issue #16304: Further optimize BZ2File.readlines?(). 2012-10-01 23:05:32 +02:00
Nadeem Vawda 138ad5066d Fix error handling in new fast path of BZ2File.readline(). 2012-10-01 23:04:11 +02:00
Nadeem Vawda 452add08a1 Issue #16304: Another performance optimization for BZ2File.
Patch by Serhiy Storchaka.
2012-10-01 23:02:50 +02:00
Nadeem Vawda b7a0bfe912 Issue #16304: Further performance improvements for BZ2File.
Optimizations suggested by Serhiy Storchaka.
2012-09-30 23:58:01 +02:00
Nadeem Vawda 9e2a28ea54 Fix the return value of BZ2File._read_block() to be consistent with comments. 2012-09-30 13:41:29 +02:00
Nadeem Vawda 6c57318c3a Issue #16034: Fix performance regressions in the new BZ2File implementation.
Thanks to Victor Hooi for the bug report, and Serhiy Storchaka for the initial patch.
2012-09-30 03:57:33 +02:00
Nadeem Vawda 8280b4ba02 #15546: Fix BZ2File.read1()'s handling of pathological input data. 2012-08-04 15:29:28 +02:00
Nadeem Vawda af518c198e Add a function bz2.open(), to match gzip.open(). 2012-06-04 23:32:38 +02:00
Nadeem Vawda 50cb936bd0 Clarify acceptable values for BZ2File.__init__'s mode argument. 2012-06-04 23:31:22 +02:00
Nadeem Vawda aebcdba829 Make BZ2File's fileobj support easier to use.
The fileobj argument was added during the 3.3 development cycle, so this change
does not break backward compatibility with 3.2.
2012-06-04 23:31:20 +02:00
Nadeem Vawda ae557d767f Fix seekable() in BZ2File and LZMAFile to check whether the underlying file supports seek(). 2012-02-12 01:51:38 +02:00
Nadeem Vawda 54d8144bb0 Make BZ2File.__init__()'s fileobj argument keyword-only. 2012-02-04 13:58:07 +02:00
Nadeem Vawda cac8909d0c Update docstring for BZ2File.__init__(). 2012-02-04 13:08:11 +02:00
Nadeem Vawda 72750a85f9 Issue #13809: Make bz2 module work with threads disabled.
Original patch by Amaury Forgeot d'Arc.
2012-01-18 01:57:14 +02:00
Nadeem Vawda 44ae4a2a22 Make error handling in BZ2File.{readable,seekable,writable,fileno} consistent with TextIOWrapper.
Also, add tests for these methods.
2011-11-30 17:39:30 +02:00
Nadeem Vawda 249ab5e8d1 BZ2File now uses the compresslevel argument given by the caller,
instead of ignoring it and always using a compression level of 9.
2011-09-11 22:38:11 +02:00
Nadeem Vawda 98838bac9c Miscellaneous cleanups to bz2 and test_bz2 following issue #1625.
* In bz2.decompress(), concatenate partial results in a way that should
   be more friendly to other Python implementations
* Remove redundant comments in test_bz2
* Use 'while True:' instead of 'while 1:'
2011-05-30 01:12:24 +02:00
Nadeem Vawda 55b4338874 Issue #1625: BZ2File and bz2.decompress() now support multi-stream files.
Initial patch by Nir Aides.
2011-05-27 01:52:15 +02:00
Nadeem Vawda f1a1af21eb Fix typo in bz2 module. 2011-05-25 00:32:08 +02:00
Antoine Pitrou 24ce386387 Fix whitespace 2011-04-03 17:08:49 +02:00
Antoine Pitrou 37dc5f85b8 Issue #5863: Rewrite BZ2File in pure Python, and allow it to accept
file-like objects using a new `fileobj` constructor argument.  Patch by
Nadeem Vawda.
2011-04-03 17:05:46 +02:00