[New-bugs-announce] [issue12974] array module: deprecate '__int__' conversion support for array elements
Meador Inge
report at bugs.python.org
Wed Sep 14 02:48:15 CEST 2011
New submission from Meador Inge <meadori at gmail.com>:
When reviewing the fix for issue1172711 it was discovered that the 'array' module allows for '__int__' conversions:
>>> import array, struct
>>> a = array.array('L', [1,2,3])
>>> class T(object):
... def __init__(self, value):
... self.value = value
... def __int__(self):
... return self.value
...
>>> a = array.array('L', [1,2,3])
>>> struct.pack_into('L', a, 0, 9)
>>> a
array('L', [9, 2, 3])
>>> a[0] = T(100)
>>> a
array('L', [100, 2, 3])
As discussed in issue1172711, this behavior may not be desirable. We should look at deprecating '__int__' and adding '__index__' as was done for the struct module in issue1530559.
----------
components: Library (Lib)
messages: 144000
nosy: mark.dickinson, meadori, skrah
priority: normal
severity: normal
stage: needs patch
status: open
title: array module: deprecate '__int__' conversion support for array elements
type: behavior
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12974>
_______________________________________
More information about the New-bugs-announce
mailing list