git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python3-3.7.3: cannot run pdb


Rich Shepard wrote:

> Running python3-3.7.3 on Slackware-14.2.
> 
> I'm trying to debug a module using pdb but failing with all attempts. For
> example, using breakpoint() at the line where I want to stop the running
> module and examine each line's execution, the program runs to completion
> and shows there's a syntax error:
> 
> $ python3 geochem.py
>    File "geochem.py", line 35
>      boxchoices = ttk.Combobox(self, textvariable=med,
>               ^
> SyntaxError: invalid syntax
> 
> Importing pdb and inserting pdb.set_trace() produces the same output.
> 
> invoking pdb from the command line produces a full back trace:
> 
> $ python3 -m pdb geochem.py
> Traceback (most recent call last):
>    File "/usr/lib/python3.7/pdb.py", line 1701, in main
>      pdb._runscript(mainpyfile)
>    File "/usr/lib/python3.7/pdb.py", line 1570, in _runscript
>      self.run(statement)
>    File "/usr/lib/python3.7/bdb.py", line 585, in run
>      exec(cmd, globals, locals)
>    File "<string>", line 1, in <module>
>    File "/home/rshepard/development/openEDMS/views/geochem.py", line 35
>      boxchoices = ttk.Combobox(self, textvariable=med,
>               ^
> SyntaxError: invalid syntax
> 
> I don't understand the source of the syntax error and I'm not able to
> allow pdb to step through the code.

You need to fix all syntax errors before you can run the script, with or 
without pdb.

The syntax error you are seeing is typically caused by unclosed parentheses 
in a line preceding the one shown by the compiler, e. g.

>>> x = 2 * (3 + 4
... foo = 42
  File "<stdin>", line 2
    foo = 42
      ^
SyntaxError: invalid syntax