[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2021-10-19 Thread Irit Katriel
Irit Katriel added the comment: Reproduced on 3.11: >>> from _struct import Struct >>> s = Struct.__new__(Struct) >>> s.unpack_from(b'asdf') Assertion failed: (self->s_codes != NULL), function Struct_unpack_from_impl, file /Users/iritkatriel/src/cpython/Modules/_struct.c, line 1603. zsh: abor

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2019-07-14 Thread Zackery Spytz
Change by Zackery Spytz : -- nosy: +ZackerySpytz versions: +Python 2.7, Python 3.8, Python 3.9 ___ Python tracker ___ ___ Python-bug

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2019-07-14 Thread Zackery Spytz
Change by Zackery Spytz : -- keywords: +patch pull_requests: +14573 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14777 ___ Python tracker ___ __

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread Ronald Oussoren
Ronald Oussoren added the comment: @DeKrain: I agree -- components: +Extension Modules -Library (Lib) ___ Python tracker ___ ___ Py

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread DeKrain
DeKrain added the comment: I think we should leave 'Extension Modules' in components field, because implementation of struct module is really written in C. -- ___ Python tracker

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread Ronald Oussoren
Ronald Oussoren added the comment: It's not as easy as that, the SystemError in the original report is caused by invalid use of a C-API due to partial initialisation of an _struct.Struct instance. The solution is likely two-fold: 1) Ensure that __new__ fully initialises the fields in de C s

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks for confirming the seg fault. I've changed this to a crasher. Should we change the exception to RuntimeError? -- components: +Library (Lib) -Extension Modules type: behavior -> crash ___ Python tracker

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-03 Thread Ronald Oussoren
Ronald Oussoren added the comment: IMHO SystemError is the wrong exception, that exception is primarily used to signal implementation errors. BTW. I can reproduce crashes in a couple of runs of your scriptlet: Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) [Clang 6.0 (clang-600.0.5

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-09-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've tried running this code in Python 3.6: from _struct import Struct for i in range(10): L = [Struct.__new__(Struct) for j in range(1000)] for s in L: try: x = s.pack_into(bytearray()) except SystemError:

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-31 Thread Ronald Oussoren
Change by Ronald Oussoren : -- nosy: +ronaldoussoren ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread DeKrain
DeKrain added the comment: (I wrote that I'm importing from _struct just for this issue.) I've seen that tp_new of PyStructType is set to s_new in Modules/_struct.c. And that crash is most likely caused by access to uninitialized memory, so it is not guaranteed. -- __

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: _struct is a private implementation detail. You shouldn't use it. You shouldn't care where the implementation "really is" in your Python code, because it could move without warning. There are no backwards-compatibility guarantees for private modules like _s

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread DeKrain
DeKrain added the comment: Well, sometimes when i do >>> b = bytearray() >>> s.pack_into(b) application crashes (because it checks arg #1, which is not initialized). Also, I imported from _struct, because it's where implementation of Struct really is. --

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: This exception goes back to at least Python 2.6 (if not older) but I'm not convinced it is a bug. Calling __new__ alone is not guaranteed to initialise a new instance completely. The public API for creating an instance is to call the class object: s =

[issue34543] _struct.Struct: calling functions without calling __init__ results in SystemError

2018-08-29 Thread DeKrain
New submission from DeKrain : >>> from _struct import Struct >>> s = Struct.__new__(Struct) >>> s.unpack_from(b'asdf') Traceback (most recent call last): File "", line 1, in SystemError: /Objects/tupleobject.c:84: Bad argument to internal function In Modules/_struct.c: static PyObject * s_u