On Thu, Jan 18, 2001 at 02:14:19AM -0800, Ka-Ping Yee wrote: > Wow!! __complex__ can produce a segfault! > >>> complex > <built-in function complex> > >>> class Foo: > ... def __complex__(self): return 3 > ... > >>> Foo() > <__main__.Foo instance at 0x81e8684> > >>> f = _ > >>> complex(f) > Segmentation fault (core dumped) > This happens because builtin_complex first retrieves and saves > the PyNumberMethods of the argument (in this case, from the > instance), then tries to call __complex__ (in this case, returning 3), > and THEN coerces the result using nbr->nb_float if the result is > not complex! (This calls the instance's nb_float method on the > integer object 3!!) I've noticed that lurking bug in the coercion code when I added augmented assignment, though I don't recall whether I fixed it then, nor do I know if that part's been "touched" by the recent coercion changes. If none of the coercion champions speak up, I'll look at this sometime this weekend. -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4