@@ -60,6 +60,12 @@ Copyright (C) 1994 Steen Lumholt.
6060
6161#include <tclTomMath.h>
6262
63+ #if defined(TCL_WITH_EXTERNAL_TOMMATH ) || (TK_HEX_VERSION >= 0x08070000 )
64+ #define USE_DEPRECATED_TOMMATH_API 0
65+ #else
66+ #define USE_DEPRECATED_TOMMATH_API 1
67+ #endif
68+
6369#if !(defined(MS_WINDOWS ) || defined(__CYGWIN__ ))
6470#define HAVE_CREATEFILEHANDLER
6571#endif
@@ -1083,20 +1089,33 @@ static PyObject*
10831089fromBignumObj (TkappObject * tkapp , Tcl_Obj * value )
10841090{
10851091 mp_int bigValue ;
1092+ mp_err err ;
1093+ #if USE_DEPRECATED_TOMMATH_API
10861094 unsigned long numBytes ;
1095+ #else
1096+ size_t numBytes ;
1097+ #endif
10871098 unsigned char * bytes ;
10881099 PyObject * res ;
10891100
10901101 if (Tcl_GetBignumFromObj (Tkapp_Interp (tkapp ), value , & bigValue ) != TCL_OK )
10911102 return Tkinter_Error (tkapp );
1103+ #if USE_DEPRECATED_TOMMATH_API
10921104 numBytes = mp_unsigned_bin_size (& bigValue );
1105+ #else
1106+ numBytes = mp_ubin_size (& bigValue );
1107+ #endif
10931108 bytes = PyMem_Malloc (numBytes );
10941109 if (bytes == NULL ) {
10951110 mp_clear (& bigValue );
10961111 return PyErr_NoMemory ();
10971112 }
1098- if (mp_to_unsigned_bin_n (& bigValue , bytes ,
1099- & numBytes ) != MP_OKAY ) {
1113+ #if USE_DEPRECATED_TOMMATH_API
1114+ err = mp_to_unsigned_bin_n (& bigValue , bytes , & numBytes );
1115+ #else
1116+ err = mp_to_ubin (& bigValue , bytes , numBytes , NULL );
1117+ #endif
1118+ if (err != MP_OKAY ) {
11001119 mp_clear (& bigValue );
11011120 PyMem_Free (bytes );
11021121 return PyErr_NoMemory ();
0 commit comments