summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-08-23 21:22:52 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-08-23 21:22:52 +0200
commitf0bc37688464646a85ea1ba49ad944c2b4096937 (patch)
tree0066492ec65e89f80b9f698a7f76178cafa99c8c
parent121f7ab484e8dae5ec3629c70c6f8fcae1f57545 (diff)
downloadcython-f0bc37688464646a85ea1ba49ad944c2b4096937.tar.gz
Prevent incorrect coercion from digit-only strings to integers in fallback code if slots are not used (e.g. in PyPy).
-rw-r--r--Cython/Utility/TypeConversion.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c
index f81f8c91d..5fe69fc7e 100644
--- a/Cython/Utility/TypeConversion.c
+++ b/Cython/Utility/TypeConversion.c
@@ -338,7 +338,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
}
#endif
#else
- res = PyNumber_Int(x);
+ if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
+ res = PyNumber_Int(x);
+ }
#endif
if (likely(res)) {
#if PY_MAJOR_VERSION < 3