FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-149171: Make TypeAliasType __module__ writable by ericmarkmartin · Pull Request #149172 · python/cpython · GitHub

/ cpython Public

gh-149171: Make TypeAliasType __module__ writable - #149172

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
ericmarkmartin:typealiastype-writable-module
May 2, 2026
Merged

gh-149171: Make TypeAliasType __module__ writable#149172
JelleZijlstra merged 1 commit into
python:mainfrom
ericmarkmartin:typealiastype-writable-module

Conversation

ericmarkmartin commented Apr 30, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You should update the TypeAlias docs (both rST and the one at L2193).

Comment thread Objects/typevarobject.c Outdated
Comment on lines +2005 to +2007
PyObject *old_module = ta->module;
Py_XDECREF(old_module);
ta->module = Py_XNewRef(value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Use Py_XSETREF instead. More generally, making it writable looks like we may introduce races on the free-threaded build so I think the getter/setter will need a critical section. I however don't know whether this should be considered an atomic change or not.

read-the-docs-community Bot commented Apr 30, 2026
edited
Loading

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32505063 | 📁 Comparing aa41fd5 against main (5110738)

  🔍 Preview build  

15 files changed · ± 15 modified

± Modified

Comment thread Objects/typevarobject.c Outdated
{
typealiasobject *ta = typealiasobject_CAST(self);
Py_BEGIN_CRITICAL_SECTION(self);
Py_XSETREF(ta->module, Py_XNewRef(value));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Minor but we could move the DECREF on the old value outside the critical section. This could theoretically cause issues if the old value has a very expensive destructor.

ericmarkmartin force-pushed the typealiastype-writable-module branch from c506040 to eaff263 Compare May 1, 2026 04:16

python-cla-bot Bot commented May 1, 2026
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

ericmarkmartin force-pushed the typealiastype-writable-module branch from c0eeb1f to aa41fd5 Compare May 1, 2026 23:50

Copy link
Copy Markdown
Member

CI failures appear to be due to the Canonical outage. I hope to get this in before the beta though.

JelleZijlstra enabled auto-merge (squash) May 2, 2026 17:08
JelleZijlstra merged commit a65611e into python:main May 2, 2026
94 of 104 checks passed
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Aug 18, 2026
…0852

https://build.opensuse.org/request/show/1370852
by user dgarcia + anag_factory
- Drop not needed patch py314-fix-tests.patch
- Add upstream patch
  remove-obsolete-literal-deduplication-assertion.patch
  (gh#python/typing_extensions#785, bsc#1274786)
- Update to 4.16.0:
  * Avoid a DeprecationWarning when deprecated is applied to a
    coroutine function on Python 3.14.0.
  * Make `typing_extensions.TypeAliasType`'s `__module__` attribute
    writable.  Backport of CPython PR [#149172](python/cpython#149172).
  * Fix setting of `__required_keys__` and `__optional_keys__` when
    inheriting keys with the same name.
  * Add support for `AsyncIterator`, `io.Reader`, `io.Writer` and
    `os.PathLike` protocols as bases for other protocols.
  * Fix incorrect behaviour on Python 3.9 and Python 3.10 that meant
    that calling `isinstance` with
    `
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make TypeAliasType __module__ attribute writable

4 participants


Back | FazBrowse Home | New Git URL