[Python-Dev] Re: [bug?] UserLong.py - pow(5, UserLong(3), 26) fails

Michael Hudson mwh@python.net
02 May 2002 14:01:17 +0100

Luke Kenneth Casson Leighton <lkcl@samba-tng.org> writes:

> class UserLong(object):
> 	...
> which i presume is the means by which new-style classes are specified
> (search google "new style python class" jumped into a tutorial:
>  couldn't find an explicit place straight away).
> i get a segmentation fault at line 1217 of Objects/typeobject.c,
> because mro - type->tp_mro - is NULL.

You can make the segfault go away by putting "int.__mro__" at the top
of the file.  mro's are lazily calculated and here we manage to go
through the code in an order that gets this wrong.  Shouldn't be too
hard to fix, but it's probably easier if you're Guido.  Unfortunately,
the situation overall is not improved:

$ ./python lkcl.py
Adding parser accelerators ...
int 3
long 3
5**int(y) 125
5**y rpow: (5,)
x^y%26 (3L, 26)
Traceback (most recent call last):
  File "lkcl.py", line 172, in ?
  File "lkcl.py", line 156, in test
    print "5^y%26", pow(5, y, 26)
TypeError: unsupported operand type(s) for pow(): 'int', 'UserLong', 'int'
[6613 refs]

I'm out of my depth in this area...


     ARTHUR:  Why are there three of you?
  LINTILLAS:  Why is there only one of you?
     ARTHUR:  Er... Could I have notice of that question?
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11