Skip to content

Unnecessary PyFrozenSet_Check calls in ast_opt.c? #111133

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eclips4 opened this issue Oct 20, 2023 · 4 comments
Closed

Unnecessary PyFrozenSet_Check calls in ast_opt.c? #111133

Eclips4 opened this issue Oct 20, 2023 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@Eclips4
Copy link
Member

Eclips4 commented Oct 20, 2023

This code looks strange:

cpython/Python/ast_opt.c

Lines 177 to 178 in 37e4e20

else if (PyLong_Check(v) && (PyTuple_Check(w) || PyFrozenSet_Check(w))) {
Py_ssize_t size = PyTuple_Check(w) ? PyTuple_GET_SIZE(w) :

Function above intended as safe mutiply, but set (and frozenset) doesn't have tp_as_number->nb_multiply field, so it cannot be used with * operator.

Linked PRs

@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 20, 2023
@Eclips4
Copy link
Member Author

Eclips4 commented Oct 20, 2023

cc @serhiy-storchaka

@serhiy-storchaka
Copy link
Member

You are right.

@Eclips4
Copy link
Member Author

Eclips4 commented Oct 20, 2023

You are right.

I'll send a PR ;)

Eclips4 added a commit to Eclips4/cpython that referenced this issue Oct 20, 2023
serhiy-storchaka pushed a commit that referenced this issue Oct 20, 2023
@Eclips4 Eclips4 closed this as completed Oct 20, 2023
@serhiy-storchaka
Copy link
Member

Thank you Kirill.

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…t folding (pythonGH-111137)

frozenset does not support multiplication.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…t folding (pythonGH-111137)

frozenset does not support multiplication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants