This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Oren Milman
Recipients Oren Milman, serhiy.storchaka
Date 2017-03-18.09:56:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489830992.7.0.11223013414.issue29843@psf.upfronthosting.co.za>
In-reply-to
Content
With regard to ctypes.Array:

currently:
>>> from ctypes import *
>>> class T(Array):
...     _type_ = c_int
...     _length_ = -1
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: array too large
>>> class T(Array):
...     _type_ = c_int
...     _length_ = -1 << 1000
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: The '_length_' attribute is too large


Obviously, here the _length_ attribute is too small, not too large.
Thus, the error messages should be changed to be more accurate (optimally, for
any negative _length_, the error message should be the same).

Moreover, in accordance with #29833 (this is a sub-issue of #29833), ValueError
should be raised for any negative _length_ attribute (instead of
OverflowError).


Also, Note that currently, in case _length_ == 0, no error is raised. ISTM that
a ctypes Array of length 0 is useless, so maybe we should raise a ValueError in
this case too?
History
Date User Action Args
2017-03-18 09:56:32Oren Milmansetrecipients: + Oren Milman, serhiy.storchaka
2017-03-18 09:56:32Oren Milmansetmessageid: <1489830992.7.0.11223013414.issue29843@psf.upfronthosting.co.za>
2017-03-18 09:56:32Oren Milmanlinkissue29843 messages
2017-03-18 09:56:32Oren Milmancreate