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
57b93ad5
Commit
57b93ad5
authored
May 08, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repr(b"\0") should return b"\x00", not the (unusual) b"\0".
parent
e5e80b8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+3
-2
Objects/bytesobject.c
Objects/bytesobject.c
+1
-1
No files found.
Lib/test/test_bytes.py
View file @
57b93ad5
...
@@ -73,8 +73,9 @@ class BytesTest(unittest.TestCase):
...
@@ -73,8 +73,9 @@ class BytesTest(unittest.TestCase):
def
test_repr
(
self
):
def
test_repr
(
self
):
self
.
assertEqual
(
repr
(
bytes
()),
"b''"
)
self
.
assertEqual
(
repr
(
bytes
()),
"b''"
)
self
.
assertEqual
(
repr
(
bytes
([
0
])),
"b'
\
\
0'"
)
self
.
assertEqual
(
repr
(
bytes
([
0
])),
"b'
\
\
x00'"
)
self
.
assertEqual
(
repr
(
bytes
([
0
,
1
,
254
,
255
])),
"b'
\
\
0
\
\
x01
\
\
xfe
\
\
xff'"
)
self
.
assertEqual
(
repr
(
bytes
([
0
,
1
,
254
,
255
])),
"b'
\
\
x00
\
\
x01
\
\
xfe
\
\
xff'"
)
self
.
assertEqual
(
repr
(
bytes
(
'abc'
)),
"b'abc'"
)
self
.
assertEqual
(
repr
(
bytes
(
'abc'
)),
"b'abc'"
)
self
.
assertEqual
(
repr
(
bytes
(
"'"
)),
"b'
\
\
''"
)
self
.
assertEqual
(
repr
(
bytes
(
"'"
)),
"b'
\
\
''"
)
...
...
Objects/bytesobject.c
View file @
57b93ad5
...
@@ -849,7 +849,7 @@ bytes_repr(PyBytesObject *self)
...
@@ -849,7 +849,7 @@ bytes_repr(PyBytesObject *self)
else
if
(
c
==
'\r'
)
else
if
(
c
==
'\r'
)
*
p
++
=
'\\'
,
*
p
++
=
'r'
;
*
p
++
=
'\\'
,
*
p
++
=
'r'
;
else
if
(
c
==
0
)
else
if
(
c
==
0
)
*
p
++
=
'\\'
,
*
p
++
=
'0'
;
*
p
++
=
'\\'
,
*
p
++
=
'
x'
,
*
p
++
=
'0'
,
*
p
++
=
'
0'
;
else
if
(
c
<
' '
||
c
>=
0x7f
)
{
else
if
(
c
<
' '
||
c
>=
0x7f
)
{
/* For performance, we don't want to call
/* For performance, we don't want to call
PyOS_snprintf here (extra layers of
PyOS_snprintf here (extra layers of
...
...
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