Skip to content

Tkinter: C API changes are needed for Tcl 8.7 and 9.0 value types #103194

Closed
@chrstphrchvz

Description

@chrstphrchvz

Bug report

I recently made changes to Tcl.pm (a Tcl wrapper for Perl) to support Tcl 8.7/9.0 (gisle/tcl.pm#42). While I was doing so, I briefly looked at _tkinter.c for comparison (particularly AsObj() and FromObj()). Although I have not attempted to run Tkinter with Tcl 8.7/9.0, I do notice a few issues in the code which would need to be addressed first.

  • Tcl 9.0 currently renames the Tcl 8.5 "booleanString" value type to "boolean", which will break the existing check in FromObj(). Tcl has suggested an idiom for retrieving the Tcl_ObjType * of unregistered types like "booleanString", regardless of Tcl version (see https://core.tcl-lang.org/tcl/info/3bb3bcf2da5b); although I would think that approach entails initializing v->BooleanType from Tkapp_New() rather than lazily initializing tkapp->BooleanType from FromObj().

  • TIP 568: As of Tcl 9.0, "bytearray" is unregistered; the suggested idiom can be used instead.

  • TIP 484: As of Tcl 8.7, on platforms with 32-bit long, there are no longer separate 32-bit "int" and 64-bit "wideInt" value types; there is only a single 64-bit type. And as of Tcl 9.0, the "int" type is unregistered. It is possible to reliably get the Tcl_ObjType * of "int" from a value created using Tcl_NewIntObj(0) and of "wideInt" (if present) using e.g. Tcl_NewWideIntObj((Tcl_WideInt)(1) << 32). However it would not be appropriate for FromObj() to continue using Tcl_GetLongFromObj() when long is 32-bit, as that would retrieve an overflowed result for values within (LONG_MAX,ULONG_MAX] rather than force FromObj() to try again with Tcl_GetWideIntFromObj() (via fromWideIntObj()); an alternative would be to always use Tcl_GetWideIntFromObj() for both "int" and "wideInt" values.

I am not familiar with contributing to Python, but I may be able to propose fixes for the above issues if no one else already has or intends to. I believe the fixes for the above issues are backward compatible with Tcl 8.5 and 8.6, and so can be implemented and tested without other changes that are likely also needed (such as for Tcl-syntax APIs) before Tkinter is usable with Tcl 8.7/9.0 and Tk 8.7 (which will be compatible with both Tcl 8.7 and 9.0) Tcl and Tk 8.7/9.0.

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