New submission from Arkadiusz Wahlig <arkadiusz.wah...@gmail.com>:

If pdb is used to debug code using zipimport, it may end up displaying source 
code from wrong module. Python will execute the correct code but the source 
code lines displayed by pdb (including the "list" command) will come from an 
unrelated module.

Reason:

The pdb obtains lines of code using the linecache module. When used with 
zipimported modules, linecache requires the module's globals dict to be passed 
in along with the filename. The filename is then used as a cache key for future 
lookups.

A bug in pdb causes it to pass filename and globals from different modules when 
calling linecache thus polluting the cache with bogus data.

A patch for 2.7.2 is attached that fixes the problem.

The patch also fixes another problem:

When Bdb (Pdb parent class from bdb.py) calls linecache, it calls 
Bdb.canonic(filename) before passing the filename to it. It doesn't pass the 
module's globals though. This isn't a problem because the call is always made 
after Pdb has queried source lines for the same module (and it does pass the 
globals). However, because Pdb doesn't call Bdb.canonic() on the filename, the 
cache key is different and Bdb's call fails.

To fix this, the patch adds calls to Bdb.canonic(filename) whenever Pdb passes 
a filename to linecache.

----------
files: pdb.diff
keywords: patch
messages: 146885
nosy: yak
priority: normal
severity: normal
status: open
title: pdb shows code from wrong module
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file23601/pdb.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13328>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to