Message307027
This is not a crash because IDLE does not crash. It does not even exit with a traceback. Some crash and freeze bugs have been fixed since 3.4.2.
I verified with 3.7.0a2 on Win10. The failing example can be simplified to the first two lines. Step over the import and into the Fraction call to get to fractions.Fraction.__new__, line 115
self = super(Fraction, cls).__new__(cls)
(Step 8 in the report above has the wrong code.) Step 2 gives this simplified traceback:
Traceback (most recent call last):
File "F:\Python\a\tem2.py", line 3, in <module>
U=Fraction(1)
File "C:\Programs\Python37\lib\fractions.py", line 117, in __new__
if denominator is None:
File "C:\Programs\Python37\lib\fractions.py", line 117, in __new__
if denominator is None:
File "C:\Programs\Python37\lib\bdb.py", line 86, in trace_dispatch
return self.dispatch_line(frame)
File "C:\Programs\Python37\lib\bdb.py", line 110, in dispatch_line
self.user_line(frame)
File "C:\Programs\Python37\lib\idlelib\debugger.py", line 24, in user_line
self.gui.interaction(message, frame)
AttributeError: _numerator
If I replace the line above with
new = super(Fraction, cls) # resolves to object.__new__
self = new(cls)
stepping the first works. For the new call, hitting 'step' or 'over' gives essentially the same traceback as above. Hitting 'go' runs the code to completion.
If I add 'print('xxxx') after the new call, the print call shows up in the traceback, twice, but is not executed.
If I simplify the code to
class C():
def __new__(cls):
self = object.__new__(cls)
return self
c = C()
and step into the C() code the the __new__ code, there is no problem. Hence the revised title.
If I add slots make C, as with Fraction, there is still no problem.
class C():
__slots__ = ('a',)
def __new__(cls, a):
self = object.__new__(cls)
self.a = a
return self
c = C(1)
Puzzles:
1. Why does the next line, 'if denominator...' show up in the traceback? It does not have a function call. Why is it printed twice?
2. Where does the _numerator error happen? It is only set, never accessed. Setting should work because _numerator is one of the two slots.
3. What extra feature of Fraction results in the failure.
If I leave IDLE's debugger off and invoke pdb by adding
import pdb; pbd.set_trace()
as line 2, before the Fraction call, stepping with s works on the line where Debugger failed. Until a fix is released, use this (and/or print) as a workaround for code that makes debugger croak.
I do not now know how to write a fully automated unittest for debugger. But it does not now even have a human-driven htest, and it should. |
|
Date |
User |
Action |
Args |
2017-11-26 22:36:44 | terry.reedy | set | recipients:
+ terry.reedy, Camion |
2017-11-26 22:36:44 | terry.reedy | set | messageid: <1511735804.71.0.213398074469.issue32140@psf.upfronthosting.co.za> |
2017-11-26 22:36:44 | terry.reedy | link | issue32140 messages |
2017-11-26 22:36:44 | terry.reedy | create | |
|