[issue43916] Check that new heap types cannot be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2022-01-27 Thread STINNER Victor


STINNER Victor  added the comment:

> 3.9 is still affected; we should fix those types first.

I'm against backporting the new type flag, but we can try to set explicitly 
tp_set to NULL *after* calling PyType_Ready().

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2022-01-27 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

FYI: There are only two bug-fix releases left for 3.9.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2022-01-27 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
title: Mark static types newly converted to heap types as immutable: add 
Py_TPFLAGS_DISALLOW_INSTANTIATION type flag -> Check that new heap types cannot 
be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
title: Check that new heap types cannot be created uninitialised -> Check that 
new heap types cannot be created uninitialised: add 
Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3bb09947ec4837de75532e21dd4bd25db0a1f1b7 by Victor Stinner in 
branch 'master':
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
https://github.com/python/cpython/commit/3bb09947ec4837de75532e21dd4bd25db0a1f1b7


--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24424
pull_request: https://github.com/python/cpython/pull/25733

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-29 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +24413
pull_request: https://github.com/python/cpython/pull/25722

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24412
pull_request: https://github.com/python/cpython/pull/25721

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-29 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Serhiy, would you mind reviewing the PR? bpo-43974 will clean up the changes 
introduced to setup.py.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-28 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Thanks, Serhiy.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Is it ok to skip tests if it is too hard to write them.

Tests should be decorated with @cpython_only because other Python 
implementations can have working constructors for these types. It is an 
implementation detail that these types are implemented in C and instances are 
not properly initialized by default.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> The second most important part here is also adding regression tests so this 
> doesn't happen.

I've started adding tests. I'm not sure if I need to wrap them with 
@cpython_only.

Some of the types are hidden deep inside the implementations, and I have a hard 
time fetching them. For example _functools._lru_list_elem and 
_thread._localdummy. Is it ok to leave those out?

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

For that to work, you'd have to add a flag in PyType_FromModuleAndSpec, set the 
flag if (slot->slot == Py_tp_new && slot->pfunc == NULL) in the slots for loop, 
and then reset tp_new _after_ PyType_Ready.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> Alternatively we can make PyType_FromSpec() setting tp_new to NULL if there 
> is explicit {Py_tp_new, NULL} in slots.

Yes. It's not as explicit (and self-documenting) as _PyType_DisabledNew, 
though. But it avoids expanding the C API.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Alternatively we can make PyType_FromSpec() setting tp_new to NULL if there is 
explicit {Py_tp_new, NULL} in slots.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Christian Heimes


Christian Heimes  added the comment:

LGTM

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Alternative approach:

Add _PyType_DisabledNew to Include/cpython, and add {Py_tp_new, 
_PyType_DisabledNew} slot to affected types. Diff attached.

See GH discussion:
- https://github.com/python/cpython/pull/25653#issuecomment-827383246
- https://github.com/python/cpython/pull/25653#issuecomment-827390034

--
Added file: https://bugs.python.org/file49992/disablednew.diff

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> These tests should also be added when new types are converted in the future.

We should have a checklist for static to heap type conversion. I'm pretty sure 
I've seen something like that in one of Victor's blogs. A new section in the 
Dev Guide, maybe?

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-27 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +24344
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25653

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Pablo, I've made a patch for most of these (I've left out Christian's 
> modules). I've only added a couple of tests for now. Do you want all in one 
> PR?

Yes, please. The second most important part here is also adding regression 
tests so this doesn't happen. These tests should also be added when new types 
are converted in the future.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
keywords: +patch
Added file: https://bugs.python.org/file49989/patch.diff

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Pablo, I've made a patch for most of these (I've left out Christian's modules). 
I've only added a couple of tests for now. Do you want all in one PR?

$ git diff main --stat  
 Lib/test/test_array.py | 4 
 Lib/test/test_unicodedata.py   | 4 
 Modules/_dbmmodule.c   | 1 +
 Modules/_functoolsmodule.c | 2 ++
 Modules/_gdbmmodule.c  | 1 +
 Modules/_sre.c | 5 +
 Modules/_threadmodule.c| 2 ++
 Modules/_winapi.c  | 1 +
 Modules/arraymodule.c  | 1 +
 Modules/cjkcodecs/multibytecodec.c | 1 +
 Modules/posixmodule.c  | 2 ++
 Modules/pyexpat.c  | 1 +
 Modules/unicodedata.c  | 1 +
 Modules/zlibmodule.c   | 2 ++
 14 files changed, 28 insertions(+)


