Skip to content

threading: fix ExceptHookArgs being a function instead of a type #4768

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

Merged
merged 1 commit into from
Nov 14, 2020

Conversation

bluetech
Copy link
Contributor

The previous typing meant threading.ExceptHookArgs could not be used to type a value.

The new typing follows what cpython does in the happy path (_thread exists rather than the pure-python fallback being used), a bit different than @srittau's suggestion in the issue.

Also, ExceptHookArgs is a PyStructSequence rather than an actual namedtuple, so stubtest complained about it. I changed it to tuple+properties instead. I can also add n_fields, n_sequence_fields, n_unnamed_fields properties which some other structseqs in typeshed use, but seems like obscure internal detail to me so I omitted those.

Fixes #4767.

The previous typing meant `threading.ExceptHookArgs` could not be used
to type a value.

The new typing follows what cpython does in the happy path (`_thread`
exists rather than the pure-python fallback being used).

Fixes python#4767.
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau merged commit 27a45df into python:master Nov 14, 2020
@jakebailey
Copy link
Contributor

Just saw this change, but I think the fix here changed the visibility of excepthook and ExceptHookArgs due to the clarification made in PEP 484 (#4586, python/peps#1630) to explicitly state that the from ... import X as X form just have X be the same in both places. This is something I believe we already adjusted for in pyright, but I'm not sure that it's been adopted fully in mypy.

Did this fix depend on no longer using the assignment, or was that just a cleanup on top of the other changes?

@bluetech
Copy link
Contributor Author

bluetech commented Dec 1, 2020 via email

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 1, 2020

Thanks for catching, @jakebailey ... Would you mind submitting a PR to fix? (fwiw I adjusted this in mypy in python/mypy#9515 although I'm not sure whether that's been released yet)

edit: looks like my comment submission raced against bluetech's, thanks for offering to fix! :-)

@jakebailey
Copy link
Contributor

Thanks for that link. I can submit a PR later if @bluetech doesn't beat me to it.

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.

threading: ExceptHookArgs funkiness
4 participants