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
a280ca75
Commit
a280ca75
authored
Aug 28, 2007
by
Lars Gustäbel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conform to strict str/bytes distinction.
parent
6665cefb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
Lib/tarfile.py
Lib/tarfile.py
+4
-4
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+4
-4
No files found.
Lib/tarfile.py
View file @
a280ca75
...
...
@@ -214,7 +214,7 @@ def itn(n, digits=8, format=DEFAULT_FORMAT):
# encoding, the following digits-1 bytes are a big-endian
# representation. This allows values up to (256**(digits-1))-1.
if
0
<=
n
<
8
**
(
digits
-
1
):
s
=
bytes
(
"%0*o"
%
(
digits
-
1
,
n
))
+
NUL
s
=
bytes
(
"%0*o"
%
(
digits
-
1
,
n
)
,
"ascii"
)
+
NUL
else
:
if
format
!=
GNU_FORMAT
or
n
>=
256
**
(
digits
-
1
):
raise
ValueError
(
"overflow in number field"
)
...
...
@@ -604,7 +604,7 @@ class _StreamProxy(object):
def
getcomptype
(
self
):
if
self
.
buf
.
startswith
(
b"
\
037
\
213
\
010
"
):
return
"gz"
if
self
.
buf
.
startswith
(
"BZh91"
):
if
self
.
buf
.
startswith
(
b
"BZh91"
):
return
"bz2"
return
"tar"
...
...
@@ -1108,7 +1108,7 @@ class TarInfo(object):
buf
=
struct
.
pack
(
"%ds"
%
BLOCKSIZE
,
b""
.
join
(
parts
))
chksum
=
calc_chksums
(
buf
[
-
BLOCKSIZE
:])[
0
]
buf
=
buf
[:
-
364
]
+
bytes
(
"%06o
\
0
"
%
chksum
)
+
buf
[
-
357
:]
buf
=
buf
[:
-
364
]
+
bytes
(
"%06o
\
0
"
%
chksum
,
"ascii"
)
+
buf
[
-
357
:]
return
buf
@
staticmethod
...
...
@@ -1155,7 +1155,7 @@ class TarInfo(object):
if
n
==
p
:
break
p
=
n
records
+=
bytes
(
str
(
p
))
+
b" "
+
keyword
+
b"="
+
value
+
b"
\
n
"
records
+=
bytes
(
str
(
p
)
,
"ascii"
)
+
b" "
+
keyword
+
b"="
+
value
+
b"
\
n
"
# We use a hardcoded "././@PaxHeader" name like star does
# instead of the one that POSIX recommends.
...
...
Lib/test/test_tarfile.py
View file @
a280ca75
...
...
@@ -481,7 +481,7 @@ class WriteTest(unittest.TestCase):
tar
=
tarfile
.
open
(
tmpname
,
self
.
mode
)
path
=
os
.
path
.
join
(
TEMPDIR
,
"file"
)
fobj
=
open
(
path
,
"wb"
)
fobj
.
write
(
"aaa"
)
fobj
.
write
(
b
"aaa"
)
fobj
.
close
()
tar
.
add
(
path
)
tar
.
close
()
...
...
@@ -499,7 +499,7 @@ class WriteTest(unittest.TestCase):
self
.
assertEqual
(
tarinfo
.
size
,
0
)
fobj
=
open
(
path
,
"wb"
)
fobj
.
write
(
"aaa"
)
fobj
.
write
(
b
"aaa"
)
fobj
.
close
()
tarinfo
=
tar
.
gettarinfo
(
path
)
self
.
assertEqual
(
tarinfo
.
size
,
3
)
...
...
@@ -603,7 +603,7 @@ class StreamWriteTest(unittest.TestCase):
data
=
fobj
.
read
()
fobj
.
close
()
self
.
assert_
(
data
.
count
(
"
\
0
"
)
==
tarfile
.
RECORDSIZE
,
self
.
assert_
(
data
.
count
(
b
"
\
0
"
)
==
tarfile
.
RECORDSIZE
,
"incorrect zero padding"
)
...
...
@@ -693,7 +693,7 @@ class HardlinkTest(unittest.TestCase):
self
.
bar
=
os
.
path
.
join
(
TEMPDIR
,
"bar"
)
fobj
=
open
(
self
.
foo
,
"wb"
)
fobj
.
write
(
"foo"
)
fobj
.
write
(
b
"foo"
)
fobj
.
close
()
os
.
link
(
self
.
foo
,
self
.
bar
)
...
...
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