(
to_name, variable_name, use_caching, needs_check, conversion_check, emit, context
)
| 96 | |
| 97 | |
| 98 | def getModuleVariableReferenceCode( |
| 99 | to_name, variable_name, use_caching, needs_check, conversion_check, emit, context |
| 100 | ): |
| 101 | owner = context.getOwner() |
| 102 | |
| 103 | context.setModuleVariableAccessorCaching(variable_name, use_caching) |
| 104 | |
| 105 | with withObjectCodeTemporaryAssignment2( |
| 106 | to_name, "mvar_value", conversion_check, emit, context |
| 107 | ) as value_name: |
| 108 | emit( |
| 109 | "%(value_name)s = %(module_variable_accessor)s(tstate);" |
| 110 | % { |
| 111 | "value_name": value_name, |
| 112 | "module_variable_accessor": getModuleVariableAccessorCodeName( |
| 113 | context.getModuleCodeName(), variable_name |
| 114 | ), |
| 115 | } |
| 116 | ) |
| 117 | |
| 118 | if needs_check: |
| 119 | if ( |
| 120 | python_version < 0x300 |
| 121 | and not owner.isCompiledPythonModule() |
| 122 | and not owner.isExpressionClassBodyBase() |
| 123 | ): |
| 124 | error_helper_name = "RAISE_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR" |
| 125 | else: |
| 126 | error_helper_name = "RAISE_CURRENT_EXCEPTION_NAME_ERROR" |
| 127 | |
| 128 | ( |
| 129 | exception_state_name, |
| 130 | _exception_lineno, |
| 131 | ) = context.variable_storage.getExceptionVariableDescriptions() |
| 132 | |
| 133 | emit( |
| 134 | """\ |
| 135 | if (unlikely(%(value_name)s == NULL)) { |
| 136 | %(error_helper_name)s(tstate, &%(exception_state_name)s, %(var_name)s); |
| 137 | } |
| 138 | """ |
| 139 | % { |
| 140 | "value_name": value_name, |
| 141 | "error_helper_name": error_helper_name, |
| 142 | "var_name": context.getConstantCode(constant=variable_name), |
| 143 | "exception_state_name": exception_state_name, |
| 144 | } |
| 145 | ) |
| 146 | |
| 147 | getErrorExitCode( |
| 148 | check_name=value_name, |
| 149 | emit=emit, |
| 150 | context=context, |
| 151 | fetched_exception=True, |
| 152 | needs_check=needs_check, |
| 153 | ) |
| 154 | |
| 155 |
no test coverage detected
searching dependent graphs…