Hi Naftali, On 10 April 2014 21:05, Naftali Harris <[email protected]> wrote: > I'd like to report a compatibility issue between CPython and PyPy in the > fractions module. In short, CPython coerces Fraction objects into int's in > strings formatted with "%d", but PyPy throws a TypeError.
It seems that "%d" % x throws a TypeError on CPython, except if x is an instance of a class that defines the __int__ method (so far, reasonable, done in PyPy too)... or else, if both the __float__ and the __trunc__ methods are defined. Defining only one of them is not sufficient. Here, I say: *what?* Anybody has got a clue about this PHP-esque worth-a-CPython-bug-report misbehavior? (Obviously the class Fraction just happens to define not __int__, but both __float__ and __trunc__. It all looks like a design-by-chance...) A bientôt, Armin. _______________________________________________ pypy-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-dev
