[Python-Dev] [bug?] UserLong.py - pow(5, UserLong(3), 26) fails
01 May 2002 19:33:51 +0100
Luke Kenneth Casson Leighton <email@example.com> writes:
> one of these - pow(int(5), UserLong(3), 26) - is failing:
What's the point of UserLong now we have 2.2?
> Script started on Wed May 1 19:06:30 2002
> highfield:/usr/local/lib/python2.2# python UserLong.py
> int 3
> long 3
> 5**int(y) 125
> 5**y rpow: (5,)
> x^y%26 (3L, 26)
> Traceback (most recent call last):
> File "UserLong.py", line 153, in ?
> print "5^y%26", pow(5, y, 26)
> TypeError: unsupported operand type(s) for pow(): 'int', 'instance', 'int'
> Script done on Wed May 1 19:06:37 2002
> now, if i read this correctly, what is happening is that in
> the [optimised] code, Objects/intobject.c, support for types
> other than int, float and long - via the macro CONVERT_TO_LONG -
> are simply not supported.
> this i believe can be demonstrated to be so because if you
> do pow(5, , 26) you get the same error except replace
> 'instance' above with 'list'.
> now, could someone with a little more knowledge than i kindly
> evaluate, if they have the time, whether:
> - _is_ this happening because i have missed out a function in
> UserLong.py that i do not know the name of?
> - _is_ this due to a bug in intobject.c's int_pow()
> - _is_ this due to a bug in the implementation of the pow()
> "spam" function?
> - other?
Are you aware of this text in section 3.3.6 of the lang ref:
Note that ternary pow() will not try calling __rpow__() (the
coercion rules would become too complicated).
so I'd say this is, if anything, a "documented limitation", though
that might something of a stretch...
The meaning of "brunch" is as yet undefined.
-- Simon Booth, ucam.chat