This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年02月10日 19:46 by travis, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| zlibmodule.diff | travis, 2009年02月12日 17:00 | |||
| zlib_finished_test.txt | solinym, 2009年08月19日 21:39 | patch to test for end-of-compressed-stream indicator | ||
| zlibmodule.c.diff | solinym, 2009年08月21日 16:39 | diff to zlibmodule.c | ||
| test_zlib.py.diff | solinym, 2009年08月21日 16:41 | diff to test_zlib.py | ||
| test_zlib.py.diff | solinym, 2009年08月21日 20:07 | complete version of diff to test_zlib.py | ||
| Messages (12) | |||
|---|---|---|---|
| msg81590 - (view) | Author: Travis Hassloch (travis) | Date: 2009年02月10日 19:46 | |
Underlying zlib can determine when it has hit the end of a compressed stream without reading past the end. Python zlib implementation requires that one read past the end before it signals the end by putting data in Decompress.unused_data. This complicates interfacing with mixed compressed/uncompressed streams. |
|||
| msg81780 - (view) | Author: Travis Hassloch (travis) | Date: 2009年02月12日 17:00 | |
Here is a patch which adds a member called is_finished to decompression objects that allows client code to know when it has reached the end of the compressed stream. |
|||
| msg90523 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2009年07月14日 22:41 | |
Thanks for the patch! Can you provide tests too? |
|||
| msg90817 - (view) | Author: Travis H. (solinym) | Date: 2009年07月22日 15:58 | |
What kind of tests did you have in mind? Unit tests in python, or something else? |
|||
| msg90820 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2009年07月22日 20:35 | |
Yes, I think that the right place where to add the tests is Lib/test/test_zlib.py |
|||
| msg91749 - (view) | Author: Travis H. (solinym) | Date: 2009年08月19日 21:39 | |
Attaching unit test diff Output of "diff -u test_zlib.py~ test_zlib.py" |
|||
| msg91757 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2009年08月20日 00:09 | |
Some comments about the patch: - In zlibmodule.c, the is_finished member should be an int, and converted to a PyObject only when requested. - The test should check that is_finished is False one byte before the compressed part, and becomes True when the decompressor reads the last compressed byte. I don't think that dco.flush() is necessary for the test. - Also, the last check could be more precise: assertEquals(y1 + y2, HAMLET_SCENE) and assertEquals(dco.unused_data, HAMLET_SCENE) |
|||
| msg91832 - (view) | Author: Travis H. (solinym) | Date: 2009年08月21日 16:39 | |
zlibmodule.c.diff Implements all the suggested features, but I'm not exactly sure whether it handles reference counts properly. |
|||
| msg91833 - (view) | Author: Travis H. (solinym) | Date: 2009年08月21日 16:41 | |
Diff to tests Implements all suggested changes save one: I wasn't sure how to test that is_finished is clear one byte before the end of the compressed section. Instead, I test that it is clear before I call the compression routine. |
|||
| msg91840 - (view) | Author: Travis H. (solinym) | Date: 2009年08月21日 20:07 | |
Figured out how to test is_finished attribute of the zlib module properly. |
|||
| msg91846 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2009年08月21日 21:28 | |
Hm, I tried a modified version of your first test, and I found another problem with the current zlib library; starting with the input: x = x1 + x2 + HAMLET_SCENE # both compressed and uncompressed data The following scenario is OK: dco.decompress(x) # returns HAMLET_SCENE dco.unused_data # returns HAMLET_SCENE But this one: for c in x: dco.decompress(x) # will return HAMLET_SCENE, in several pieces dco.unused_data # only one character, the last of (c in x)! This is a bug IMO: unused_data should accumulate all the extra uncompressed data. |
|||
| msg174057 - (view) | Author: Nadeem Vawda (nadeem.vawda) * (Python committer) | Date: 2012年10月28日 16:26 | |
This bug (zlib not providing a way to detect end-of-stream) has already been fixed - see issue 12646. I've opened issue 16350 for the unused_data problem. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:45 | admin | set | github: 49460 |
| 2012年10月28日 16:26:20 | nadeem.vawda | set | status: open -> closed superseder: zlib.Decompress.decompress/flush do not raise any exceptions when given truncated input streams messages: + msg174057 resolution: out of date stage: test needed -> resolved |
| 2012年01月26日 13:03:45 | nadeem.vawda | set | nosy:
+ nadeem.vawda |
| 2009年08月21日 21:28:26 | amaury.forgeotdarc | set | messages: + msg91846 |
| 2009年08月21日 20:07:56 | solinym | set | files:
+ test_zlib.py.diff messages: + msg91840 |
| 2009年08月21日 16:41:08 | solinym | set | files:
+ test_zlib.py.diff messages: + msg91833 |
| 2009年08月21日 16:39:53 | solinym | set | files:
+ zlibmodule.c.diff messages: + msg91832 |
| 2009年08月20日 00:09:17 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg91757 |
| 2009年08月19日 21:39:51 | solinym | set | files:
+ zlib_finished_test.txt messages: + msg91749 |
| 2009年07月22日 20:35:20 | ezio.melotti | set | messages: + msg90820 |
| 2009年07月22日 15:58:31 | solinym | set | nosy:
+ solinym messages: + msg90817 |
| 2009年07月14日 22:41:20 | ezio.melotti | set | priority: normal versions: + Python 2.7, Python 3.2, - Python 3.0 nosy: + ezio.melotti messages: + msg90523 stage: test needed |
| 2009年07月14日 22:38:08 | ezio.melotti | link | issue6485 superseder |
| 2009年02月12日 17:00:08 | travis | set | files:
+ zlibmodule.diff keywords: + patch messages: + msg81780 |
| 2009年02月10日 19:46:19 | travis | create | |