python / cpython

The Python programming language
https://www.python.org
Other
62.84k stars 30.09k forks source link

python -c readlink()s and stat()s \'-c\' #41554

Closed 91e326f9-79c9-4a48-942f-4d1b8fde564a closed 19 years ago

91e326f9-79c9-4a48-942f-4d1b8fde564a commented 19 years ago
BPO 1119423
Nosy @birkenfeld, @birkenfeld
Files
  • dashc.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = 'https://github.com/birkenfeld' closed_at = created_at = labels = ['interpreter-core'] title = "python -c readlink()s and stat()s \\'-c\\'" updated_at = user = 'https://bugs.python.org/bpfoley' ``` bugs.python.org fields: ```python activity = actor = 'georg.brandl' assignee = 'georg.brandl' closed = True closed_date = None closer = None components = ['Interpreter Core'] creation = creator = 'bpfoley' dependencies = [] files = ['6489'] hgrepos = [] issue_num = 1119423 keywords = ['patch'] message_count = 2.0 messages = ['47737', '47738'] nosy_count = 3.0 nosy_names = ['georg.brandl', 'georg.brandl', 'bpfoley'] pr_nums = [] priority = 'normal' resolution = 'accepted' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1119423' versions = ['Python 2.4'] ```

    91e326f9-79c9-4a48-942f-4d1b8fde564a commented 19 years ago

    Due to the way input arguments are processed by Py_Main when Python is invoked with the -c switch, PySys_SetArgv treats '-c' as the name of the python executable and tries to get an absolute path for it before adding it to sys.argv.

    This is mostly harmless, but is doing work that shouldn't be done: on UNIX it involves calling readlink() and realpath().

    The patch avoids the lookup if argv0 is '-c'.

    birkenfeld commented 19 years ago

    Logged In: YES user_id=1188172

    Thanks for the patch, committed in Python/sysmodule.c r2.129, r2.126.2.3.