interp create resets the system encoding set by encoding system
Closed / Fixed63941fee4fc984f8675b6cabff50b18457b9255bCreated 48 days agoUpdated 42 days ago
Descriptionwiki2026-10-16 22:05:58
Since [17c53b7edd] (the fix for [fccb9f322f]) Tcl_Init() calls TclpSetInitialEncodings() for every interpreter, so creating an interpreter (also with Thread or Tk) resets the system encoding to the one from the environment:
encoding system koi8-r interp create a encoding system ;# utf-8 (8.6: koi8-r)
The repeated detection is also what calls setlocale() in parallel threads in [c35e347c6f]. It is only needed while the earlier detection failed (the encoding files were not found yet).
Referenced by6
f599e9b2c9Ticket [c35e347c6f] Concurrent Tcl_Init calls race in Unix locale initialization, causing crashes on OpenBSD status still Open with 3 other changes ticket2026-10-20 08:42:501034e112f5Ticket [c35e347c6f] Concurrent Tcl_Init calls race in Unix locale initialization, causing crashes on OpenBSD status still Open with 3 other changes ticket2026-10-18 21:44:147283e91c05Ticket [c35e347c6f] Concurrent Tcl_Init calls race in Unix locale initialization, causing crashes on OpenBSD status still Open with 3 other changes ticket2026-10-18 21:02:5827f849b6b3Fix [63941fee4f]: interp create resets the system encoding set by [encoding system] check-in2026-10-17 07:22:1900b1026efeFix [63941fee4f]: interp create resets the system encoding set by [encoding system] check-in2026-10-17 07:19:4803512d66ebFix [63941fee4f]: interp create reset the system encoding set by [encoding system]. TclpSetInitialEncodings() sets the encoding from the environment only until it succeeds, so the calls from Tcl_Init() added for [fccb9f322f] no longer reset it. check-in2026-10-16 22:09:50
serhiy.storchakawiki2026-10-16 22:12:02
Proposed fix in branch initial-encoding-once: TclpSetInitialEncodings() sets the encoding from the environment only until it succeeds, so later Tcl_Init() calls do not reset it and do not call setlocale() again. The retry for [fccb9f322f] still works (unixInit-3.2). Test encoding-31.5.
jan.nijtmanswiki2026-10-17 06:46:04
I agree with this.
Please go ahead merging this!
serhiy.storchakawiki2026-10-17 07:25:45
Merged into main in [00b1026efe] and into 9.0 in [27f849b6b3].
serhiy.storchaka Ticket [63941fee4f]: 3 changes
[History diff]2026-10-22 17:19:27
Log in (anonymous is fine) to add a comment.