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
7619e88a
Commit
7619e88a
authored
May 14, 2011
by
Nadeem Vawda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
attribute when called without a max_length argument.
parent
eda19903
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
Lib/test/test_zlib.py
Lib/test/test_zlib.py
+9
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/zlibmodule.c
Modules/zlibmodule.c
+12
-7
No files found.
Lib/test/test_zlib.py
View file @
7619e88a
...
@@ -350,6 +350,15 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
...
@@ -350,6 +350,15 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
self
.
assertRaises
(
ValueError
,
dco
.
decompress
,
b""
,
-
1
)
self
.
assertRaises
(
ValueError
,
dco
.
decompress
,
b""
,
-
1
)
self
.
assertEqual
(
b''
,
dco
.
unconsumed_tail
)
self
.
assertEqual
(
b''
,
dco
.
unconsumed_tail
)
def
test_clear_unconsumed_tail
(
self
):
# Issue #12050: calling decompress() without providing max_length
# should clear the unconsumed_tail attribute.
cdata
=
b"x
\
x9c
KLJ
\
x06
\
x00
\
x02
M
\
x01
"
# "abc"
dco
=
zlib
.
decompressobj
()
ddata
=
dco
.
decompress
(
cdata
,
1
)
ddata
+=
dco
.
decompress
(
dco
.
unconsumed_tail
)
self
.
assertEqual
(
dco
.
unconsumed_tail
,
b""
)
def
test_flushes
(
self
):
def
test_flushes
(
self
):
# Test flush() with the various options, using all the
# Test flush() with the various options, using all the
# different levels in order to provide more variations.
# different levels in order to provide more variations.
...
...
Misc/NEWS
View file @
7619e88a
...
@@ -69,6 +69,9 @@ Core and Builtins
...
@@ -69,6 +69,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
attribute when called without a max_length argument.
- Issue #12062: Fix a flushing bug when doing a certain type of I/O sequence
- Issue #12062: Fix a flushing bug when doing a certain type of I/O sequence
on a file opened in read+write mode (namely: reading, seeking a bit forward,
on a file opened in read+write mode (namely: reading, seeking a bit forward,
writing, then seeking before the previous write but still within buffered
writing, then seeking before the previous write but still within buffered
...
...
Modules/zlibmodule.c
View file @
7619e88a
...
@@ -560,17 +560,22 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
...
@@ -560,17 +560,22 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
}
}
/* Not all of the compressed data could be accommodated in the output buffer
of specified size. Return the unconsumed tail in an attribute.*/
if
(
max_length
)
{
if
(
max_length
)
{
/* Not all of the compressed data could be accommodated in a buffer of
the specified size. Return the unconsumed tail in an attribute. */
Py_DECREF
(
self
->
unconsumed_tail
);
Py_DECREF
(
self
->
unconsumed_tail
);
self
->
unconsumed_tail
=
PyBytes_FromStringAndSize
((
char
*
)
self
->
zst
.
next_in
,
self
->
unconsumed_tail
=
PyBytes_FromStringAndSize
((
char
*
)
self
->
zst
.
next_in
,
self
->
zst
.
avail_in
);
self
->
zst
.
avail_in
);
if
(
!
self
->
unconsumed_tail
)
{
}
Py_DECREF
(
RetVal
);
else
if
(
PyBytes_GET_SIZE
(
self
->
unconsumed_tail
)
>
0
)
{
RetVal
=
NULL
;
/* All of the compressed data was consumed. Clear unconsumed_tail. */
goto
error
;
Py_DECREF
(
self
->
unconsumed_tail
);
}
self
->
unconsumed_tail
=
PyBytes_FromStringAndSize
(
""
,
0
);
}
if
(
self
->
unconsumed_tail
==
NULL
)
{
Py_DECREF
(
RetVal
);
RetVal
=
NULL
;
goto
error
;
}
}
/* The end of the compressed data has been reached, so set the
/* The end of the compressed data has been reached, so set the
...
...
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