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-31109: Convert zipimport to argument clinic #2990

Merged
merged 6 commits into from
Aug 18, 2017

Conversation

jarondl
Copy link
Contributor

@jarondl jarondl commented Aug 2, 2017

Convert the zipimport module to argument clinic. Mostly
straight-forward, had to rename a few argument names.

https://bugs.python.org/issue31109

Convert the zipimport module to argument clinic. Mostly
straight-forward, had to rename a few argument names.
/*[clinic input]
zipimport.zipimporter.__init__

archivepath: object(converter="PyUnicode_FSDecoder")
Copy link
Member

Choose a reason for hiding this comment

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

Why not use just the name "path"?

Copy link
Contributor Author

@jarondl jarondl Aug 3, 2017

Choose a reason for hiding this comment

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

Do you mean path: or archivepath as path:?
Sure I can do the latter, but what's the benefit? It was more straight forward to rename the variable to match the signature. The meaning of archivepath is clearer

Copy link
Member

Choose a reason for hiding this comment

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

The benefit of not renaming is the patch is much easier to review that way. As it stands it's much harder for us to check the accuracy of the changes due to so many lines being flagged as changed compared to just reviewing the Argument Clinic changes which is what this PR is specifically targeting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/*[clinic input]
zipimport.zipimporter.find_module

fullname: unicode
Copy link
Member

Choose a reason for hiding this comment

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

The arguments of this method (and many other methods) were positional-only. Converting to Argument Clinic shouldn't change the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually all the methods here were positional-only. But this change is backwards compatible and logical. See for example http://bugs.python.org/issue20294#msg208444
Why should we force positional-only? Your patch in bpo-25711 to convert zipimport to Python would also have the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you prefer to keep Argument Clinic conversion separate from behavioral changes? Then we can add trailing /s to the argument lists and remove them in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we prefer to not change semantics while doing an Argument Clinic conversion (we have run into issues in the past when doing both at the same time).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, done, now they are positional only. Thank you both for reviewing.

Preserve positional only arguments in zipimport after argument clinic
conversion.
/*[clinic input]
zipimport.zipimporter.__init__

archivepath: object(converter="PyUnicode_FSDecoder")
Copy link
Member

Choose a reason for hiding this comment

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

The benefit of not renaming is the patch is much easier to review that way. As it stands it's much harder for us to check the accuracy of the changes due to so many lines being flagged as changed compared to just reviewing the Argument Clinic changes which is what this PR is specifically targeting.

Revert the argument names archivepath and pathname to their
original names in the code (path, and path).
Copy link
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.

Three really minor formatting tweaks necessary and then I think this will be ready to go!

'/tmp/myimport.zip/mydirectory', if mydirectory is a valid directory inside
the archive.

'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is a stray ' at the start of this sentence.

'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip
archive.

The 'archive' attribute of zipimporter objects contains the name of the
Copy link
Member

Choose a reason for hiding this comment

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

"zipimporter objects" -> "the zipimporter object".


Search for a module specified by 'fullname'.

'fullname' must be the
Copy link
Member

Choose a reason for hiding this comment

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

Premature line break.

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

@serhiy-storchaka did you have any other feedback or can I merge this?

@jarondl
Copy link
Contributor Author

jarondl commented Aug 17, 2017

@serhiy-storchaka and @brettcannon , is there anything else I can do to have this merged?
In any case I want to say thank you both for the reviews.

@brettcannon brettcannon self-assigned this Aug 17, 2017
@brettcannon
Copy link
Member

Since it looks like @serhiy-storchaka has nothing to add would you mind adding a news entry? See https://devguide.python.org/committing/#what-s-new-and-news-entries on how to do that. Once that's file in I can touch it up as necessary and then merge this!

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

Please add a news entry.

@bedevere-bot
Copy link

A Python core developer, brettcannon, 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 didn't expect the Spanish Inquisition!
I will then notify brettcannon along with any other core developers
who have left a review that you're ready for them to take another look
at this pull request.

@jarondl
Copy link
Contributor Author

jarondl commented Aug 18, 2017

Blimey, I didn't expect the Spanish Inquisition!

@bedevere-bot
Copy link

Nobody expects the Spanish Inquisition!

@brettcannon: please review the changes made to this pull request.

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

Once Travis goes green I'll merge!

@brettcannon
Copy link
Member

Thanks for the work, @jarondl !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants