diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-06 14:01:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 14:01:54 (GMT) |
commit | c644fe403aa5eede2b0406e43a67eba0c2869d90 (patch) | |
tree | 516a94278598fb4ef3320ba9c7b4d4a1fdc7124e /Modules | |
parent | b8d3bb72b0bfa8bcc0fae282739d4e534c57aac6 (diff) | |
download | cpython-c644fe403aa5eede2b0406e43a67eba0c2869d90.zip cpython-c644fe403aa5eede2b0406e43a67eba0c2869d90.tar.gz cpython-c644fe403aa5eede2b0406e43a67eba0c2869d90.tar.bz2 |
[3.11] gh-104399: Use newer libtommath APIs when necessary (GH-104407) (#105344)
gh-104399: Use newer libtommath APIs when necessary (GH-104407)
(cherry picked from commit 00d73caf804c0474980e471347d6385757af975f)
Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_tkinter.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 4807ad5..2aab68e 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -60,6 +60,12 @@ Copyright (C) 1994 Steen Lumholt. #include <tclTomMath.h> +#if defined(TCL_WITH_EXTERNAL_TOMMATH) || (TK_HEX_VERSION >= 0x08070000) +#define USE_DEPRECATED_TOMMATH_API 0 +#else +#define USE_DEPRECATED_TOMMATH_API 1 +#endif + #if !(defined(MS_WINDOWS) || defined(__CYGWIN__)) #define HAVE_CREATEFILEHANDLER #endif @@ -1083,20 +1089,33 @@ static PyObject* fromBignumObj(TkappObject *tkapp, Tcl_Obj *value) { mp_int bigValue; + mp_err err; +#if USE_DEPRECATED_TOMMATH_API unsigned long numBytes; +#else + size_t numBytes; +#endif unsigned char *bytes; PyObject *res; if (Tcl_GetBignumFromObj(Tkapp_Interp(tkapp), value, &bigValue) != TCL_OK) return Tkinter_Error(tkapp); +#if USE_DEPRECATED_TOMMATH_API numBytes = mp_unsigned_bin_size(&bigValue); +#else + numBytes = mp_ubin_size(&bigValue); +#endif bytes = PyMem_Malloc(numBytes); if (bytes == NULL) { mp_clear(&bigValue); return PyErr_NoMemory(); } - if (mp_to_unsigned_bin_n(&bigValue, bytes, - &numBytes) != MP_OKAY) { +#if USE_DEPRECATED_TOMMATH_API + err = mp_to_unsigned_bin_n(&bigValue, bytes, &numBytes); +#else + err = mp_to_ubin(&bigValue, bytes, numBytes, NULL); +#endif + if (err != MP_OKAY) { mp_clear(&bigValue); PyMem_Free(bytes); return PyErr_NoMemory(); |