Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhayen committed Oct 19, 2022
2 parents cb18253 + a81cea3 commit 2136bbc
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 157 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"distutils",
"Doxygen",
"dpkg",
"dunder",
"DYLD",
"dylib",
"elif",
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
nuitka (1.1.6+ds-1) unstable; urgency=medium

* New upstream hotfix release.

-- Kay Hayen <kay.hayen@gmail.com> Wed, 19 Oct 2022 18:36:12 +0200

nuitka (1.1.5+ds-1) unstable; urgency=medium

* New upstream hotfix release.
Expand Down
7 changes: 4 additions & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Build-Depends: debhelper (>= 9),
base-files (>= 11) | python-setuptools,
base-files (>= 11) | python-jinja2,
base-files (>= 11) | python-yaml,
base-files (>= 11) | python-glob2,
base-files (>= 11) | base-files (<< 9.10) | python-glob2,
scons,
python3-all-dev (>= 3.3),
python3-all-dbg (>= 3.3),
Expand All @@ -21,6 +21,7 @@ Build-Depends: debhelper (>= 9),
zlib1g-dev,
base-files (>= 11) | python-appdirs,
python3-appdirs | base-files (<< 7.2),
python3-glob2 | base-files (<< 9.10),
rst2pdf,
fontconfig,
base-files (>= 11) | python-pil | python-imaging,
Expand All @@ -44,11 +45,11 @@ Depends: gcc (>= 5.0) | g++ (>= 4.4) | clang (>= 3.0),
scons (>= 2.0.0),
python3-jinja2,
python3-appdirs | base-files (<< 7.2),
python3-glob2 | base-files (<= 9),
python3-glob2 | base-files (<< 9.10),
python3-dev,
base-files (>= 11) | python-jinja2,
base-files (>= 11) | python-yaml,
base-files (>= 11) | python-glob2,
base-files (>= 11) | base-files (<< 9.10) | python-glob2,
zlib1g-dev,
libzstd-dev | base-files (<= 9),
ccache,
Expand Down
2 changes: 1 addition & 1 deletion nuitka/Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""

version_string = """\
Nuitka V1.1.5
Nuitka V1.1.6
Copyright (C) 2022 Kay Hayen."""


Expand Down
2 changes: 2 additions & 0 deletions nuitka/build/include/nuitka/helper/import_hard.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ extern PyObject *IMPORT_HARD_CTYPES(void);
extern PyObject *IMPORT_HARD_CTYPES__MACHOLIB(void);

/* C helper for hard import of module "ctypes.wintypes" import. */
#if defined(_WIN32)
extern PyObject *IMPORT_HARD_CTYPES__WINTYPES(void);
#endif

/* C helper for hard import of module "functools" import. */
extern PyObject *IMPORT_HARD_FUNCTOOLS(void);
Expand Down
4 changes: 2 additions & 2 deletions nuitka/build/include/nuitka/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ extern PyObject *BUILTIN_LEN(PyObject *boundary);
extern PyObject *BUILTIN_ANY(PyObject *value);

// For built-in built-in super() no args and 2 user args functionality.
extern PyObject *BUILTIN_SUPER2(PyObject *type, PyObject *object);
extern PyObject *BUILTIN_SUPER0(PyObject *type, PyObject *object);
extern PyObject *BUILTIN_SUPER2(PyDictObject *module_dict, PyObject *type, PyObject *object);
extern PyObject *BUILTIN_SUPER0(PyDictObject *module_dict, PyObject *type, PyObject *object);

// For built-in built-in all() functionality.
extern PyObject *BUILTIN_ALL(PyObject *value);
Expand Down
2 changes: 2 additions & 0 deletions nuitka/build/include/nuitka/prelude.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ extern PyObject **global_constants;
#define const_str_plain_file global_constants[61]
// 'print'
#define const_str_plain_print global_constants[62]
// 'super'
#define const_str_plain_super global_constants[62]
// '__spec__'
#define const_str_plain___spec__ global_constants[63]
// '_initializing'
Expand Down
13 changes: 13 additions & 0 deletions nuitka/build/static_src/CompiledCodeHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,19 @@ int Nuitka_BuiltinModule_SetAttr(PyModuleObject *module, PyObject *name, PyObjec
}
#endif

if (found == false) {
res = PyObject_RichCompareBool(name, const_str_plain_super, Py_EQ);

if (unlikely(res == -1)) {
return -1;
}

if (res == 1) {
NUITKA_UPDATE_BUILTIN(super, value);
found = true;
}
}

return PyObject_GenericSetAttr((PyObject *)module, name, value);
}

Expand Down
39 changes: 37 additions & 2 deletions nuitka/build/static_src/CompiledFunctionType.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,34 @@ static int Nuitka_Function_set_code(struct Nuitka_FunctionObject *object, PyObje
return -1;
}

static PyObject *Nuitka_Function_get_compiled(struct Nuitka_FunctionObject *object) {
PyObject *result = Nuitka_dunder_compiled_value;
Py_INCREF(result);
return result;
}

