@@ -65,6 +65,12 @@ Copyright (C) 1994 Steen Lumholt.
6565#endif
6666#include <tclTomMath.h>
6767
68+ #if defined(TCL_WITH_EXTERNAL_TOMMATH ) || (TK_HEX_VERSION >= 0x08070000 )
69+ #define USE_DEPRECATED_TOMMATH_API 0
70+ #else
71+ #define USE_DEPRECATED_TOMMATH_API 1
72+ #endif
73+
6874#if !(defined(MS_WINDOWS ) || defined(__CYGWIN__ ))
6975#define HAVE_CREATEFILEHANDLER
7076#endif
@@ -1049,20 +1055,33 @@ static PyObject*
10491055fromBignumObj (TkappObject * tkapp , Tcl_Obj * value )
10501056{
10511057 mp_int bigValue ;
1058+ mp_err err ;
1059+ #if USE_DEPRECATED_TOMMATH_API
10521060 unsigned long numBytes ;
1061+ #else
1062+ size_t numBytes ;
1063+ #endif
10531064 unsigned char * bytes ;
10541065 PyObject * res ;
10551066
10561067 if (Tcl_GetBignumFromObj (Tkapp_Interp (tkapp ), value , & bigValue ) != TCL_OK )
10571068 return Tkinter_Error (tkapp );
1069+ #if USE_DEPRECATED_TOMMATH_API
10581070 numBytes = mp_unsigned_bin_size (& bigValue );
1071+ #else
1072+ numBytes = mp_ubin_size (& bigValue );
1073+ #endif
10591074 bytes = PyMem_Malloc (numBytes );
10601075 if (bytes == NULL ) {
10611076 mp_clear (& bigValue );
10621077 return PyErr_NoMemory ();
10631078 }
1064- if (mp_to_unsigned_bin_n (& bigValue , bytes ,
1065- & numBytes ) != MP_OKAY ) {
1079+ #if USE_DEPRECATED_TOMMATH_API
1080+ err = mp_to_unsigned_bin_n (& bigValue , bytes , & numBytes );
1081+ #else
1082+ err = mp_to_ubin (& bigValue , bytes , numBytes , NULL );
1083+ #endif
1084+ if (err != MP_OKAY ) {
10661085 mp_clear (& bigValue );
10671086 PyMem_Free (bytes );
10681087 return PyErr_NoMemory ();
0 commit comments