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

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Wed Nov 9 19:39:21 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):

 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?


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


 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?

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4414#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list