mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #27474: Unified error messages in the __contains__ method of bytes and
bytearray for integers in and out of the Py_ssize_t range. Patch by Xiang Zhang.
This commit is contained in:
parent
95750b1ca5
commit
f9efb8b18b
2 changed files with 2 additions and 1 deletions
|
@ -269,6 +269,7 @@ class BaseBytesTest:
|
||||||
self.assertNotIn(200, b)
|
self.assertNotIn(200, b)
|
||||||
self.assertRaises(ValueError, lambda: 300 in b)
|
self.assertRaises(ValueError, lambda: 300 in b)
|
||||||
self.assertRaises(ValueError, lambda: -1 in b)
|
self.assertRaises(ValueError, lambda: -1 in b)
|
||||||
|
self.assertRaises(ValueError, lambda: sys.maxsize+1 in b)
|
||||||
self.assertRaises(TypeError, lambda: None in b)
|
self.assertRaises(TypeError, lambda: None in b)
|
||||||
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
|
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
|
||||||
self.assertRaises(TypeError, lambda: "a" in b)
|
self.assertRaises(TypeError, lambda: "a" in b)
|
||||||
|
|
|
@ -645,7 +645,7 @@ _Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args)
|
||||||
int
|
int
|
||||||
_Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg)
|
_Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg)
|
||||||
{
|
{
|
||||||
Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
|
Py_ssize_t ival = PyNumber_AsSsize_t(arg, NULL);
|
||||||
if (ival == -1 && PyErr_Occurred()) {
|
if (ival == -1 && PyErr_Occurred()) {
|
||||||
Py_buffer varg;
|
Py_buffer varg;
|
||||||
Py_ssize_t pos;
|
Py_ssize_t pos;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue