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.19:33:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514748790.27.0.467229070634.issue32466@psf.upfronthosting.co.za>
In-reply-to
Content
> In what scenario would the numerator and denominator be numbers.Rational but not an integer or a fraction

But that's not the issue here. The issue here is having an instance of `numbers.Rational` whose numerator and denominator are not specifically of concrete type `int`: the test that (IIUC) you're proposing to remove is:

     if type(numerator) is int is type(denominator):
         [...]

Certainly I'd expect the numerator and denominator to be instances of `numbers.Integral`, but that's more general than being of exact type `int`.

The `numbers.Integral` and `numbers.Rational` ABCs are deliberately not tied to particular concrete classes. It would be perfectly possible (and reasonable) for someone to have a `MyFraction` class that behaves like a `Fraction`, and whose numerator and denominator are instances of some other concrete class `MyInteger` that behaves like an integer.

The branch in the code is necessary to support that situation, so we can't simply remove it.
History
Date User Action Args
2017-12-31 19:33:10mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, gphemsley
2017-12-31 19:33:10mark.dickinsonsetmessageid: <1514748790.27.0.467229070634.issue32466@psf.upfronthosting.co.za>
2017-12-31 19:33:10mark.dickinsonlinkissue32466 messages
2017-12-31 19:33:09mark.dickinsoncreate