Tcl Source Code

View Ticket
Login
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-17 07:25:45
Status: Closed Closed by: nobody
Resolution: Fixed Closed on:
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].