This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年03月05日 00:15 by Simon.Chopin, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg154916 - (view) | Author: Simon Chopin (Simon.Chopin) | Date: 2012年03月05日 00:15 | |
This issue occurred at least in Python 2.7, I haven't checked in other versions.
When stepping on a return statement, pdb calls the return value __str__() method to display it at the end of the line. Only, it doesn't handle the potential exceptions raised within those functions.
An exemple would be:
import pdb
class A(object):
def __new__(cls):
pdb.set_trace()
return super(A, cls).__new__()
def __init__(self):
self.value = "Foo"
def __str__(self):
return self.value
pdb.run("A()")
When using the step by step, pdb will be interrupted by an unhandled AttributeError.
|
|||
| msg175294 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2012年11月10日 20:25 | |
I cannot reproduce the problem on python 2.7. The example runs without problem after fixing the example with the following changes: remove the call to pdb.set_trace(), the debugger is already started with a call to pdb.run() add the missing 'cls' parameter in the call to __new__() in: return super(A, cls).__new__() |
|||
| msg266260 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年05月24日 18:54 | |
Georg, if you agree that Xavier's analysis is correct, we can close this as not a bug. |
|||
| msg355634 - (view) | Author: Batuhan Taskaya (BTaskaya) * (Python committer) | Date: 2019年10月29日 09:34 | |
Can't reproducible in py3 (3.8), IMHO can be closed. |
|||
| msg355665 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2019年10月29日 18:12 | |
Batuhan, thanks for the nudge. For the record ... If __new__ were a normal instance method, then 'some_class.__new__()' would be a correct call, as 'some_class' would be passed to '__new__' as its first and perhaps only argument. But " __new__() is a static method (special-cased so you need not declare it as such)". https://docs.python.org/3/reference/datamodel.html#object.__new__ Its special-casing makes it easy to forget that its first argument, a class, must be passed explicitly. Hence Xavier's comment. In current 2.7.17 and 3.8 (for instance), with pdb left out of the picture, the missing cls argument results in TypeError: object.__new__(): not enough arguments When I pdb.run('A()') new and step, it catches the error and refuses to advance. > <pyshell#10>(3)__new__() (Pdb) s TypeError: object.__new__(): not enough arguments > <pyshell#10>(3)__new__() |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:27 | admin | set | github: 58404 |
| 2019年10月29日 18:12:48 | terry.reedy | set | status: open -> closed type: behavior messages: + msg355665 resolution: not a bug stage: resolved |
| 2019年10月29日 09:34:31 | BTaskaya | set | nosy:
+ BTaskaya messages: + msg355634 |
| 2016年05月24日 18:54:52 | terry.reedy | set | nosy:
+ georg.brandl, terry.reedy messages: + msg266260 |
| 2012年11月10日 20:25:05 | xdegaye | set | nosy:
+ xdegaye messages: + msg175294 |
| 2012年03月06日 10:11:29 | tshepang | set | nosy:
+ tshepang |
| 2012年03月05日 00:15:16 | Simon.Chopin | create | |