JelleZijlstra · GitHub

Merged

Merged

Conversation

…defined module

@JelleZijlstra

Closed

@JelleZijlstra

@JelleZijlstra

@JelleZijlstra JelleZijlstra changed the title gh-130907: Error when accessing __annotations__ on a partially defined module gh-130907: Treat all module-level annotations as conditional

Apr 9, 2025

@JelleZijlstra

JelleZijlstra

self.assertNotIn('__annotate__', gns)

gns.update(lns) # __annotate__ looks at globals
self.assertEqual(lns["__annotate__"](annotationlib.Format.VALUE), {'x': int})

iritkatriel

int _PyInstructionSequence_InsertInstruction(_PyInstructionSequence *seq, int pos,
int opcode, int oparg, _Py_SourceLocation loc);
int _PyInstructionSequence_PrependSequence(_PyInstructionSequence *seq, int pos,
_PyInstructionSequence *nested);
}

instr_sequence *old_instr_seq = INSTR_SEQUENCE(c);
instr_sequence *nested_instr_seq = NULL;

@AlexWaygood

Closed

iritkatriel

if (nested_instr_seq == NULL) {
bool need_separate_block = scope_type == COMPILE_SCOPE_MODULE;
if (need_separate_block) {
if (_PyCompile_StartAnnotationSetup(c) == ERROR) {

iritkatriel

@JelleZijlstra

@JelleZijlstra

Closed

Labels

None yet

Read the original on github.com ↗