[pypy-issue] [issue808] Pypy throws exception when typecasting array whereas CPython doesn't

Connelly Barnes tracker at bugs.pypy.org
Mon Jul 25 20:50:55 CEST 2011


New submission from Connelly Barnes <connellybarnes at gmail.com>:

CPython can cast from any of the integer array types to float 'f' or double 'd'. 
In contrast, pypy fails with an exception:

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
>>> a=array.array('i',[1,2,3])
>>> b=array.array('d',a)
>>> b
array('d', [1.0, 2.0, 3.0])

C:\Code\stock>pypy
Python 2.7.1 (aefc70438132+, Apr 29 2011, 12:45:42)
[PyPy 1.5.0-alpha0 with MSC v.1600 32 bit] on win32
>>>> a=array.array('i',[1,2,3])
>>>> b=array.array('d',a)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: can only extend with array of same kind

After fixing the bug, the following test should run without any exceptions (as 
it does in CPython). It currently raises a TypeError in Pypy:

>>> for itype in 'bBhHiIlL':
...   a = array.array(itype, [1, 2, 3])
...   assert array.array('d',a) == array.array('d',[1,2,3])
...   assert array.array('f',a) == array.array('f',[1,2,3])
...
>>>

----------
messages: 2861
nosy: connelly, pypy-issue
priority: bug
status: unread
title: Pypy throws exception when typecasting array whereas CPython doesn't

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue808>
________________________________________


More information about the pypy-issue mailing list