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
bpo-30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader. #1735
Conversation
Lib/importlib/_bootstrap_external.py
Outdated
def __init__(self, fullname=None, path=None, *, name=None): | ||
if name is not None: | ||
_warnings.warn("the 'name' parameter is deprecated; use " | ||
"'fullname' instead", DeprecationWarning) |
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.
You also need to use the deprecated name if it's given.
Lib/importlib/_bootstrap_external.py
Outdated
@@ -910,6 +910,7 @@ def __init__(self, fullname=None, path=None, *, name=None): | |||
if name is not None: | |||
_warnings.warn("the 'name' parameter is deprecated; use " | |||
"'fullname' instead", DeprecationWarning) | |||
self.name = name | |||
self.name = fullname |
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.
You need to put self.name = fullname
in an else:
statement, otherwise you'll always re-assign self.name
to fullname
anyway.
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.
Oops, terrible mistake it was. Fixed it.
I believe this was done during Pycon US sprint, so I applied the sprint label. |
Lib/importlib/_bootstrap_external.py
Outdated
def __init__(self, fullname=None, path=None, *, name=None): | ||
if name is not None: | ||
_warnings.warn("the 'name' parameter is deprecated; use " | ||
"'fullname' instead", DeprecationWarning) |
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.
You need to pass stacklevel=2
in order to make DeprecationWarning
more useful.
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.
Also, please add a test case for DeprecationWarning
.
Misc/NEWS
Outdated
@@ -338,6 +338,8 @@ Extension Modules | |||
|
|||
Library | |||
------- | |||
- bpo-30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader. Patch |
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.
We don't edit Misc/NEWS
manually anymore. Please use blurb to create a NEWS entry: https://github.com/python/core-workflow/tree/master/blurb
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.
Okay, I will looking in blurb and update the PR accordingly
The side effect of this change is that it makes both arguments optional, with default to None. I have doubts that this is an intentional change.
The only correct calls are:
ExtensionFileLoader(thename, thepath)
ExtensionFileLoader(thename, path=thepath)
ExtensionFileLoader(fullname=thename, path=thepath)
ExtensionFileLoader(name=thename, path=thepath) # deprecated
Passing both fullname
and name
should be an error.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@sayanchowdhury do you plan to address the review comments or should I close it? |
@brettcannon I'll try to get this closed as soon as possible. |
@serhiy-storchaka Which error should I be throwing here? |
|
Though I've written the test for
I tried to import
|
@sayanchowdhury did you run |
pythonGH-1735) This patch would also raise DeprecationWarning for 'name'. Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
@berkerpeksag I did not. Thanks. I have updated the PR. I don't know if the message for TypeError sounds good. Please review the PR. |
Please add a NEWS entry. See https://devguide.python.org/committing/#what-s-new-and-news-entries for details.
pythonGH-1735) This patch would also raise DeprecationWarning for 'name'. Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
Sorry for that one. Probably because it is an old PR. |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @berkerpeksag, @serhiy-storchaka, @brettcannon, @ambv: please review the changes made to this pull request. |
|
@sayanchowdhury changes looks great! Unfortunately the macOS tests failed for some reason and now there's a merge conflict. If you could fix the merge conflict then hopefully the tests will pass and then we can merge this! |
Sorry, I can't merge this PR. Reason: |
@sayanchowdhury, please resolve the merge conflict as this has been approved and is ready to merge. Thanks! |
Ping. I see this has stalled, in what way can we get it started again? |
@DimitrisJim macOS test failure needs to be resolved and the merge conflict needs to be fixed. |
This PR is stale because it has been open for 30 days with no activity. |
The problem is that it makes all parameters optional. ExtensionFileLoader()
is now valid.
At this point I think the risk of breakage outweighs the purity of normalizing the argument name. Thanks to @sayanchowdhury for the PR, but I think this has stalled out too long to merge at this point. |
DeprecationWarning is raised for any use of 'name'.
https://bugs.python.org/issue30274
Automerge-Triggered-By: @brettcannon