[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #4414 [Thandy]: ScriptWrapper should be multiplatform



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

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

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

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4414#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs