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

gh-85795: Add support forsuper() inNamedTuple subclasses#129352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
bswck wants to merge16 commits intopython:mainfrombswck:fix-namedtuple-classcell-bug
Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
e84d487
Add support for `super()` in `NamedTuple` subclasses
bswckJan 27, 2025
577bdc7
Rewrite the test to be more neutral
bswckJan 28, 2025
b77ea9f
Add a check that `__classcell__` isn't leaked
bswckJan 28, 2025
31f6607
Separate leakage test and mark it as CPython-only
bswckJan 28, 2025
74578e9
Shorten the test name, we know it's a namedtuple test from context
bswckJan 28, 2025
7696b87
We test for dunder class too
bswckJan 28, 2025
2f801dc
Language correctness
bswckJan 28, 2025
f8cf62f
Minor aesthetical
bswckJan 28, 2025
cc20a2d
Remove unintended attribute access
bswckJan 28, 2025
efb9ad2
Encapsulate the `_classcell` parameter
bswckJan 29, 2025
d9cdb27
Use a sentinel for missing `__classcell__`
bswckJan 29, 2025
074df4c
Convert new documentation into a `versionchanged` block
bswckJan 29, 2025
998474d
Add a comment discussing reasons for `__classcell__` manipulation
bswckJan 29, 2025
ee93519
Reformat for optimal line length
bswckJan 29, 2025
e3fc197
Add extra param `stack_offset` for fetching correct frames
bswckJan 29, 2025
c2a0c50
Use `next` version ref instead of `3.14`
bswckJan 29, 2025
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
PrevPrevious commit
NextNext commit
Reformat for optimal line length
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
@bswck@AlexWaygood
bswck andAlexWaygood committedJan 29, 2025
commitee93519bccb4914b41ab2c3b51fc3813edce693d
3 changes: 2 additions & 1 deletionLib/collections/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -360,7 +360,8 @@ def __ror__(self, other):

_nmtuple_classcell_sentinel = object()

def _namedtuple(typename, field_names, *, rename=False, defaults=None, module=None, classcell=_nmtuple_classcell_sentinel):
def _namedtuple(typename, field_names, *, rename=False, defaults=None, module=None,
classcell=_nmtuple_classcell_sentinel):
# Validate the field names. At the user's option, either generate an error
# message or automatically replace the field name with a valid name.
if isinstance(field_names, str):
Expand Down
3 changes: 2 additions & 1 deletionLib/typing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2929,7 +2929,8 @@ def __round__(self, ndigits: int = 0) -> T:
pass


def _make_nmtuple(name, fields, annotate_func, module, defaults = (), classcell=collections._nmtuple_classcell_sentinel):
def _make_nmtuple(name, fields, annotate_func, module, defaults = (),
classcell=collections._nmtuple_classcell_sentinel):
nm_tpl = collections._namedtuple(name, fields, defaults=defaults,
module=module, classcell=classcell)
nm_tpl.__annotate__ = nm_tpl.__new__.__annotate__ = annotate_func
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp