@@ -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
@@ -1053,20 +1059,33 @@ static PyObject*
10531059fromBignumObj (TkappObject * tkapp , Tcl_Obj * value )
10541060{
10551061 mp_int bigValue ;
1062+ mp_err err ;
1063+ #if USE_DEPRECATED_TOMMATH_API
10561064 unsigned long numBytes ;
1065+ #else
1066+ size_t numBytes ;
1067+ #endif
10571068 unsigned char * bytes ;
10581069 PyObject * res ;
10591070
10601071 if (Tcl_GetBignumFromObj (Tkapp_Interp (tkapp ), value , & bigValue ) != TCL_OK )
10611072 return Tkinter_Error (tkapp );
1073+ #if USE_DEPRECATED_TOMMATH_API
10621074 numBytes = mp_unsigned_bin_size (& bigValue );
1075+ #else
1076+ numBytes = mp_ubin_size (& bigValue );
1077+ #endif
10631078 bytes = PyMem_Malloc (numBytes );
10641079 if (bytes == NULL ) {
10651080 mp_clear (& bigValue );
10661081 return PyErr_NoMemory ();
10671082 }
1068- if (mp_to_unsigned_bin_n (& bigValue , bytes ,
1069- & numBytes ) != MP_OKAY ) {
1083+ #if USE_DEPRECATED_TOMMATH_API
1084+ err = mp_to_unsigned_bin_n (& bigValue , bytes , & numBytes );
1085+ #else
1086+ err = mp_to_ubin (& bigValue , bytes , numBytes , NULL );
1087+ #endif
1088+ if (err != MP_OKAY ) {
10701089 mp_clear (& bigValue );
10711090 PyMem_Free (bytes );
10721091 return PyErr_NoMemory ();
0 commit comments