[Python-Dev] Strange behavior in Python 2.5a0 (trunk) --- possible error in AST?

Michael Hudson mwh at python.net
Mon Mar 13 10:47:46 CET 2006


"Travis E. Oliphant" <oliphant.travis at ieee.org> writes:

> I'm seeing strange behavior in the Python 2.5a0 trunk that is causing 
> the tests for numpy to fail.  Apparently obj[...] = 1 is not calling 
> PyObject_SetItem
>
> Here is a minimal example to show the error.  Does anyone else see this?
>
> class temp(object):
>         def __setitem__(self, obj, v):
>             print obj, v
>
> mine = temp()
> mine[...] = 1

It's a compiler problem:

>>> dis.dis(compile("mine[...] = 1", '', 'single'))
  1           0 LOAD_CONST               0 (1)
              3 LOAD_NAME                0 (mine)
              6 LOAD_CONST               1 (Ellipsis)
              9 LOAD_CONST               2 (None)
             12 RETURN_VALUE        

Cheers,
mwh

-- 
6. The code definitely is not portable - it will produce incorrect 
   results if run from the surface of Mars.
               -- James Bonfield, http://www.ioccc.org/2000/rince.hint


More information about the Python-Dev mailing list