MCPcopy Index your code
hub / github.com/Nuitka/Nuitka / getLocalVariableReferenceErrorCode

Function getLocalVariableReferenceErrorCode

nuitka/code_generation/ErrorCodes.py:216–254  ·  view source on GitHub ↗
(variable, condition, emit, context)

Source from the content-addressed store, hash-verified

214
215
216def getLocalVariableReferenceErrorCode(variable, condition, emit, context):
217 variable_name = variable.getName()
218
219 (
220 exception_state_name,
221 _exception_lineno,
222 ) = context.variable_storage.getExceptionVariableDescriptions()
223
224 if variable.getOwner() is not context.getOwner():
225 helper_code = "FORMAT_UNBOUND_CLOSURE_ERROR"
226 else:
227 helper_code = "FORMAT_UNBOUND_LOCAL_ERROR"
228
229 set_exception = [
230 "%s(tstate, &%s, %s);"
231 % (
232 helper_code,
233 exception_state_name,
234 context.getConstantCode(variable_name),
235 ),
236 ]
237
238 # TODO: Move this into the helper code.
239 if python_version >= 0x300:
240 set_exception.extend(_getExceptionChainingCode(context))
241
242 emit(
243 template_error_format_string_exception
244 % {
245 "condition": condition,
246 "exception_exit": context.getExceptionEscape(),
247 "set_exception": indented(set_exception),
248 "release_temps": indented(getErrorExitReleaseCode(context)),
249 "var_description_code": indented(
250 getFrameVariableTypeDescriptionCode(context)
251 ),
252 "line_number_code": indented(getErrorLineNumberUpdateCode(context)),
253 }
254 )
255
256
257# TODO: Get rid of this function entirely.

Callers 2

_getVariableDelCodeFunction · 0.85

Calls 11

indentedFunction · 0.85
getErrorExitReleaseCodeFunction · 0.85
emitFunction · 0.50
getNameMethod · 0.45
getOwnerMethod · 0.45
getConstantCodeMethod · 0.45
getExceptionEscapeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…