mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-130907: Treat all module-level annotations as conditional (#131550)
This commit is contained in:
parent
5bf0f3666e
commit
922049b613
21 changed files with 221 additions and 53 deletions
|
@ -154,6 +154,15 @@ _PyInstructionSequence_InsertInstruction(instr_sequence *seq, int pos,
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
_PyInstructionSequence_SetAnnotationsCode(instr_sequence *seq,
|
||||
instr_sequence *annotations)
|
||||
{
|
||||
assert(seq->s_annotations_code == NULL);
|
||||
seq->s_annotations_code = annotations;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
_PyInstructionSequence_AddNested(instr_sequence *seq, instr_sequence *nested)
|
||||
{
|
||||
|
@ -178,6 +187,12 @@ PyInstructionSequence_Fini(instr_sequence *seq) {
|
|||
|
||||
PyMem_Free(seq->s_instrs);
|
||||
seq->s_instrs = NULL;
|
||||
|
||||
if (seq->s_annotations_code != NULL) {
|
||||
PyInstructionSequence_Fini(seq->s_annotations_code);
|
||||
Py_CLEAR(seq->s_annotations_code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
@ -200,6 +215,7 @@ inst_seq_create(void)
|
|||
seq->s_labelmap = NULL;
|
||||
seq->s_labelmap_size = 0;
|
||||
seq->s_nested = NULL;
|
||||
seq->s_annotations_code = NULL;
|
||||
|
||||
PyObject_GC_Track(seq);
|
||||
return seq;
|
||||
|
@ -414,6 +430,7 @@ inst_seq_traverse(PyObject *op, visitproc visit, void *arg)
|
|||
{
|
||||
_PyInstructionSequence *seq = (_PyInstructionSequence *)op;
|
||||
Py_VISIT(seq->s_nested);
|
||||
Py_VISIT((PyObject *)seq->s_annotations_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -422,6 +439,7 @@ inst_seq_clear(PyObject *op)
|
|||
{
|
||||
_PyInstructionSequence *seq = (_PyInstructionSequence *)op;
|
||||
Py_CLEAR(seq->s_nested);
|
||||
Py_CLEAR(seq->s_annotations_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue