Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix potential memory leak when a reference cycle exists between an instance
of :class:`typing.TypeAliasType`, :class:`typing.TypeVar`,
:class:`typing.ParamSpec`, or :class:`typing.TypeVarTuple` and its
``__name__`` attribute. Patch by Mikhail Efimov.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Installing with ``py install 3[.x]-dev`` will now select final versions as
well as prereleases.
16 changes: 12 additions & 4 deletions Objects/typevarobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ typevar_dealloc(PyObject *self)

_PyObject_GC_UNTRACK(self);

Py_DECREF(tv->name);
Py_XDECREF(tv->name);
Py_XDECREF(tv->bound);
Py_XDECREF(tv->evaluate_bound);
Py_XDECREF(tv->constraints);
Expand All @@ -491,6 +491,7 @@ typevar_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
typevarobject *tv = typevarobject_CAST(self);
Py_VISIT(tv->name);
Py_VISIT(tv->bound);
Py_VISIT(tv->evaluate_bound);
Py_VISIT(tv->constraints);
Expand All @@ -505,6 +506,7 @@ static int
typevar_clear(PyObject *op)
{
typevarobject *self = typevarobject_CAST(op);
Py_CLEAR(self->name);
Py_CLEAR(self->bound);
Py_CLEAR(self->evaluate_bound);
Py_CLEAR(self->constraints);
Expand Down Expand Up @@ -1171,7 +1173,7 @@ paramspec_dealloc(PyObject *self)

_PyObject_GC_UNTRACK(self);

Py_DECREF(ps->name);
Py_XDECREF(ps->name);
Py_XDECREF(ps->bound);
Py_XDECREF(ps->default_value);
Py_XDECREF(ps->evaluate_default);
Expand All @@ -1187,6 +1189,7 @@ paramspec_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
paramspecobject *ps = paramspecobject_CAST(self);
Py_VISIT(ps->name);
Py_VISIT(ps->bound);
Py_VISIT(ps->default_value);
Py_VISIT(ps->evaluate_default);
Expand All @@ -1198,6 +1201,7 @@ static int
paramspec_clear(PyObject *op)
{
paramspecobject *self = paramspecobject_CAST(op);
Py_CLEAR(self->name);
Py_CLEAR(self->bound);
Py_CLEAR(self->default_value);
Py_CLEAR(self->evaluate_default);
Expand Down Expand Up @@ -1519,7 +1523,7 @@ typevartuple_dealloc(PyObject *self)
_PyObject_GC_UNTRACK(self);
typevartupleobject *tvt = typevartupleobject_CAST(self);

Py_DECREF(tvt->name);
Py_XDECREF(tvt->name);
Py_XDECREF(tvt->default_value);
Py_XDECREF(tvt->evaluate_default);
PyObject_ClearManagedDict(self);
Expand Down Expand Up @@ -1683,6 +1687,7 @@ typevartuple_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
typevartupleobject *tvt = typevartupleobject_CAST(self);
Py_VISIT(tvt->name);
Py_VISIT(tvt->default_value);
Py_VISIT(tvt->evaluate_default);
PyObject_VisitManagedDict(self, visit, arg);
Expand All @@ -1693,6 +1698,7 @@ static int
typevartuple_clear(PyObject *self)
{
typevartupleobject *tvt = typevartupleobject_CAST(self);
Py_CLEAR(tvt->name);
Py_CLEAR(tvt->default_value);
Py_CLEAR(tvt->evaluate_default);
PyObject_ClearManagedDict(self);
Expand Down Expand Up @@ -1851,7 +1857,7 @@ typealias_dealloc(PyObject *self)
PyTypeObject *tp = Py_TYPE(self);
_PyObject_GC_UNTRACK(self);
typealiasobject *ta = typealiasobject_CAST(self);
Py_DECREF(ta->name);
Py_XDECREF(ta->name);
Py_XDECREF(ta->type_params);
Py_XDECREF(ta->compute_value);
Py_XDECREF(ta->value);
Expand Down Expand Up @@ -2032,6 +2038,7 @@ static int
typealias_traverse(PyObject *op, visitproc visit, void *arg)
{
typealiasobject *self = typealiasobject_CAST(op);
Py_VISIT(self->name);
Py_VISIT(self->type_params);
Py_VISIT(self->compute_value);
Py_VISIT(self->value);
Expand All @@ -2043,6 +2050,7 @@ static int
typealias_clear(PyObject *op)
{
typealiasobject *self = typealiasobject_CAST(op);
Py_CLEAR(self->name);
Py_CLEAR(self->type_params);
Py_CLEAR(self->compute_value);
Py_CLEAR(self->value);
Expand Down
22 changes: 12 additions & 10 deletions PC/layout/support/pymanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False):

# Tag used in runtime ID (for side-by-side install/updates)
ID_TAG = XY_ARCH_TAG
# Tag shown in 'py list' output
# Tag shown in 'py list' output.
# gh-139810: We only include '-dev' here for prereleases, even though it
# works for final releases too.
DISPLAY_TAG = f"{XY_TAG}-dev{TAG_ARCH}" if VER_SUFFIX else XY_ARCH_TAG
# Tag used for PEP 514 registration
SYS_WINVER = XY_TAG + (TAG_ARCH if TAG_ARCH != '-64' else '')
Expand All @@ -102,9 +104,10 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False):
FULL_ARCH_TAG,
XY_ARCH_TAG,
X_ARCH_TAG,
# X_TAG and XY_TAG doesn't include VER_SUFFIX, so create -dev versions
f"{XY_TAG}-dev{TAG_ARCH}" if XY_TAG and VER_SUFFIX else "",
f"{X_TAG}-dev{TAG_ARCH}" if X_TAG and VER_SUFFIX else "",
# gh-139810: The -dev tags are always included so that the latest
# release is chosen, no matter whether it's prerelease or final.
f"{XY_TAG}-dev{TAG_ARCH}" if XY_TAG else "",
f"{X_TAG}-dev{TAG_ARCH}" if X_TAG else "",
]

# Generate run-for entries for each target.
Expand All @@ -115,16 +118,15 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False):
]:
if not base["target"]:
continue
STD_RUN_FOR.append({**base, "tag": FULL_ARCH_TAG})
STD_RUN_FOR.extend([
{**base, "tag": FULL_ARCH_TAG},
{**base, "tag": f"{XY_TAG}-dev{TAG_ARCH}" if XY_TAG else ""},
{**base, "tag": f"{X_TAG}-dev{TAG_ARCH}" if X_TAG else ""},
])
if XY_TAG:
STD_RUN_FOR.append({**base, "tag": XY_ARCH_TAG})
if X_TAG:
STD_RUN_FOR.append({**base, "tag": X_ARCH_TAG})
if VER_SUFFIX:
STD_RUN_FOR.extend([
{**base, "tag": f"{XY_TAG}-dev{TAG_ARCH}" if XY_TAG else ""},
{**base, "tag": f"{X_TAG}-dev{TAG_ARCH}" if X_TAG else ""},
])

# Generate alias entries for each target. We need both arch and non-arch
# versions as well as windowed/non-windowed versions to make sure that all
Expand Down
Loading