[issue6719] pdb messes up when debugging an non-ascii program

samuel de framond report at bugs.python.org
Mon Aug 17 18:50:11 CEST 2009


New submission from samuel de framond <samuel43 at laposte.net>:

consider a program like this one:

---- File: ./test.py ----
#/usr/bin/env python
#coding: utf8

print 'qwerty'
-------------------------

Here is a shell (e.g. bash) session:

$ python -m pdb ./test.py
--Return--
> /usr/lib/python2.6/encodings/__init__.py(69)normalize_encoding()->'latin1'
-> return '_'.join(encoding.translate(_norm_encoding_map).split())
(Pdb) 

While for a file without the line #2, the output would be:

$ python -m pdb ./test.py
> /home/.../test.py(3)<module>()
-> print 'qwerty'
(Pdb) 

Here is the thing: the normal behaviour of pdb in this case is to pause
before executing the first line of the program. Instead of this, it
pauses at line #69 in .../encodings/__init__.py, which makes pdb almost
unusable.
Plus, pdb's inline command "q" (or "quit") does not work anymore. Here,
the first line should close the program but it does not:

(Pdb) q
Traceback (most recent call last):
  File "/usr/lib/python2.6/pdb.py", line 1283, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python2.6/pdb.py", line 1202, in _runscript
    self.run(statement)
  File "/usr/lib/python2.6/bdb.py", line 368, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "./test.py", line 2
 SyntaxError: encoding problem: with BOM (test.py, line 2)
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> <string>(1)<module>()
(Pdb) 

if 'q' is types a second time in a row, it goes like this and we are
back to starting point:

(Pdb) q
Post mortem debugger finished. The ./test.py will be restarted
--Return--
> /usr/lib/python2.6/encodings/__init__.py(69)normalize_encoding()->'latin1'
-> return '_'.join(encoding.translate(_norm_encoding_map).split())
(Pdb)

----------
components: Library (Lib)
messages: 91667
nosy: smu
severity: normal
status: open
title: pdb messes up when debugging an non-ascii program
type: behavior
versions: Python 2.6

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


More information about the Python-bugs-list mailing list