Skip to content
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

Fix an issue trying list.index indexing in FusedNode #5896

Merged

Conversation

da-woods
Copy link
Contributor

@da-woods da-woods commented Dec 5, 2023

In some Python versions, generating the error message when .index fails to find an index leads to a compiler crash.

Fix this by not relying on type being fully set up while generating __repr__.

Fixes #5894 and #5588

In some Python versions, generating the error message when .index
fails to find an index leads to a compiler crash.

Fix this by not relying on type being fully set up while generating
__str__.

Fixes cython#5894 and cython#5588
@scoder
Copy link
Contributor

scoder commented Dec 6, 2023 via email

@da-woods
Copy link
Contributor Author

da-woods commented Dec 6, 2023

try:
cindex = env.cfunc_entries.index(self.node.entry)
except ValueError:
env.cfunc_entries.extend(new_cfunc_entries)
else:
env.cfunc_entries[cindex:cindex+1] = new_cfunc_entries

We find the index of an entry in a list. If the index isn't found then Python calls __repr__ of the entry (and thus __repr__ of the type) as part of preparing the ValueError.

It could probably be rewritten to do an in test before finding the index

@scoder
Copy link
Contributor

scoder commented Dec 6, 2023

It could probably be rewritten to do an in test before finding the index

Yes, that seems better.

@da-woods da-woods merged commit 28b64ad into cython:master Dec 8, 2023
63 checks passed
@da-woods da-woods deleted the fix-version-specific-error-message-formatting branch December 8, 2023 19:46
da-woods added a commit that referenced this pull request Dec 8, 2023
* Fix an issue trying list.index indexing in FusedNode

In some Python versions, generating the error message when .index
fails to find an index leads to a compiler crash.

Fix this by not relying on type being fully set up while generating
__str__.

Fixes #5894 and #5588

* Check "in" before indexing
da-woods added a commit that referenced this pull request Dec 8, 2023
* Fix an issue trying list.index indexing in FusedNode

In some Python versions, generating the error message when .index
fails to find an index leads to a compiler crash.

Fix this by not relying on type being fully set up while generating
__str__.

Fixes #5894 and #5588

* Check "in" before indexing
@da-woods
Copy link
Contributor Author

da-woods commented Dec 8, 2023

I backported to 0.29.x because it looked like it would be an issue there too.

0.29.x: 35247a0
3.0.x 66a6be1

@da-woods da-woods modified the milestones: 3.0.7, 0.29.37 Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler crashes while analyzing fused method with optional arguments only on Python 3.11
2 participants