Tcl Source Code

View Ticket
Login
2026-10-22
17:19 • Ticket [63941fee4f] interp create resets the system encoding set by encoding sys... artifact: 7d1c2071a0 user: serhiy.storchaka
2026-10-20
08:42 • Ticket [c35e347c6f] Concurrent Tcl_Init calls race in Unix locale initialization... artifact: f599e9b2c9 user: serhiy.storchaka
2026-10-18
21:44 • Ticket [c35e347c6f]: 3 changes artifact: 1034e112f5 user: serhiy.storchaka
21:02 • Ticket [c35e347c6f]: 3 changes artifact: 7283e91c05 user: jan.nijtmans
2026-10-17
07:25 • Closed ticket [63941fee4f]: interp create resets the system encoding set by enco... artifact: 651c1cbbd3 user: serhiy.storchaka
07:22
Fix [63941fee4f]: interp create resets the system encoding set by [encoding system] check-in: 27f849b6b3 user: serhiy.storchaka tags: core-9-0-branch
07:19
Fix [63941fee4f]: interp create resets the system encoding set by [encoding system] check-in: 00b1026efe user: serhiy.storchaka tags: trunk, main
06:46 • Ticket [63941fee4f] interp create resets the system encoding set by encoding sys... artifact: f3d1ce6b6c user: jan.nijtmans
2026-10-16
22:12 • Ticket [63941fee4f]: 3 changes artifact: d4ba36ed13 user: serhiy.storchaka
22:09
Fix [63941fee4f]: interp create reset the system encoding set by [encoding system]. TclpSetInitialEn... closed check-in: 03512d66eb user: serhiy.storchaka tags: initial-encoding-once
22:05 • New ticket [63941fee4f] interp create resets the system encoding set by encoding... artifact: 0a1b32dcc7 user: serhiy.storchaka

Ticket UUID: 63941fee4fc984f8675b6cabff50b18457b9255b
Title: interp create resets the system encoding set by encoding system
Type: Bug Created on: 2026-10-16 22:05:58
Submitter: serhiy.storchaka Assigned to: aku
Subsystem: 44. UTF-8 Strings Severity: Minor
Priority: 5 Medium Last modified: 2026-10-22 17:19:27
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-17 07:25:45
Version: 9.0.5, 9.1.0
Description:

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

User Comments:
serhiy.storchaka added on 2026-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.nijtmans added on 2026-10-17 06:46:04:

I agree with this.

Please go ahead merging this!


serhiy.storchaka added on 2026-10-17 07:25:45:

Merged into main in [00b1026efe] and into 9.0 in [27f849b6b3].