-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-74185: repr() of ImportError now contains attributes name and path #136770
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
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
You need to sign the CLA. Requesting @encukou who wanted to finish this per #1011 (comment) |
Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-10-35-31.gh-issue-74185.7hPCA5.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now. I'll let @serhiy-storchaka have a look as well.
Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-10-35-31.gh-issue-74185.7hPCA5.rst
Outdated
Show resolved
Hide resolved
thanks for the review @picnixz ! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I plan to merge this around Wednesday if there are no objections.
Doc/whatsnew/3.15.rst
Outdated
* The :meth:`~object.__repr__` of :class:`ImportError` and :class:`ModuleNotFoundError` | ||
now shows "name" and "path" as ``name=<name>`` and ``path=<path>`` if they were given | ||
as keyword arguments at construction time. | ||
(Contributed by Serhiy Storchaka, Oleg Iarygin, and Yoav Nir in :gh:`74185`.) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Yoav11, there's a conflict with main
in this place. It needs to be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for ignoring this PR earlier. It did not looked important to me, and I was no longer sure about its usefulness, because path
is usually so long.
Why use PyUnicodeWriter
at first place? Does it make the code smaller/clearer? Is the performance difference too large?
@picnixz recommended PyUnicodeWriter in #136770 (comment) |
What were the problems with recreating the strings? Do you have any benchmark data? |
@serhiy-storchaka, what would be your preferred alternative to PyUnicodeWriter? As far as I know, @vstinner added it exactly for use cases like this. |
The original PR used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I'm fine with PyUnicodeWriter usage in this PR. It makes the code more verbose (than the first PR version), but the code is easy to read.
@serhiy-storchaka Please see a small benchmark test of the two alternatives here Yoav11#1 |
This PR was created during Europython 2025's sprint weekend.
This is a patch on #1011. authored by serhiy-storchaka and arhadthedev