summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorJustin Applegate <70449145+Legoclones@users.noreply.github.com>2024-12-11 12:37:59 (GMT)
committerGitHub <noreply@github.com>2024-12-11 12:37:59 (GMT)
commitce76b547f94de6b1c9c74657b4e8f150365ad76f (patch)
tree0cd674a625cd7319aa2e1bd927b85148c2949fa1 /Modules/_pickle.c
parentd5d84c3f13fe7fe591b375c41979d362bc11957a (diff)
downloadcpython-ce76b547f94de6b1c9c74657b4e8f150365ad76f.zip
cpython-ce76b547f94de6b1c9c74657b4e8f150365ad76f.tar.gz
cpython-ce76b547f94de6b1c9c74657b4e8f150365ad76f.tar.bz2
gh-126992: Change pickle code to base 10 for load_long and load_int (GH-127042)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 2696f38..599b5f9 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -5211,16 +5211,14 @@ load_int(PickleState *state, UnpicklerObject *self)
return bad_readline(state);
errno = 0;
- /* XXX: Should the base argument of strtol() be explicitly set to 10?
- XXX(avassalotti): Should this uses PyOS_strtol()? */
- x = strtol(s, &endptr, 0);
+ /* XXX(avassalotti): Should this uses PyOS_strtol()? */
+ x = strtol(s, &endptr, 10);
if (errno || (*endptr != '\n' && *endptr != '\0')) {
/* Hm, maybe we've got something long. Let's try reading
* it as a Python int object. */
errno = 0;
- /* XXX: Same thing about the base here. */
- value = PyLong_FromString(s, NULL, 0);
+ value = PyLong_FromString(s, NULL, 10);
if (value == NULL) {
PyErr_SetString(PyExc_ValueError,
"could not convert string to int");
@@ -5370,8 +5368,7 @@ load_long(PickleState *state, UnpicklerObject *self)
the 'L' to be present. */
if (s[len-2] == 'L')
s[len-2] = '\0';
- /* XXX: Should the base argument explicitly set to 10? */
- value = PyLong_FromString(s, NULL, 0);
+ value = PyLong_FromString(s, NULL, 10);
if (value == NULL)
return -1;