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

bpo-30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader. #1735

Closed
wants to merge 3 commits into from

Conversation

Copy link
Contributor

@sayanchowdhury sayanchowdhury commented May 22, 2017

DeprecationWarning is raised for any use of 'name'.

https://bugs.python.org/issue30274

Automerge-Triggered-By: @brettcannon

@sayanchowdhury sayanchowdhury changed the title bpo30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader. bpo-30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader. May 22, 2017
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)
Copy link
Contributor

@ambv ambv May 22, 2017

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.

@@ -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
Copy link
Contributor

@ambv ambv May 23, 2017

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.

Copy link
Contributor Author

@sayanchowdhury sayanchowdhury May 23, 2017

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.

@Mariatta
Copy link
Sponsor

@Mariatta Mariatta commented Jun 12, 2017

I believe this was done during Pycon US sprint, so I applied the sprint label.

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)
Copy link
Member

@berkerpeksag berkerpeksag Jul 23, 2017

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.

Copy link
Member

@berkerpeksag berkerpeksag Jul 23, 2017

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
Copy link
Member

@berkerpeksag berkerpeksag Jul 23, 2017

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

Copy link
Contributor Author

@sayanchowdhury sayanchowdhury Jul 24, 2017

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

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

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.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 2, 2017

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@brettcannon
Copy link

@brettcannon brettcannon commented Jul 20, 2018

@sayanchowdhury do you plan to address the review comments or should I close it?

@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Jul 24, 2018

@brettcannon I'll try to get this closed as soon as possible.

@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Oct 13, 2018

@serhiy-storchaka Which error should I be throwing here? ValueError?

@serhiy-storchaka
Copy link

@serhiy-storchaka serhiy-storchaka commented Oct 14, 2018

TypeError, as in the case when you pass positional and keyword argument for the same parameter.

@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Oct 14, 2018

Though I've written the test for DeprecationWarning I don't know if it's correct. Locally, my tests are failing with this error

======================================================================
FAIL: test_name_deprecation (test.test_importlib.extension.test_loader.Frozen_LoaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sachowdh/code/cpython/Lib/test/test_importlib/extension/test_loader.py", line 34, in test_name_deprecation
    other = self.machinery.ExtensionFileLoader(
AssertionError: DeprecationWarning not triggered

----------------------------------------------------------------------

I tried to import ExtensionFileLoader in Python shell and it does not reflect the updated arguments i.e. fullname. How can I fix it?

➜  cpython git:(bpo30274) ✗ ./python                                                     
Python 3.8.0a0 (heads/bpo30274-dirty:8e5ac1790b, Oct 14 2018, 19:03:35) 
[GCC 8.1.1 20180712 (Red Hat 8.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.machinery import ExtensionFileLoader
>>> help(ExtensionFileLoader)
class ExtensionFileLoader(FileLoader, _LoaderBasics)
 |  ExtensionFileLoader(name, path)

@berkerpeksag
Copy link

@berkerpeksag berkerpeksag commented Oct 16, 2018

@sayanchowdhury did you run make regen-importlib?

sayanchowdhury added a commit to sayanchowdhury/cpython that referenced this issue Oct 17, 2018
pythonGH-1735)

This patch would also raise DeprecationWarning for 'name'.

Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Oct 17, 2018

@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.

Copy link
Member

@berkerpeksag berkerpeksag left a comment

Lib/test/test_importlib/extension/test_loader.py Outdated Show resolved Hide resolved
Lib/test/test_importlib/extension/test_loader.py Outdated Show resolved Hide resolved
sayanchowdhury added a commit to sayanchowdhury/cpython that referenced this issue Oct 17, 2018
pythonGH-1735)

This patch would also raise DeprecationWarning for 'name'.

Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Mar 20, 2020

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Doc/whatsnew/3.9.rst Outdated Show resolved Hide resolved
Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Mar 21, 2020

I'm really sorry to send this back to you, @sayanchowdhury, but I just noticed some indentation inconsistencies. (I would have committed them myself and then merged but I don't think you checked the box to let me edit the PR).

Sorry for that one. Probably because it is an old PR.

@sayanchowdhury
Copy link
Author

@sayanchowdhury sayanchowdhury commented Mar 21, 2020

I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Mar 21, 2020

Thanks for making the requested changes!

@berkerpeksag, @serhiy-storchaka, @brettcannon, @ambv: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from brettcannon Mar 21, 2020
@serhiy-storchaka
Copy link

@serhiy-storchaka serhiy-storchaka commented Mar 22, 2020

👍

@brettcannon
Copy link

@brettcannon brettcannon commented Mar 25, 2020

@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!

@brettcannon brettcannon added the 🤖 automerge label Mar 25, 2020
@miss-islington
Copy link

@miss-islington miss-islington commented Mar 25, 2020

Sorry, I can't merge this PR. Reason: Pull Request is not mergeable.

@csabella
Copy link

@csabella csabella commented May 23, 2020

@sayanchowdhury, please resolve the merge conflict as this has been approved and is ready to merge. Thanks!

@DimitrisJim
Copy link

@DimitrisJim DimitrisJim commented May 17, 2021

Ping. I see this has stalled, in what way can we get it started again?

@brettcannon
Copy link

@brettcannon brettcannon commented May 17, 2021

@DimitrisJim macOS test failure needs to be resolved and the merge conflict needs to be fixed.

@github-actions
Copy link

@github-actions github-actions bot commented Feb 19, 2022

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Feb 19, 2022
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

The problem is that it makes all parameters optional. ExtensionFileLoader() is now valid.

@brettcannon
Copy link

@brettcannon brettcannon commented May 4, 2022

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.

@brettcannon brettcannon closed this May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge CLA signed 🤖 automerge sprint stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet