(variable, condition, emit, context)
| 214 | |
| 215 | |
| 216 | def 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. |
no test coverage detected
searching dependent graphs…