[Python-bugs-list] [ python-Bugs-231560 ] pdb imports 'repr', causing name collision

nobody nobody@sourceforge.net
Sun, 04 Mar 2001 17:22:42 -0800


Bugs #231560, was updated on 2001-02-08 08:33
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=231560&group_id=5470

Category: Python Library
Group: None
Status: Closed
Priority: 5
Submitted By: Greg Ward
Assigned to: Greg Ward
Summary: pdb imports 'repr', causing name collision

Initial Comment:
It's apparently impossible to debug code that calls the
built-in function 'repr', because pdb.py imports the
repr module, resulting in a "call of non-function (type module)" traceback.

Here's my example script:
$ cat r.py
print repr(0.1)

And here's what happens when I run it through the debugger:

$ python2.0 [...]/pdb.py r.py
> /tmp/<string>(0)?()
(Pdb) c
> /tmp/<string>(1)?()
(Pdb) c
TypeError: 'call of non-...(type module)'
> /tmp/<string>(1)?()
(Pdb) c
Traceback (most recent call last):
  File "/www/python/lib/python2.0/pdb.py", line 943, in ?
    run('execfile(' + `filename` + ')')
  File "/www/python/lib/python2.0/pdb.py", line 878, in run
    Pdb().run(statement, globals, locals)
  File "/www/plat/python2.0/lib/python2.0/bdb.py", line 346, in run
    exec cmd in globals, locals
  File "<string>", line 1, in ?
  File "r.py", line 1, in ?
    print repr(0.1)
TypeError: call of non-function (type module)

Two obvious fixes: import repr "as" something else, or do "from repr import repr" instead of "import repr".  Whatever.

I've checked the CVS version, and this bug appears to be still present.


----------------------------------------------------------------------

Comment By: Greg Ward
Date: 2001-03-04 17:22

Message:
Logged In: YES 
user_id=14422

Works for me now with 2.1b1.

----------------------------------------------------------------------

Comment By: Tim Peters
Date: 2001-02-09 15:29

Message:
Marked as Fixed and assigned back to you.
Please try CVS Python again (pdb.py, rev 1.51).
I added
from repr import repr as _saferep

If this works OK for you, just change the bug to Closed, else assign back to me.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=231560&group_id=5470