Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-07-05
17:14 • Ticket [9b2e636361] Tcl_CreateInterp() needs initialized encoding search path</i... artifact: 710a2b7a9e user: dgp
16:53 • Ticket [9b2e636361]: 5 changes artifact: 8a7a92d0ff user: dgp
16:00 • Ticket [9b2e636361]: 5 changes artifact: 7e0d4ab1e2 user: dgp
2013-06-27
09:16 • Closed ticket [9b2e636361]. artifact: 81cf61f624 user: jan.nijtmans
09:11 • Ticket [9b2e636361]: 3 changes artifact: d7bca6f4dc user: jan.nijtmans
08:51
Bug [9b2e636361]: Tcl_CreateInterp() needs initialized encodings. check-in: 6189063c4d user: jan.nijtmans tags: trunk
08:28
Bug [9b2e636361]: Tcl_CreateInterp() needs initialized encodings. check-in: 341f682e08 user: jan.nijtmans tags: core-8-5-branch
2013-06-26
07:45 • Ticket [9b2e636361] Tcl_CreateInterp() needs initialized encodings status st... artifact: 407716f6e9 user: jan.nijtmans
07:42
Proposed solution for [9b2e636361] check-in: 06020a12ac user: jan.nijtmans tags: ticket-9b2e636361
07:41 • New ticket [9b2e636361] Tcl_CreateInterp() needs initialized encodings. artifact: c24c63b48f user: jan.nijtmans

Tcl_CreateInterp() needs initialized encoding search path

Closed / Fixed9b2e63636199b969e480a2a5fdba09588b0f0170Created 13 years agoUpdated 13 years ago
Descriptionwiki2013-06-26 07:41:10
Starting with Tcl 8.5 (Actually, [tip.tcl.tk/59|TIP #59]) Tcl_CreateInterp() needs the encodings to be initialized. This makes it impossible to implement a VFS using scripts. Thinking about it, it's a design error in TIP #59, but that's easy to conclude afterwards. Fixing this would prevent the need for a double TclInitSubsystems() call in tclMain.c: one in Tcl_FindExecutable(), one on Tcl_CreateInterp().
Referenced by3
jan.nijtmanswiki2013-06-26 07:45:05

Proposed solution in [06020a12ac]

jan.nijtmanswiki2013-06-27 09:11:52

Fixed in core-8-5-branch [341f682e08] and trunk [6189063c4d], with more comments and using a Byte Array in stead of a String to store unencoded configuration values (Good suggestion by Andreas Kupries, thanks!)

jan.nijtmans Closed ticket [9b2e636361]. [History diff]2013-06-27 09:16:04
dgpplain2013-07-05 16:00:13
Related issue is [983509].

Reviewing the patch now.  Wondering whether
ProcessGlobalValue is a useful tool here.
dgpplain2013-07-05 16:53:26
Yes this change is a fix for [983509] (why isn't
this a link?).

PGV is not helpful here.  These values are stored
per-interp, so a process-global thing isn't useful.

So this patch is a good one.

I don't think the description is as helpful as
it ought to be, since the notion of "initialized
encodings" covers multiple stages.

The first stage is the call to TclInitEncodingSubsystem(),
which is called by TclInitSubsystems() which in turn is
called early by Tcl_CreateInterp(), so that level of 
initialization is always complete and not an issue.  This
means the core machinery is set up and the set of built-in
encodings (identity, utf-8, unicode, iso8859-1) is ready
to go.

The second stage is the call to TclpSetInitialEncodings()
which this patch delays until after Tcl_CreateInterp() is
complete.  The only thing functionally that call does is 
to (try to) set the value of [encoding system] to match
the value it detects the environment expects it to have.
Since the workings of Tcl_RegisterConfig() don't make use
of the system encoding, the direct effect of that routine
doesn't really matter here.

The third stage is getting the [encoding dirs] search path
set up to locate where the *.enc files are actually stored.
This isn't done explicitly by Tcl initialization.  Instead
either the first [encoding dirs] command in init.tcl or
the first attempt to use an encoding that is not built-in
will cause the default search path to be established by the
routine InitializeEncodingSearchPath().  In some embedding
scenarios -- notably kit things that store *.enc in a 
script-powered VFS -- this default path won't be a successful
one, and a later [encoding dirs $path] will need to establish
a fully working encoding system.

It's the third stage that's really the issue here, so I revised
the Title to make that more clear.
dgpplain2013-07-05 17:14:26
All that said, I think Twylite is correct
and we'd be better off doing what we can
to establish that the value of CFG_ENCODING
when we build Tcl is the name of one of
the built-in encodings.  That's already true
on many platforms.  That's a fairly straightforward
first step toward the more radical redesign where
we deny the use of CFG_ENCODING completely, and
just demand conformance to a particular encoding
in the built-in set, likely utf-8.
Log in (anonymous is fine) to add a comment.