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
Date 2017-10-13.10:54:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507892060.42.0.213398074469.issue31779@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes an assertion failure:
    import _struct
    struct_obj = _struct.Struct.__new__(_struct.Struct)
    struct_obj.iter_unpack(b'foo')

This is because Struct_iter_unpack() (in Modules/_struct.c) assumes that
Struct.__init__() was called, and so it does `assert(self->s_codes != NULL);`.

The same happens in (almost) every method of Struct, and in s_get_format(), so
in all them, too, we would get an assertion failure in case of an uninitialized
Struct object.
The exception is __sizeof__(), which doesn't have an `assert`, and simply
crashes while trying to iterate over `self->s_codes`.


I would open a PR to fix this soon.
History
Date User Action Args
2017-10-13 10:54:20Oren Milmansetrecipients: + Oren Milman
2017-10-13 10:54:20Oren Milmansetmessageid: <1507892060.42.0.213398074469.issue31779@psf.upfronthosting.co.za>
2017-10-13 10:54:20Oren Milmanlinkissue31779 messages
2017-10-13 10:54:19Oren Milmancreate