◐ Shell
clean mode source ↗

gh-96151: Use a private name for passing builtins to dataclass by hauntsaninja · Pull Request #98143 · python/cpython

There's no indication that BUILTINS is a special name. Other names that
are special to dataclass are all prefixed by an underscore.

As mentioned in the issue, we can also avoid this locals dance
altogether by using `().__class__.__base__` instead of
`BUILTINS.object`.

@blurb-it

sobolevn

@hauntsaninja

ericvsmith

@hauntsaninja

JelleZijlstra

@hauntsaninja

@hauntsaninja

JelleZijlstra

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Oct 31, 2022
… This now allows for a field named BUILTIN (pythongh-98143)

(cherry picked from commit 29f98b4)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Oct 31, 2022
… This now allows for a field named BUILTIN (pythongh-98143)

(cherry picked from commit 29f98b4)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

ericvsmith pushed a commit that referenced this pull request

Oct 31, 2022
…. This now allows for a field named BUILTIN (gh-98143) (gh-98899)

gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
(cherry picked from commit 29f98b4)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

ericvsmith pushed a commit that referenced this pull request

Oct 31, 2022
…. This now allows for a field named BUILTIN (gh-98143) (gh-98900)

gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
(cherry picked from commit 29f98b4)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

hauntsaninja added a commit to hauntsaninja/cpython that referenced this pull request

Feb 18, 2023
This commit prefixes `__dataclass` to several things in the locals dict:
- Names like _dflt_ (which cause trouble, see first test)
- Names like _type_ (not known to be able to cause trouble)
- _return_type (not known to able to cause trouble)
- _HAS_DEFAULT_FACTORY (which causes trouble, see second test)

In addition, this removes `MISSING` from the locals dict. As far as I
can tell, this wasn't needed even in the initial implementation of
dataclasses.py (and tests on that version passed with it removed).

This is basically a continuation of python#96151, where fixing this was
welcomed in python#98143 (comment)

hauntsaninja added a commit that referenced this pull request

Mar 25, 2023
…mes (#102032)

This commit prefixes `__dataclass` to several things in the locals dict:
- Names like `_dflt_` (which cause trouble, see first test)
- Names like `_type_` (not known to be able to cause trouble)
- `_return_type` (not known to able to cause trouble)
- `_HAS_DEFAULT_FACTORY` (which causes trouble, see second test)

In addition, this removes `MISSING` from the locals dict. As far as I can tell, this wasn't needed even in the initial implementation of dataclasses.py (and tests on that version passed with it removed). This makes me wary :-)

This is basically a continuation of #96151, where fixing this was welcomed in #98143 (comment)

Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request

Mar 27, 2023
…ore names (python#102032)

This commit prefixes `__dataclass` to several things in the locals dict:
- Names like `_dflt_` (which cause trouble, see first test)
- Names like `_type_` (not known to be able to cause trouble)
- `_return_type` (not known to able to cause trouble)
- `_HAS_DEFAULT_FACTORY` (which causes trouble, see second test)

In addition, this removes `MISSING` from the locals dict. As far as I can tell, this wasn't needed even in the initial implementation of dataclasses.py (and tests on that version passed with it removed). This makes me wary :-)

This is basically a continuation of python#96151, where fixing this was welcomed in python#98143 (comment)

warsaw pushed a commit to warsaw/cpython that referenced this pull request

Apr 11, 2023
…ore names (python#102032)

This commit prefixes `__dataclass` to several things in the locals dict:
- Names like `_dflt_` (which cause trouble, see first test)
- Names like `_type_` (not known to be able to cause trouble)
- `_return_type` (not known to able to cause trouble)
- `_HAS_DEFAULT_FACTORY` (which causes trouble, see second test)

In addition, this removes `MISSING` from the locals dict. As far as I can tell, this wasn't needed even in the initial implementation of dataclasses.py (and tests on that version passed with it removed). This makes me wary :-)

This is basically a continuation of python#96151, where fixing this was welcomed in python#98143 (comment)