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 <rep...@bugs.python.org>
<http://bugs.python.org/issue28140>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to