[New-bugs-announce] [issue28140] Attempt to give better errors for shell commands typed into the REPL

Nick Coghlan report at bugs.python.org
Wed Sep 14 00:40:03 EDT 2016


New submission from Nick Coghlan:

A problem we're starting to see on distutils-sig is folks trying to type pip commands into the Python REPL rather than their system shell, and getting cryptic syntax errors back:

>>> pip install requests
  File "<stdin>", line 1
    pip install requests
              ^
SyntaxError: invalid syntax
>>> python -m pip install requests
  File "<stdin>", line 1
    python -m pip install requests
                ^
SyntaxError: invalid syntax

This may be amenable to a similar solution to the one we used to give a custom error message for "print ":

>>> print foo
  File "<stdin>", line 1
    print foo
            ^
SyntaxError: Missing parentheses in call to 'print'

That code currently checks for "print " and "exec ", so it would be a matter of adding another special case that looked for "pip install " appearing anywhere in the string that's failing to compile (it can't be limited to the start as it may be an attempt to invoke pip via "-m")

----------
messages: 276373
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Attempt to give better errors for shell commands typed into the REPL
type: enhancement
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28140>
_______________________________________


More information about the New-bugs-announce mailing list