Skip to content

GH-74460: Renamed name argument to fullname for importlib.machinery.ExtensionFileLoader#92300

Closed
achhina wants to merge 2 commits into
python:mainfrom
achhina:fix-issue-74460
Closed

GH-74460: Renamed name argument to fullname for importlib.machinery.ExtensionFileLoader#92300
achhina wants to merge 2 commits into
python:mainfrom
achhina:fix-issue-74460

Conversation

@achhina
Copy link
Copy Markdown
Contributor

@achhina achhina commented May 4, 2022

Corresponds to issue GH-74460. Fixed merge conflicts in PR-1735 as it has been reviewed successfully but has now been stale for over two years; thanks to @sayanchowdhury for the original code.

  • Tests passed locally
  • CLA signed
  • Blurb added
  • Deprecation notice added in 3.11 what's new

@achhina
Copy link
Copy Markdown
Contributor Author

achhina commented May 4, 2022

Hi, @brettcannon and @serhiy-storchaka, as both of you had reviewed the original PR that this one references; would one of you be able to look at this follow-up?

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.

@achhina
Copy link
Copy Markdown
Contributor Author

achhina commented May 4, 2022

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

I'm not familiar enough with the environment, but would that be an issue? It's not ideal but I currently see ExtensionFileLoader() as not a very useful invocation but not necessarily a breaking change - however, I might be missing something.

Alternatively, we could raise a TypeError if name and fullname are both None, with some message stating that fullname must be nonempty (presumably because if both are empty then we should only suggest passing in the non-deprecated parameter).

Something like this:

    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,
                           stacklevel=2)
            if fullname is not None:
                raise TypeError("'name' and 'fullname' cannot be used "
                                "simultaneously")
            self.name = name
        elif fullname is not None:
            self.name = fullname
        else:
            raise TypeError("'fullname' cannot be empty")
        self.path = path

There are two caveats that immediately come to mind. The first is that would name/fullname being None ever be a valid invocation? Second, this now stops ExtensionFileLoader(), but still allows it to not pass a path.

With that being said if it doesn't break anything I'm still leaning towards allowing ExtensionFileLoader().

@brettcannon
Copy link
Copy Markdown
Member

I actually just closed the issue and all other PRs due to too much time having passed since I opened the original issue back in 2017. The risk of breaking code is too high now just to get some purity around name consistency.

@achhina thanks so much for taking a stab at this! But I'm afraid that I don't think we can take the PR.

@brettcannon brettcannon closed this May 4, 2022
@achhina achhina deleted the fix-issue-74460 branch May 5, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants