Skip to content

Commit

Permalink
Python3.11: Compatible error message for accessing unset closure vari…
Browse files Browse the repository at this point in the history
…ables
  • Loading branch information
kayhayen committed Feb 8, 2023
1 parent 3a7d78e commit 5b71040
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nuitka/build/static_src/HelpersExceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ void FORMAT_UNBOUND_CLOSURE_ERROR(PyObject **exception_type, PyObject **exceptio
*exception_type = PyExc_NameError;
Py_INCREF(*exception_type);

*exception_value = Nuitka_String_FromFormat("free variable '%s' referenced before assignment in enclosing scope",
Nuitka_String_AsString_Unchecked(variable_name));
#if PYTHON_VERSION < 0x3b0
char const *message = "free variable '%s' referenced before assignment in enclosing scope";
#else
char const *message = "cannot access free variable '%s' where it is not associated with a value in enclosing scope";
#endif

*exception_value = Nuitka_String_FromFormat(message, Nuitka_String_AsString_Unchecked(variable_name));
CHECK_OBJECT(*exception_value);
}

Expand Down

0 comments on commit 5b71040

Please sign in to comment.