ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activetcl
activetcl
Re: [Activetcl] Active state, ::safe:: base, and package require
by Andreas Kupries other posts by this author
Jun 20 2008 10:08AM messages near this date
view in the new Beta List Site
[Activetcl] Active state, ::safe:: base, and package require | Re: [Activetcl] Active state, ::safe:: base, and package require
>  Hi folks,
> 
>  In the tcl documentation of ::safe:: (safe base), it is said that by
>  default a safe interpreter created with :
>      ::safe::interpCreate
>  can source, load and "package require" in the auto_path of its master.
> 
>  Indeed, when using tcl on Linux installed through ActiveState, with tcllib
>  installed through teacup by :
>      teacup install ActiveState::ActiveTcl,
> 
>  there are many packages in the tcllib that cannot be required from a safe
>  interp.
>  EG:
>      % package require math::bigfloat
>      2.0.1
>      % ::safe::interpCreate
>      interp0
>      % interp eval interp0 "package require math::bigfloat"
>      can't find package math::bigfloat
>      % interp eval interp0 "package require math::linearalgebra"
>      can't find package math::linearalgebra

>  Indeed, the packages that cannot be loaded are installed in:
>  /opt/ActiveTcl-8.5/lib/teapot/package/tcl/teapot/tcl8/8.4/

Ah. Tcl Modules (TM, see TIP 189, http://tip.tcl.tk/189). Yes, I think that
explains it. The code for the 'safe base' was likely not updated to handle
searching for TMs... It may also be that the package unknown handler doing
the search for TMs is not installed in safe interpreters. I would have to
check the init.tcl file doing that part of the setup.


>  Also, I cannot find any pkgIndex.tcl containing a reference to the
>  non-safely-requirable packages throughout the activetcl installation.

That is correct. Tcl Modules do not have an associated pkgIndex.tcl file.
Their 'ifneeded' command and script are constructed from their path and
filename, which encode package name and version.


> 
>  Questions are:
>  - why is the master interp able to require these packages ?

See above.

>  - is the problem due to ActiveState architecture?
>  Or to the ::safe:: mechanism?

I would say the ::safe system, not being updated for TMs.

>  - how can I work arround these problem so that I can load ?

This will have to be fixed in Tcl itself.

>  - or does it mean that none of the packages in tcllib are supposed to be
>  loaded in a safe interpreter ?

No.

>  PS :
> 
>  I've found also a problem with safe-loading of the package math.

>  This time, the safe interp is able to locate the package, but
>  cannot load it.
>  I've reported the issue on the tcllib bugtracker :
> 
https://sourceforge.net/tracker/?func=detail&atid=112883&aid=1998628&group_i
d=12883

This seems to be an issue with the package itself, using a command which is
forbidden in the safe base (pwd). Whether it should contain that command is
something we have to ask the author ... Ok, I looked at the code, and this
is a package using old-style auto-loading to lazily load its parts on
demand. for that it needs the 'pwd' and 'file' commands, both of which are
forbidden in the safe base by default. To load such a package the safe base
has to be reconfigured by your application so that the commands are
available, in some restricted form. Or the package has to be rewritten to
not do this old-style auto-loading.

> I mention this here in case it would also concern ActiveState. In this
> case, I can post a bug report, if needed !


--
	Andreas Kupries <andreask@[...].com> 
	Developer @ http://www.ActiveState.com
	Tel: +1 778-786-1122


_______________________________________________
ActiveTcl mailing list
ActiveTcl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Nicolas Castagne
Andreas Kupries
Nicolas Castagne
Andreas Kupries

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved