[Python-bugs-list] [ python-Bugs-423728 ] improper value of sys.argv with '-c' opt

noreply@sourceforge.net noreply@sourceforge.net
Sun, 13 May 2001 08:04:03 -0700


Bugs item #423728, was updated on 2001-05-13 08:04
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=423728&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Frederic Giacometti (giacometti)
Assigned to: Nobody/Anonymous (nobody)
Summary: improper value of sys.argv with '-c' opt

Initial Comment:

Python 2,1 gives the following result:

---
python -c "import sys; print sys.argv"
[ '-c']
---

This is uncorrect and error-prone.

The two (possible) correct answers are:
    [] # strip off the '-c' stuff
  or
    [ '-c', 'import sys; print sys.argv'] # keep the '-c' stuff

  but ['-c'] alone is definitely uncorrect, as well as it does not make sense.

The source of the problem can explicitly be traced to file Python-2.1 -main.c, line 287:
  argv[_PyOS_optind] = "-c"; 
        (cf. [ python-Bugs-422678 ] (argv is modified in Py_Main())

which modifies 'argv' as side effect; this then messes up the initialization of 'sys.argv'.

Note: This bug is another side effect of [ python-Bugs-422678 ]

FG


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=423728&group_id=5470