Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #104568
chrstphrchvz opened this issue May 11, 2023 · 3 comments
Closed
Tracked by #104568

Comments

@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented May 11, 2023

_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

@terryjreedy
Copy link
Member

@serhiy-storchaka The issue is about patching _tkinter, which is beyond me.

@chrstphrchvz
Copy link
Contributor Author

…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.

If I understand correctly, the current logic in tkinter.Tk._loadtk() enforces that the versions (but not the more specific patchlevel) of Tcl and Tk at runtime matches what Tkinter was compiled against. So enabling the new functions on 8.7 should be fine.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 6, 2023
…04407)

(cherry picked from commit 00d73ca)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 6, 2023
…04407)

(cherry picked from commit 00d73ca)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
@serhiy-storchaka
Copy link
Member

Thank you for your contribution @chrstphrchvz.

terryjreedy pushed a commit that referenced this issue Jun 6, 2023
#105343)

gh-104399: Use newer libtommath APIs when necessary (GH-104407)
(cherry picked from commit 00d73ca)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
terryjreedy pushed a commit that referenced this issue Jun 6, 2023
#105344)

gh-104399: Use newer libtommath APIs when necessary (GH-104407)
(cherry picked from commit 00d73ca)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants