summaryrefslogtreecommitdiffstats
path: root/Python/instruction_sequence.c
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2025-04-28 13:10:28 (GMT)
committerGitHub <noreply@github.com>2025-04-28 13:10:28 (GMT)
commit922049b613d155ade4c4a8f83452767bea003a9f (patch)
treec466659499780de432b0d77a803d3adfbe739174 /Python/instruction_sequence.c
parent5bf0f3666e272798789ff900b1071760c73b46fd (diff)
downloadcpython-922049b613d155ade4c4a8f83452767bea003a9f.zip
cpython-922049b613d155ade4c4a8f83452767bea003a9f.tar.gz
cpython-922049b613d155ade4c4a8f83452767bea003a9f.tar.bz2
gh-130907: Treat all module-level annotations as conditional (#131550)
Diffstat (limited to 'Python/instruction_sequence.c')
-rw-r--r--Python/instruction_sequence.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/instruction_sequence.c b/Python/instruction_sequence.c
index 4ca85ee..b068e4f 100644
--- a/Python/instruction_sequence.c
+++ b/Python/instruction_sequence.c
@@ -155,6 +155,15 @@ _PyInstructionSequence_InsertInstruction(instr_sequence *seq, int pos,
}
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)
{
if (seq->s_nested == NULL) {
@@ -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;
}