I don't know why I included the sqlite3 and select types in msg391924; they are 
not affected by this issue. Somebody should double check that everything's 
covered.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Christian:
> Can I get rid of the function with "{Py_tp_new, NULL}" [...]

Unfortunately not. The workaround in 993e88cf08994f7c1e0f9f62fda4ed32634ee2ad 
does the trick though.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

You're right, that would become messy. Complementing existing test suites is a 
better approach.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

test_uninitialised_heap_types.py will need to import unrelited modules (some of 
which can be platform depending). And more modules will be added as more types 
be converted. I think it is better to add tests for different modules in 
corresponding module test files. They are pretty trivial, for example:

def test_new_tcl_obj(self):
self.assertRaises(TypeError, _tkinter.Tcl_Obj)

@requires_curses_func('panel')
def test_new_curses_panel(self):
w = curses.newwin(10, 10)
panel = curses.panel.new_panel(w)
self.assertRaises(TypeError, type(panel))

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Christian Heimes


Christian Heimes  added the comment:

I have had this workaround in _hashopenssl.c for a while. Can I get rid of the 
function with "{Py_tp_new, NULL}" or is there a more generic way to accomplish 
the same goal?

/* {Py_tp_new, NULL} doesn't block __new__ */
static PyObject *
_disabled_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyErr_Format(PyExc_TypeError,
"cannot create '%.100s' instances", _PyType_Name(type));
return NULL;
}

--
nosy: +christian.heimes

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Is it worth it adding tests for this? I'm thinking a generic version of 
msg391910 (maybe Lib/test/test_uninitialised_heap_types.py) coupled with a 
dataset.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I am marking this as a release blocker, giving that this is probably going to 
involve a big change.

--
priority: deferred blocker -> release blocker

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I afraid that changing the corresponding code in Objects/typeobject.c will 
break existing user code. For now, it is safer to patch every single type 
manually. Later we can design a general solution.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Is there any way we can fix this in Objects/typeobject.c, or do we actually 
> have to patch every single type manually?

That would be probably a bad idea since typeobject.c is supposed to be generic. 
We would be inverting the responsibility concerns to the base.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Is there any way we can fix this in Objects/typeobject.c, or do we actually 
have to patch every single type manually?

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Here's a plaintext version:

- 0b858cdd5d2021-01-04 Modules/cjkcodecs/multibytecodec.c
- _multibytecodec.MultibyteCodec

- c8a87addb1 2021-01-04 Modules/pyexpat.c
- pyexpat.xmlparser

- 75bf107c62 2021-01-02 Modules/arraymodule.c
- array.arrayiterator

- dd39123970 2020-12-29 Modules/_functoolsmodule.c
- functools.KeyWrapper
- functools._lru_list_elem

- 6104013838 2020-12-18 Modules/_threadmodule.c
- _thread.lock
- _thread._localdummy

- a6109ef68d 2020-11-20 Modules/_sre.c
- re.Pattern
- re.Match
- _sre.SRE_Scanner

- c8c4200b65 2020-10-26 Modules/unicodedata.c
- unicodedata.UCD

- 256e54acdb 2020-10-01 Modules/_sqlite
- sqlite3.Connection
- sqlite3.Cursor

- 9031bd4fa4 2020-10-01 Modules/_sqlite
- sqlite3.Row
- sqlite3.Statement

- cb6db8b6ae 2020-09-27 Modules/_sqlite
- sqlite3.Node
- sqlite3.Cache

- 52a2df135c 2020-09-08 Modules/sha256module.c
- _sha256.sha224
- _sha256.sha256

- 2aabc3200b 2020-09-06 Modules/md5module.c Modules/sha1module.c 
Modules/sha512module.c
- _md5.md5
- _sha1.sha1
- _sha512.sha384
- _sha512.sha512

