Tk Source Code

View Ticket
Login
Ticket UUID: a91b242d437b5d949c7a4c63db661e035f8f8169
Title: Correct macOSVersion on future macOS for older SDK builds
Type: Bug Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2025-08-13 21:29:36
Subsystem: 83. Mac OS X Build Assigned To: chrstphrchvz
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-08-15 22:30:01
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2025-08-15 22:30:01
Description:

When a program is built with a macOS SDK earlier than version 11 (i.e. a macOS 10.x SDK), and then run on macOS 11 and later, it sees 10.16 as the system macOS version. The macOSVersion variable (as used by the ::tk::mac::macOSVersion command) works around this by computing the macOS version from the Darwin kernel version. Because macOS Tahoe jumps to version 26, does this calculation require adjustment? Possible fix:

--- macosx/tkMacOSXInit.c
+++ macosx/tkMacOSXInit.c
@@ -283,7 +283,10 @@
 	struct utsname name;
 	char *endptr;
 	if (uname(&name) == 0) {
-	    majorVersion = (int)strtol(name.release, &endptr, 10) - 9;
+	    majorVersion = (int)strtol(name.release, &endptr, 10) + 1;
+	    if (majorVersion < 26) {
+		majorVersion -= 10;
+	    }
 	    minorVersion = 0;
 	}
     }

User Comments: jan.nijtmans added on 2025-08-15 22:30:01:

Fixed [f2d0ceecc7a789d3|here] and in all other active branches

Thanks for the report and the patch!