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
53d559b4
Commit
53d559b4
authored
Aug 22, 2006
by
Thomas Wouters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make bytesobject raise ValueError instead of TypeError again (thanks, Nick)
parent
40bf2198
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+4
-4
Objects/bytesobject.c
Objects/bytesobject.c
+4
-4
No files found.
Lib/test/test_bytes.py
View file @
53d559b4
...
...
@@ -60,13 +60,13 @@ class BytesTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
bytes
,
[
-
1
])
self
.
assertRaises
(
ValueError
,
bytes
,
[
-
sys
.
maxint
])
self
.
assertRaises
(
ValueError
,
bytes
,
[
-
sys
.
maxint
-
1
])
self
.
assertRaises
(
Typ
eError
,
bytes
,
[
-
sys
.
maxint
-
2
])
self
.
assertRaises
(
Typ
eError
,
bytes
,
[
-
10
**
100
])
self
.
assertRaises
(
Valu
eError
,
bytes
,
[
-
sys
.
maxint
-
2
])
self
.
assertRaises
(
Valu
eError
,
bytes
,
[
-
10
**
100
])
self
.
assertRaises
(
ValueError
,
bytes
,
[
256
])
self
.
assertRaises
(
ValueError
,
bytes
,
[
257
])
self
.
assertRaises
(
ValueError
,
bytes
,
[
sys
.
maxint
])
self
.
assertRaises
(
Typ
eError
,
bytes
,
[
sys
.
maxint
+
1
])
self
.
assertRaises
(
Typ
eError
,
bytes
,
[
10
**
100
])
self
.
assertRaises
(
Valu
eError
,
bytes
,
[
sys
.
maxint
+
1
])
self
.
assertRaises
(
Valu
eError
,
bytes
,
[
10
**
100
])
def
test_repr
(
self
):
self
.
assertEqual
(
repr
(
bytes
()),
"bytes()"
)
...
...
Objects/bytesobject.c
View file @
53d559b4
...
...
@@ -245,7 +245,7 @@ bytes_contains(PyBytesObject *self, PyObject *value)
if
(
PyBytes_Check
(
value
))
return
bytes_substring
(
self
,
(
PyBytesObject
*
)
value
);
ival
=
PyNumber_AsSsize_t
(
value
,
PyExc_
Typ
eError
);
ival
=
PyNumber_AsSsize_t
(
value
,
PyExc_
Valu
eError
);
if
(
ival
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
if
(
ival
<
0
||
ival
>=
256
)
{
...
...
@@ -365,7 +365,7 @@ bytes_setitem(PyBytesObject *self, Py_ssize_t i, PyObject *value)
if
(
value
==
NULL
)
return
bytes_setslice
(
self
,
i
,
i
+
1
,
NULL
);
ival
=
PyNumber_AsSsize_t
(
value
,
PyExc_
Typ
eError
);
ival
=
PyNumber_AsSsize_t
(
value
,
PyExc_
Valu
eError
);
if
(
ival
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
...
...
@@ -448,7 +448,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
}
/* Is it an int? */
count
=
PyNumber_AsSsize_t
(
arg
,
PyExc_
Typ
eError
);
count
=
PyNumber_AsSsize_t
(
arg
,
PyExc_
Valu
eError
);
if
(
count
==
-
1
&&
PyErr_Occurred
())
PyErr_Clear
();
else
{
...
...
@@ -500,7 +500,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
}
/* Interpret it as an int (__index__) */
value
=
PyNumber_AsSsize_t
(
item
,
PyExc_
Typ
eError
);
value
=
PyNumber_AsSsize_t
(
item
,
PyExc_
Valu
eError
);
Py_DECREF
(
item
);
if
(
value
==
-
1
&&
PyErr_Occurred
())
goto
error
;
...
...
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