Skip to content

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

Closed
sayanchowdhury wants to merge 3 commits into
python:mainfrom
sayanchowdhury:bpo30274
Closed

bpo-30274: Rename 'name' to 'fullname' argument to ExtensionFileLoader.#1735
sayanchowdhury wants to merge 3 commits into
python:mainfrom
sayanchowdhury:bpo30274

Conversation

@sayanchowdhury
Copy link
Copy Markdown
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
Comment thread Lib/importlib/_bootstrap_external.py Outdated
Copy link
Copy Markdown
Contributor

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.

Comment thread Lib/importlib/_bootstrap_external.py Outdated
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

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

Comment thread Lib/importlib/_bootstrap_external.py Outdated
Copy link
Copy Markdown
Member

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

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.

Comment thread Misc/NEWS Outdated
Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

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
Copy Markdown

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

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

@sayanchowdhury
Copy link
Copy Markdown
Contributor Author

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

@sayanchowdhury
Copy link
Copy Markdown
Contributor Author

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

@serhiy-storchaka
Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

@sayanchowdhury did you run make regen-importlib?

@sayanchowdhury
Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Member

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

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

Comment thread Lib/test/test_importlib/extension/test_loader.py Outdated
Comment thread Lib/test/test_importlib/extension/test_loader.py Outdated
@bedevere-bot
Copy link
Copy Markdown

Thanks for making the requested changes!

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

Copy link
Copy Markdown
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

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

Comment thread Lib/test/test_importlib/extension/test_loader.py Outdated
Comment thread Lib/test/test_importlib/extension/test_loader.py Outdated
@bedevere-bot
Copy link
Copy Markdown

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.

Comment thread Doc/whatsnew/3.9.rst Outdated
Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
@sayanchowdhury
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link
Copy Markdown

Thanks for making the requested changes!

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

@serhiy-storchaka
Copy link
Copy Markdown
Member

👍

@brettcannon
Copy link
Copy Markdown
Member

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

@miss-islington
Copy link
Copy Markdown
Contributor

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

@csabella
Copy link
Copy Markdown
Contributor

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

@DimitrisJim
Copy link
Copy Markdown
Contributor

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

@brettcannon
Copy link
Copy Markdown
Member

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

@github-actions
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

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

@brettcannon
Copy link
Copy Markdown
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge sprint stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.