static int Nuitka_Function_set_compiled(struct Nuitka_FunctionObject *object, PyObject *value) {
SET_CURRENT_EXCEPTION_TYPE0_STR(PyExc_RuntimeError, "__compiled__ is not writable");
return -1;
}

static PyObject *Nuitka_Function_get_compiled_constant(struct Nuitka_FunctionObject *object) {
PyObject *result = object->m_constant_return_value;

if (result == NULL) {
SET_CURRENT_EXCEPTION_TYPE0_STR(PyExc_AttributeError, "non-constant return value");

return NULL;
}
Py_INCREF(result);
return result;
}

static int Nuitka_Function_set_compiled_constant(struct Nuitka_FunctionObject *object, PyObject *value) {
SET_CURRENT_EXCEPTION_TYPE0_STR(PyExc_RuntimeError, "__compiled_constant__ is not writable");
return -1;
}

static PyObject *Nuitka_Function_get_closure(struct Nuitka_FunctionObject *object) {
if (object->m_closure_given > 0) {
PyObject *result = PyTuple_New(object->m_closure_given);
Expand Down Expand Up @@ -389,6 +417,9 @@ static PyGetSetDef Nuitka_Function_getset[] = {
#if PYTHON_VERSION >= 0x3a0
{(char *)"__builtins__", (getter)Nuitka_Function_get_builtins, (setter)Nuitka_Function_set_builtins, NULL},
#endif
{(char *)"__compiled__", (getter)Nuitka_Function_get_compiled, (setter)Nuitka_Function_set_compiled, NULL},
{(char *)"__compiled_constant__", (getter)Nuitka_Function_get_compiled_constant,
(setter)Nuitka_Function_set_compiled_constant, NULL},
{NULL}};

static PyObject *Nuitka_Function_reduce(struct Nuitka_FunctionObject *function) {
Expand Down Expand Up @@ -643,6 +674,12 @@ void _initCompiledFunctionType(void) {
}
#endif

if (strcmp(own->name, "__compiled__") == 0 || strcmp(own->name, "__compiled_constant__") == 0) {
// We have to do that differently, because we do not keep this around until
// needed, and we make it read-only
continue;
}

PRINT_FORMAT("Not found in uncompiled type: %s\n", own->name);
NUITKA_CANNOT_GET_HERE("Type problem");
}
Expand Down Expand Up @@ -786,9 +823,7 @@ struct Nuitka_FunctionObject *Nuitka_Function_New(function_impl_code c_code, PyO

if (c_code != NULL) {
result->m_c_code = c_code;
#ifndef __NUITKA_NO_ASSERT__
result->m_constant_return_value = NULL;
#endif
} else {
result->m_c_code = _Nuitka_FunctionEmptyCodeNoneImpl;
result->m_constant_return_value = Py_None;
Expand Down
137 changes: 11 additions & 126 deletions nuitka/build/static_src/HelpersBuiltin.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,150 +637,35 @@ PyObject *BUILTIN_TYPE3(PyObject *module_name, PyObject *name, PyObject *bases,

/** The "super" built-in.
*
* This uses a private structure "superobject" that we declare here too.
*
**/

typedef struct {
/* Python object folklore: */
PyObject_HEAD

PyTypeObject *type;
PyObject *obj;
PyTypeObject *obj_type;
} superobject;
NUITKA_DEFINE_BUILTIN(super);

PyObject *BUILTIN_SUPER2(PyObject *type, PyObject *object) {
PyObject *BUILTIN_SUPER2(PyDictObject *module_dict, PyObject *type, PyObject *object) {
CHECK_OBJECT(type);
CHECK_OBJECT_X(object);

if (unlikely(PyType_Check(type) == false)) {
#if PYTHON_VERSION < 0x300
SET_CURRENT_EXCEPTION_TYPE_COMPLAINT_NICE("super() argument 1 must be type, not %s", type);
#elif PYTHON_VERSION < 0x352
SET_CURRENT_EXCEPTION_TYPE_COMPLAINT_NICE("must be type, not %s", type);
#else
SET_CURRENT_EXCEPTION_TYPE_COMPLAINT_NICE("super() argument 1 must be type, not %s", type);
#endif
return NULL;
}

if (object == Py_None) {
object = NULL;
}

PyTypeObject *obj_type = NULL;

#if 0
PRINT_STRING("SUPER:");
PRINT_ITEM(type);
PRINT_ITEM(object);
PRINT_NEW_LINE();
#endif

if (object != NULL) {

if (PyType_Check(object) && PyType_IsSubtype((PyTypeObject *)object, (PyTypeObject *)type)) {
obj_type = (PyTypeObject *)object;
} else if (object != NULL && PyType_IsSubtype(Py_TYPE(object), (PyTypeObject *)type)) {
obj_type = Py_TYPE(object);
} else {
PyObject *class_attr = PyObject_GetAttr(object, const_str_plain___class__);

if (likely(class_attr != NULL && PyType_Check(class_attr) &&
(PyTypeObject *)class_attr != Py_TYPE(object) &&
PyType_IsSubtype((PyTypeObject *)class_attr, (PyTypeObject *)type))) {
PyObject *super_value = GET_STRING_DICT_VALUE(module_dict, (Nuitka_StringObject *)const_str_plain_super);

obj_type = (PyTypeObject *)class_attr;
Py_DECREF(class_attr);
} else {
Py_XDECREF(class_attr);
if (super_value == NULL) {
NUITKA_ASSIGN_BUILTIN(super);

SET_CURRENT_EXCEPTION_TYPE0_STR(PyExc_TypeError,
"super(type, obj): obj must be an instance or subtype of type");

return NULL;
}
}
super_value = NUITKA_ACCESS_BUILTIN(super);
}

superobject *result = PyObject_GC_New(superobject, &PySuper_Type);
assert(result);

result->type = (PyTypeObject *)type;
Py_INCREF(type);
result->obj = object;
Py_XINCREF(object);

result->obj_type = obj_type;
Py_XINCREF(obj_type);
PyObject *args[] = {type, object};
char const *arg_names[] = {"type", "obj"};

Nuitka_GC_Track(result);

CHECK_OBJECT(result);
assert(Py_TYPE(result) == &PySuper_Type);

return (PyObject *)result;
return CALL_BUILTIN_KW_ARGS(super_value, args, arg_names, 2);
}

PyObject *BUILTIN_SUPER0(PyObject *type, PyObject *object) {
CHECK_OBJECT(type);

superobject *result = PyObject_GC_New(superobject, &PySuper_Type);
assert(result);

PyObject *BUILTIN_SUPER0(PyDictObject *module_dict, PyObject *type, PyObject *object) {
if (object == Py_None) {
object = NULL;
}

if (unlikely(PyType_Check(type) == false)) {
PyErr_Format(PyExc_RuntimeError, "super(): __class__ is not a type (%s)", Py_TYPE(type)->tp_name);

return NULL;
}

result->type = (PyTypeObject *)type;
Py_INCREF(type);
if (object) {
result->obj = object;
Py_INCREF(object);

if (PyType_Check(object) && PyType_IsSubtype((PyTypeObject *)object, (PyTypeObject *)type)) {
result->obj_type = (PyTypeObject *)object;
Py_INCREF(object);
} else if (PyType_IsSubtype(Py_TYPE(object), (PyTypeObject *)type)) {
result->obj_type = Py_TYPE(object);
Py_INCREF(result->obj_type);
} else {
PyObject *class_attr = PyObject_GetAttr(object, const_str_plain___class__);

if (likely(class_attr != NULL && PyType_Check(class_attr) &&
(PyTypeObject *)class_attr != Py_TYPE(object))) {
result->obj_type = (PyTypeObject *)class_attr;
} else {
if (class_attr == NULL) {
CLEAR_ERROR_OCCURRED();
} else {
Py_DECREF(class_attr);
}

SET_CURRENT_EXCEPTION_TYPE0_STR(PyExc_TypeError,
"super(type, obj): obj must be an instance or subtype of type");

return NULL;
}
}
} else {
result->obj = NULL;
result->obj_type = NULL;
}

Nuitka_GC_Track(result);

CHECK_OBJECT(result);
assert(Py_TYPE(result) == &PySuper_Type);

return (PyObject *)result;
return BUILTIN_SUPER2(module_dict, type, object);
}

/** The "callable" built-in.
Expand Down
2 changes: 2 additions & 0 deletions nuitka/build/static_src/HelpersImportHard.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ PyObject *IMPORT_HARD_CTYPES__MACHOLIB(void) {
}

/* C helper for hard import of module "ctypes.wintypes" import. */
#if defined(_WIN32)
PyObject *IMPORT_HARD_CTYPES__WINTYPES(void) {
static PyObject *module_import_hard_ctypes__wintypes = NULL;

Expand All @@ -139,6 +140,7 @@ PyObject *IMPORT_HARD_CTYPES__WINTYPES(void) {

return module_import_hard_ctypes__wintypes;
}
#endif

/* C helper for hard import of module "functools" import. */
PyObject *IMPORT_HARD_FUNCTOOLS(void) {
Expand Down
3 changes: 2 additions & 1 deletion nuitka/code_generation/ClassCodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ def generateBuiltinSuperCode(to_name, expression, emit, context):
) as value_name:

emit(
"%s = BUILTIN_SUPER%d(%s, %s);"
"%s = BUILTIN_SUPER%d(moduledict_%s, %s, %s);"
% (
value_name,
2 if expression.isExpressionBuiltinSuper2() else 0,
context.getModuleCodeName(),
type_name if type_name is not None else "NULL",
object_name if object_name is not None else "NULL",
)
Expand Down
1 change: 1 addition & 0 deletions nuitka/code_generation/GlobalConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def getConstantDefaultPopulation():
"compile",
"range",
"open",
"super",
"sum",
"format",
"__import__",
Expand Down

0 comments on commit 2136bbc

Please sign in to comment.