diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2016-07-10 12:37:30 +0300 |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-07-10 12:37:30 +0300 |
| commit | f9efb8b18b689ff5ef7f12e6124f21532d799516 (patch) | |
| tree | 17ae9815406dabe43fd8dc28c0869a1f8038d14b | |
| parent | 95750b1ca535a9883d483ee82b4373fb47d82bc5 (diff) | |
| download | cpython-git-f9efb8b18b689ff5ef7f12e6124f21532d799516.tar.gz | |
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.
| -rw-r--r-- | Lib/test/test_bytes.py | 1 | ||||
| -rw-r--r-- | Objects/bytes_methods.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 05dc26afaf..129b4abf33 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -269,6 +269,7 @@ class BaseBytesTest: self.assertNotIn(200, b) self.assertRaises(ValueError, lambda: 300 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: float(ord('a')) in b) self.assertRaises(TypeError, lambda: "a" in b) diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c index d0f784ecd4..d7f061bcf0 100644 --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -645,7 +645,7 @@ _Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args) int _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()) { Py_buffer varg; Py_ssize_t pos; |
