Message144000
| Author |
meador.inge |
| Recipients |
mark.dickinson, meador.inge, skrah |
| Date |
2011年09月14日.00:48:14 |
| SpamBayes Score |
6.234066e-05 |
| Marked as misclassified |
No |
| Message-id |
<1315961295.78.0.425877150438.issue12974@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年09月14日 00:48:15 | meador.inge | set | recipients:
+ meador.inge, mark.dickinson, skrah |
| 2011年09月14日 00:48:15 | meador.inge | set | messageid: <1315961295.78.0.425877150438.issue12974@psf.upfronthosting.co.za> |
| 2011年09月14日 00:48:15 | meador.inge | link | issue12974 messages |
| 2011年09月14日 00:48:15 | meador.inge | create |
|