- e087f7cd43 2020-08-13 Modules/_winapi.c
- winapi__overlapped.Overlapped

- c4862e333a 2020-06-17 Modules/_gdbmmodule.c
- g_dbm.dbm

- bf69a8f99f 2020-06-16 Modules/_dbmmodule.c
- _dbm.dbm

- 33f15a16d4 2019-11-05 Modules/posixmodule.c
- posix.DirEntry
- posix.ScandirIterator

- df69e75edc 2019-09-25 Modules/_hashopenssl.c
- _hashlib.HASH

- f919054e53 2019-09-14 Modules/selectmodule.c
- select.devpoll
- select.kevent
- select.poll

- 04f0bbfbed 2019-09-10 Modules/zlibmodule.c
- zlib.Compress
- zlib.Decompress

- 4f384af067 2012-10-14 Modules/_tkinter.c
- _tkinter.Tcl_Obj
- _tkinter.tktimertoken
- _tkinter.tkapp

- bc07cb883e 2012-06-14 Modules/_curses_panel.c
- _curses_panel.panel

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> Thank you for your work Erlend.

Anytime! I've updated the list now. There may still be errors, but I think it's 
pretty accurate now.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Serhiy, do you think this should be a release blocker for the beta?

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your work Erlend.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> It is incomplete.

Yes, I know. I'm working on completing it manually. Some of the static structs 
were only partially initialised (most stop at tp_members). The rest of the 
struct (including tp_new) would then be initialised to zero.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is incomplete. For example arrayiterator did have tp_new = NULL (in other 
words, PyArrayIter_Type.tp_new was not set to non-NULL value).

In 3.9:

>>> import array
>>> type(iter(array.array('I')))()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: cannot create 'arrayiterator' instances

In 3.10:

>>> import array
>>> type(iter(array.array('I')))()


--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> We need to check which static types had tp_new = NULL before they were 
> converted to heap types

I did a quick git grep. Results pasted into the list over at 
https://discuss.python.org/t/list-of-built-in-types-converted-to-heap-types/8403.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The explaining comment was added in f884b749103bad0724e2e4878cd5fe49a41bd7df.

The code itself is much older. It was originally added in 
6d6c1a35e08b95a83dbe47dbd9e6474daff00354, then
weaked in c11e192d416e2970e6a06cf06d4cf788f322c6ea and strengthen in 
29687cd2112c540a8a4d31cf3b191cf10db08412.

All types except static types which are direct descendants of object inherit 
tp_new from a base class.

We need to check which static types had tp_new = NULL before they were 
converted to heap types and set it to NULL manually after type creation.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Shreyan Avigyan


Change by Shreyan Avigyan :


--
nosy: +shreyanavigyan

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

>From Objects/typeobject.c:

/* The condition below could use some explanation.
   It appears that tp_new is not inherited for static types
   whose base class is 'object'; this seems to be a precaution
   so that old extension types don't suddenly become
   callable (object.__new__ wouldn't insure the invariants
   that the extension type's own factory function ensures).
   Heap types, of course, are under our control, so they do
   inherit tp_new; static extension types that specify some
   other built-in type as the default also
   inherit object.__new__. */
if (base != _Type ||
(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
if (type->tp_new == NULL)
type->tp_new = base->tp_new;
}

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-26 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-22 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Serhiy's comment for reference:

Static type with tp_new = NULL does not have public constructor, but heap type 
inherits constructor from base class. As result, it allows to create instances 
without proper initialization, that can lead to crash. It was fixed for few 
standard heap types in issue23815, then reintroduced, then fixed again in 
issue42694. But it should be checked for every type without constructor.

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-22 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

I'm creating this issue and marking it as a deferred blocker to make sure we 
don't forget to check this (adding tests) before the release.

Check this message from Serhiy regarding heap typed concerns:

https://bugs.python.org/msg391598

--
messages: 391634
nosy: pablogsal, serhiy.storchaka, vstinner
priority: deferred blocker
severity: normal
status: open
title: Check that new heap types cannot be created uninitialised
type: behavior
versions: Python 3.10

___
Python tracker 

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