[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 
<https://bugs.python.org/issue34543>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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.

--

___
Python tracker 
<https://bugs.python.org/issue34543>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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.

--

___
Python tracker 
<https://bugs.python.org/issue34543>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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_unpack_internal(PyStructObject *soself, const char *startfrom) {
...
PyObject *result = PyTuple_New(soself->s_len);
// soself->s_len is -1, set in Struct.__new__

--
components: Extension Modules
messages: 324330
nosy: DeKrain
priority: normal
severity: normal
status: open
title: _struct.Struct: calling functions without calling __init__ results in 
SystemError
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue34543>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com