[tor-bugs] #4414 [Thandy]: ScriptWrapper should be multiplatform
Tor Bug Tracker & Wiki
torproject-admin at torproject.org
Wed Nov 9 19:54:54 UTC 2011
#4414: ScriptWrapper should be multiplatform
--------------------+-------------------------------------------------------
Reporter: chiiph | Owner: nickm
Type: defect | Status: needs_review
Priority: normal | Milestone:
Component: Thandy | Version:
Keywords: | Parent:
Points: | Actualpoints:
--------------------+-------------------------------------------------------
Comment(by nickm):
Replying to [comment:3 chiiph]:
> Replying to [comment:2 nickm]:
> > If the goal here is only to handle the case where the python binary is
not named "python" and in the path, why not just use sys.executable to
find out where it is?
> >
>
> If we ship Thandy with PyInstaller, we won't have a python executable.
Ah; that's a problem.
> > I don't think you should use code.InteractiveInterpreter for this at
all. The interpreter's semantics actually give you different syntax from
regular python.
> >
> > Example: the following is legal in a Python script, but not legal in
an interactive environment:
> > {{{
> > def a():
> > pass
> > def b():
> > pass
> > }}}
> > and the following is legal in a python script but not an interactive
environment:
> > {{{
> > def a():
> >
> > pass
> > }}}
> >
> > (An interactive interpreter requires a blank line at the end of a top-
level block, and requires that every blank line indicate the end of a top-
level block.)
>
> True, but I think it's better than using plain eval, and we can't use
the python executable for the reason above.
How is it better than eval? It changes our language from "Python" to "Not
really Python". Taking a quick look at the source for code.py, I see that
internally all it's really doing is calling compile() and exec().
> > Also, stuff like this should make you terrified:
> > {{{
> > + run_code.append("os.environ[\""+var+"\"] =
\""+self._env[var]+"\"\n
> > }}}
> > What if there's something in self._env that contains a quote or a
newline?
>
> Yeah, I thought about using repr() but I'm not sure if that would mess
up some part of the rest of the env.
repr() on a string always gives you a string that evaluates to that
string().
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4414#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list