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 mark.dickinson
Recipients gphemsley, mark.dickinson, rhettinger
Date 2017-12-31.20:23:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514751812.75.0.467229070634.issue32466@psf.upfronthosting.co.za>
In-reply-to
Content
Here's a concrete example, using gmpy2 [1], that exercises the code path you're proposing to remove. I had to cheat a bit, since the gmpy2 types *don't* (currently) buy in to the numbers ABC tower (though there's no good reason that they couldn't do so), so I registered them manually.

>>> import fractions, numbers
>>> import gmpy2
>>> x = gmpy2.mpq(2, 3)
>>> numbers.Rational.register(type(x))
<class 'mpq'>
>>> numbers.Integral.register(type(x.denominator))
<class 'mpz'>
>>> fractions.Fraction(x, x)  # code path exercised here ...
Fraction(1, 1)

Note that the numerator and the denominator of the resulting `Fraction` object are still of type `mpz`.

It _would_ be possible to remove the check and always use `math.gcd`, but it would result in a behaviour change: for the above code, we'd get a `Fraction` whose numerator and denominator were both of actual type `int` instead of `mpz`. Whether that's a desirable behaviour change or not is another question ...

[1] https://gmpy2.readthedocs.io/en/latest/
History
Date User Action Args
2017-12-31 20:23:32mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, gphemsley
2017-12-31 20:23:32mark.dickinsonsetmessageid: <1514751812.75.0.467229070634.issue32466@psf.upfronthosting.co.za>
2017-12-31 20:23:32mark.dickinsonlinkissue32466 messages
2017-12-31 20:23:32mark.dickinsoncreate