-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Tkinter: C API changes are needed for Tcl 8.7 and 9.0 value types #103194
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
Comments
Christopher, thank you for posting and offering your assistence. My understanding is that 8.7 and 9.0 have been in alpha since 2020. Do you have any updated information on when there might be a beta, let along a final release? IOW, how urgent are the needed changes? Our _/tkinter maintainer is currently constrained in his python time. _tkinter patches should be welcome. I just hope he will be available to review any. Our devguide should give you any info you need. I maintain IDLE. From what I have read, the main feature of interest for me in 8.7 is change to Text and in 9.0 full unicode support. Are these in the alphas? If 9.0 does unicode support that works with tkinter, that will be the version I would want out windows and mac installers to install. I wonder though if people would push for 8.7. Should that be an issue? tkinter requires 8.6 now, so supporting 8.5 is not an issue, but 8.6 will be on Linux for possibly a decade or more. Tip 568 suggests replacing |
It sounded like there has been an increased push to get 8.7 and 9.0 beta releases out since last year, but I do not know how imminent these really are. Some areas of improvement do not seem completely settled, e.g. Unicode support/error handling, replacing
Thanks, I will look into creating a pull request for these changes.
The last alpha releases were a couple years ago, so even if they contain these features, I would think there are noticeable differences by now in the development branches. I am not familiar enough with how 8.7 and 9.0 differ (on things like Unicode support) in ways that matter to Tkinter to summarize here. My understanding is that 8.7 is meant as a choice and/or more gradual transition for 8.6 users that really do not want C API or other breaking changes from 9.0. But even some Tcl core team members raise the idea of abandoning 8.7 in favor of 9.0: https://sourceforge.net/p/tcl/mailman/tcl-core/thread/0fdf01d929c6$9c027350$d40759f0$@yahoo.com/
Is the 8.6 requirement already documented somewhere? I find documentation/comments which still mention 8.5.12 as the minimum.
I recently got confirmation that for the use case of wrappers like Tkinter, which only want to use |
There was an idea to require 8.6 instead of 8.5, but yes, we stopped at 8.5.12 in issue 91152.
I think that this would be a lot easier for Python. |
I have a draft of the changes: main...chrstphrchvz:cpython:patch-103194. I have verified that they work under Tcl 8.6.13. The boolean value case in import tkinter
i = tkinter.Tcl()
# retrieve bytearray
i.eval("""
set x [binary decode hex 40]
# manually verify value type:
puts [::tcl::unsupported::representation $x]
""")
assert i.getvar('x') == b'@'
# retrieve booleanString
i.eval("""
# start with pure string
set x yes
puts [::tcl::unsupported::representation $x]
# this command causes x to have booleanString type:
expr {!$x}
puts [::tcl::unsupported::representation $x]
""")
assert i.getvar('x') == True
# retrieve int
i.eval('set x [expr 1+1]')
assert i.getvar('x') == 2
# retrieve wideInt (or int if wideInt is not present)
i.eval("""
set x [expr 1<<32]
puts [::tcl::unsupported::representation $x]
""")
assert i.getvar('x') == (1 << 32) I think the only thing left to settle for this set of changes is whether Also, at least one other person appears interested in having Tkinter work with Tk 8.7: one of the Tk Aqua developers, who has been working on extensive improvements which will only appear in 8.7, attempted to use Tkinter with 8.7 but encountered other issues: https://core.tcl-lang.org/tk/info/6b49149b4e7c. |
That issue seems to indicate another necessary change:
|
A separate report for an attempt to build Tkinter against Tcl 8.7 (https://core.tcl-lang.org/tcl/info/ff255adc4cb5) indicates yet another necessary change:
Package managers presumably would want Tkinter to build against separately-built Tcl/Tk (and in turn separately-built libtommath once they update to 8.7). But given that nothing else in CPython uses libtommath, how much would the official Python binary distributions prefer that Tcl continue building its bundled libtommath? Edit: I have created a separate issue for this: #103839. It may make more sense to address that issue before making the other changes on the issue here. |
Tcl has agreed to register "utf32string": https://core.tcl-lang.org/tcl/vdiff/?from=27d3b99343&to=9883f837fc However it does seem like Tkinter code should still use |
More C API changes are needed for |
…103846) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl.
pythonGH-103846) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl. (cherry picked from commit 94e9585) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
… 8.7/9.0 (pythonGH-103846) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl. (cherry picked from commit 94e9585) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
….0 (GH-103846) (GH-119831) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl. (cherry picked from commit 94e9585) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
….0 (GH-103846) (GH-119830) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl. (cherry picked from commit 94e9585) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
Thank you for your great investigations @chrstphrchvz. I agree with all of your changes. |
pythonGH-103846) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl.
pythonGH-103846) Some of standard Tcl types were renamed, removed, or no longer registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl values to Python values to avoid returning a Tcl_Obj where the primary Python types (int, bool, str, bytes) were returned in older Tcl.
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()
andFromObj()
). 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 theTcl_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 initializingv->BooleanType
fromTkapp_New()
rather than lazily initializingtkapp->BooleanType
fromFromObj()
.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 theTcl_ObjType *
of "int" from a value created usingTcl_NewIntObj(0)
and of "wideInt" (if present) using e.g.Tcl_NewWideIntObj((Tcl_WideInt)(1) << 32)
. However it would not be appropriate forFromObj()
to continue usingTcl_GetLongFromObj()
whenlong
is 32-bit, as that would retrieve an overflowed result for values within (LONG_MAX
,ULONG_MAX
] rather than forceFromObj()
to try again withTcl_GetWideIntFromObj()
(viafromWideIntObj()
); an alternative would be to always useTcl_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
The text was updated successfully, but these errors were encountered: