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.

classification
Title: excess_args asserts if args == nullptr
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, tkrasnukha
Priority: normal Keywords:

Created on 2018-08-25 06:22 by tkrasnukha, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8903 closed tkrasnukha, 2018-08-25 06:22
Messages (4)
msg324041 - (view) Author: Tatyana (tkrasnukha) * Date: 2018-08-25 06:22
Since version 3.7 PyTuple_GET_SIZE performs assert(PyTuple_Check(args)); Due to this change, object_new and object_init cannot be called with args == nullptr.

Such behavior breaks existing user's code, particularly a code generated with Swig.
msg324042 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-25 06:46
object_new and object_init should not be called with args == NULL. This looks like a bug in the user code.

Even without assert(PyTuple_Check(args)) in PyTuple_GET_SIZE it dereferences the NULL pointer if args == NULL.

Unless there is a code in CPython implementation itself which calls object_new and object_init with args == NULL this issue will be closed as not a bug.
msg324346 - (view) Author: Tatyana (tkrasnukha) * Date: 2018-08-29 19:40
So, user has to do

	PyObject *empty_args = PyTuple_New(0);
	inst = PyBaseObject_Type.tp_new(type_obj, empty_args, Py_None);
	Py_DECREF(empty_args);


when type_obj doesn't require arguments for constructing?
msg324348 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-29 20:33
The third argument of tp_new() should be a dict or NULL.
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78676
2018-08-30 05:00:32benjamin.petersonsetstatus: open -> closed
stage: resolved
2018-08-29 20:33:36serhiy.storchakasetmessages: + msg324348
2018-08-29 19:40:17tkrasnukhasetmessages: + msg324346
2018-08-25 06:46:39serhiy.storchakasetresolution: not a bug

messages: + msg324042
nosy: + serhiy.storchaka
2018-08-25 06:22:15tkrasnukhacreate