[New-bugs-announce] [issue23035] -c: Line causing exception not shown for exceptions other than SyntaxErrors

Arfrever Frehtes Taifersar Arahesis report at bugs.python.org
Fri Dec 12 02:44:07 CET 2014


New submission from Arfrever Frehtes Taifersar Arahesis:

When 'python -c ${command}' is used and exception other than SyntaxError occurs, then line causing exception is not shown.

Problem seen in output of last 2 commands below:

$ cat /tmp/test1
1 /
$ cat /tmp/test2
1 / 0
$ cat /tmp/test3
a
$ python3.5 /tmp/test1
  File "/tmp/test1", line 1
    1 /
      ^
SyntaxError: invalid syntax
$ python3.5 /tmp/test2
Traceback (most recent call last):
  File "/tmp/test2", line 1, in <module>
    1 / 0
ZeroDivisionError: division by zero
$ python3.5 /tmp/test3
Traceback (most recent call last):
  File "/tmp/test3", line 1, in <module>
    a
NameError: name 'a' is not defined
$ python3.5 -c '1 /'
  File "<string>", line 1
    1 /
      ^
SyntaxError: invalid syntax
$ python3.5 -c '1 / 0'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ZeroDivisionError: division by zero
$ python3.5 -c 'a'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'a' is not defined

----------
components: Interpreter Core
messages: 232506
nosy: Arfrever, benjamin.peterson, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: -c: Line causing exception not shown for exceptions other than SyntaxErrors
versions: Python 3.5

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


More information about the New-bugs-announce mailing list