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.

Author Camion
Recipients Camion, terry.reedy
Date 2017-11-26.11:46:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511696773.06.0.213398074469.issue32140@psf.upfronthosting.co.za>
In-reply-to
Content
Hello all,

I have been investigating a bug with a generator, which crashed, reporting that "TypeError: 'Fraction' object is not iterable".

Then I have tried to find it with the debugger and/or to reproduce it with a simpler program, but, I have not managed to reproduce the bug in my test program and I have been stopped by the fact that the debugger crashes with another error:

I have reproduced it on version 3.4.2 ans 3.6.3, BUT NOT on version 2.7.9. So I suspect it has been introduced with version 3.

Here is how to reproduce it : 

1/ Open Idle
2/ create and save this text program (or open if you already did - or don't do anything if it's already opened X-D)

from fractions import Fraction
U=Fraction(1)

def test(x):
    for i in range(1, x.denominator):
        x*=x
        yield i, i*x

for m, n in test(U*3/5):
    print (m, n)

3/ Run/check module (F5) in Idle editors window : it works perfectly
4/ start the debugger from Idle menus
5/ activate the "source" checkbox
6/ Run/check module (F5) in Idle editors window
7/ Click 3 times on [over] to get to the "for m, n in test(U*3/5):" line
8/ Click 6 times on [step], to get to the line 116 ("for m, n in test(U*3/5):") in the fractions.py files
9/ Click a seventh time on [step] and your program will crash with the folowing error (here with 3.6.3)

Traceback (most recent call last):
  File "/raid/ArcFolder/Mes documents/Mes Textes/Mes programmes/Machin/Test_itérateur_et_fractions.py", line 12, in <module>
    for m, n in test(U*3/5):
  File "/usr/local/lib/python3.6/fractions.py", line 376, in forward
    return monomorphic_operator(a, b)
  File "/usr/local/lib/python3.6/fractions.py", line 419, in _mul
    return Fraction(a.numerator * b.numerator, a.denominator * b.denominator)
  File "/usr/local/lib/python3.6/fractions.py", line 117, in __new__
    if denominator is None:
  File "/usr/local/lib/python3.6/fractions.py", line 117, in __new__
    if denominator is None:
  File "/usr/local/lib/python3.6/bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/local/lib/python3.6/bdb.py", line 66, in dispatch_line
    self.user_line(frame)
  File "/usr/local/lib/python3.6/idlelib/debugger.py", line 24, in user_line
    self.gui.interaction(message, frame)
AttributeError: _numerator5/ Run/check module (F5) in Idle editors window

I have observed once 3.4.2 that the same operation without activating the source checkbox, lead to a full idle freeze, but I have not been able to reproduce it.
History
Date User Action Args
2017-11-26 11:46:13Camionsetrecipients: + Camion, terry.reedy
2017-11-26 11:46:13Camionsetmessageid: <1511696773.06.0.213398074469.issue32140@psf.upfronthosting.co.za>
2017-11-26 11:46:12Camionlinkissue32140 messages
2017-11-26 11:46:12Camioncreate