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
88440960
Commit
88440960
authored
Mar 25, 2008
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A stab in the dark attempt to fix the alpha/tru64 buildbot problem and add more
test coverage of valid inputs to zlib.crc32.
parent
4677fbf7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
Lib/tarfile.py
Lib/tarfile.py
+2
-2
Lib/test/test_zlib.py
Lib/test/test_zlib.py
+9
-0
No files found.
Lib/tarfile.py
View file @
88440960
...
...
@@ -420,7 +420,7 @@ class _Stream:
except
ImportError
:
raise
CompressionError
(
"zlib module is not available"
)
self
.
zlib
=
zlib
self
.
crc
=
zlib
.
crc32
(
""
)
self
.
crc
=
zlib
.
crc32
(
""
)
&
0xffffffff
L
if
mode
==
"r"
:
self
.
_init_read_gz
()
else
:
...
...
@@ -458,7 +458,7 @@ class _Stream:
"""Write string s to the stream.
"""
if
self
.
comptype
==
"gz"
:
self
.
crc
=
self
.
zlib
.
crc32
(
s
,
self
.
crc
)
self
.
crc
=
self
.
zlib
.
crc32
(
s
,
self
.
crc
)
&
0xffffffff
L
self
.
pos
+=
len
(
s
)
if
self
.
comptype
!=
"tar"
:
s
=
self
.
cmp
.
compress
(
s
)
...
...
Lib/test/test_zlib.py
View file @
88440960
...
...
@@ -53,6 +53,15 @@ class ChecksumTestCase(unittest.TestCase):
self
.
assertEqual
(
binascii
.
crc32
(
foo
),
zlib
.
crc32
(
foo
))
self
.
assertEqual
(
binascii
.
crc32
(
'spam'
),
zlib
.
crc32
(
'spam'
))
def
test_negative_crc_iv_input
(
self
):
# The range of valid input values for the crc state should be
# -2**31 through 2**32-1 to allow inputs artifically constrained
# to a signed 32-bit integer.
self
.
assertEqual
(
zlib
.
crc32
(
'ham'
,
-
1
),
zlib
.
crc32
(
'ham'
,
0xffffffff
L
))
self
.
assertEqual
(
zlib
.
crc32
(
'spam'
,
-
3141593
),
zlib
.
crc32
(
'spam'
,
0xffd01027
L
))
self
.
assertEqual
(
zlib
.
crc32
(
'spam'
,
-
(
2
**
31
)),
zlib
.
crc32
(
'spam'
,
(
2
**
31
)))
class
ExceptionTestCase
(
unittest
.
TestCase
):
...
...
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