Skip to content

Tkinter uses deprecated functions mp_to_unsigned_bin_n() and mp_unsigned_bin_size() #104399

Closed
@chrstphrchvz

Description

@chrstphrchvz

_tkinter.c currently uses the functions mp_to_unsigned_bin_n() and mp_unsigned_bin_size(), which were deprecated in libtommath 1.2.0 and replaced by new functions mp_to_ubin() and mp_ubin_size().

The deprecated functions are removed from future libtommath and Tcl 9.0, leaving _tkinter.c unable to build:

./Modules/_tkinter.c:1089:16: error: call to undeclared function 'mp_unsigned_bin_size'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
    numBytes = mp_unsigned_bin_size(&bigValue);
               ^
./Modules/_tkinter.c:1095:9: error: call to undeclared function 'TclBN_mp_to_unsigned_bin_n'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
    if (mp_to_unsigned_bin_n(&bigValue, bytes,
        ^
/Users/user/tcl90p/include/tclTomMathDecls.h:153:30: note: expanded from macro 'mp_to_unsigned_bin_n'
#define mp_to_unsigned_bin_n TclBN_mp_to_unsigned_bin_n
                             ^

TIP 538 says that Tcl 8.7/9.0 can build against external libtommath 1.2.0 or later. So if TCL_WITH_EXTERNAL_TOMMATH is defined, or if TCL_MAJOR_VERSION >= 9, then mp_to_ubin() and mp_ubin_size() should be available.

Even though mp_to_ubin() and mp_ubin_size() have been available since Tcl 8.6.10 (the first release to bundle libtommath 1.2.0), mp_to_ubin() was added as a new ABI, unlike mp_ubin_size() which was added by having the existing ABI for mp_unsigned_bin_size() return size_t instead of int. So Tkinter presumably could use the new functions when built with Tcl 8.6.10 through 8.7 only if there is no expectation for that build to work with Tcl 8.5.12 through 8.6.9; otherwise the deprecated functions can continue to be used for Tcl < 9.

Note that Tcl 8.7 with bundled libtommath currently only warns about mp_to_unsigned_bin_n() being deprecated:

./Modules/_tkinter.c:1099:9: warning: 'TclBN_mp_to_unsigned_bin_n' is deprecated [-Wdeprecated-declarations]
    if (mp_to_unsigned_bin_n(&bigValue, bytes,
        ^
/Users/user/tcl87p/include/tclTomMathDecls.h:150:30: note: expanded from macro 'mp_to_unsigned_bin_n'
#define mp_to_unsigned_bin_n TclBN_mp_to_unsigned_bin_n
                             ^
/Users/user/tcl87p/include/tclTomMathDecls.h:316:1: note: 'TclBN_mp_to_unsigned_bin_n' has been explicitly marked deprecated here
TCL_DEPRECATED("Use mp_to_ubin")
^
/Users/user/tcl87p/include/tclDecls.h:33:37: note: expanded from macro 'TCL_DEPRECATED'
# define TCL_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg)
                                    ^
/Users/user/tcl87p/include/tcl.h:181:50: note: expanded from macro 'TCL_DEPRECATED_API'
#       define TCL_DEPRECATED_API(msg)  __attribute__ ((__deprecated__))
                                                        ^

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions