On Sun, 19 Dec 2004 17:13:30 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Alex Martelli: > > >> what? Early warning, a few microseconds ahead of the invocation of a > >> method which will cause the stub in the base class to raise an > >> exception? > > > > Exactly. Microseconds don't count, but stack levels do -- getting the > > traceback end as close as possible to the real CAUSE of the problem, > > rather than a few levels further down where the SYMPTOM appears, can > > easily shave whole minutes off debugging time. > > minutes? > > Traceback (most recent call last): > File "mymodule.py", line 9, in somefunction > someobj.bar() > ... zero or more lines ... > File "somelibrary.py", line 3, in bar > raise NotImplementedError("must implement abstract method bar") > NotImplementedError: must implement abstract method bar > > you have to look at the last line of a traceback to find the error message, > and > the offending module/method is two lines above that.
The last frame in the traceback tells you where the method which should have been overridden is defined. It does not tell you where the overridding that did not happen was. I'm not sure if you can stretch this out to minutes of debug time, but you do at least need to determine the type of the object on which the method call was made and then go to _its_ class definition to add the missing method. If the line immediately before "someobj.bar()" is "someobj = FooType()", this will surely be easy. If someobj is instantiated further away, then more digging is required. Jp -- http://mail.python.org/mailman/listinfo/python-list