Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9126fd

Browse files
larryhastingsmiss-islington
authored andcommitted
pythongh-97943: PyFunction_GetAnnotations should return a borrowed reference. (pythonGH-97949)
(cherry picked from commit6bfb0be)Co-authored-by: larryhastings <larry@hastings.org>
1 parent6057030 commite9126fd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Bugfix::func:`PyFunction_GetAnnotations` should return a borrowed
2+
reference. It was returning a new reference.

‎Objects/funcobject.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ func_get_annotation_dict(PyFunctionObject *op)
300300
}
301301
Py_SETREF(op->func_annotations,ann_dict);
302302
}
303-
Py_INCREF(op->func_annotations);
304303
assert(PyDict_Check(op->func_annotations));
305304
returnop->func_annotations;
306305
}
@@ -532,7 +531,11 @@ func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
532531
if (op->func_annotations==NULL)
533532
returnNULL;
534533
}
535-
returnfunc_get_annotation_dict(op);
534+
PyObject*d=func_get_annotation_dict(op);
535+
if (d) {
536+
Py_INCREF(d);
537+
}
538+
returnd;
536539
}
537540

538541
staticint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp