-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Conversation
10e92c6
to
940ad28
Compare
Convert the zipimport module to argument clinic. Mostly straight-forward, had to rename a few argument names.
Modules/zipimport.c
Outdated
/*[clinic input] | ||
zipimport.zipimporter.__init__ | ||
|
||
archivepath: object(converter="PyUnicode_FSDecoder") |
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.
Why not use just the name "path"?
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.
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
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.
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.
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.
Done.
/*[clinic input] | ||
zipimport.zipimporter.find_module | ||
|
||
fullname: unicode |
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.
The arguments of this method (and many other methods) were positional-only. Converting to Argument Clinic shouldn't change the behavior.
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.
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.
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.
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.
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.
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).
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.
OK, done, now they are positional only. Thank you both for reviewing.
Preserve positional only arguments in zipimport after argument clinic conversion.
Modules/zipimport.c
Outdated
/*[clinic input] | ||
zipimport.zipimporter.__init__ | ||
|
||
archivepath: object(converter="PyUnicode_FSDecoder") |
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.
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).
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.
Three really minor formatting tweaks necessary and then I think this will be ready to go!
Modules/zipimport.c
Outdated
'/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 |
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.
Looks like there is a stray '
at the start of this sentence.
Modules/zipimport.c
Outdated
'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip | ||
archive. | ||
|
||
The 'archive' attribute of zipimporter objects contains the name of the |
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.
"zipimporter objects" -> "the zipimporter object".
Modules/zipimport.c
Outdated
|
||
Search for a module specified by 'fullname'. | ||
|
||
'fullname' must be the |
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.
Premature line break.
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.
@serhiy-storchaka did you have any other feedback or can I merge this?
@serhiy-storchaka and @brettcannon , is there anything else I can do to have this merged? |
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! |
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.
Please add a news entry.
A Python core developer, brettcannon, has requested some changes be Once you have made the requested changes, please leave a comment |
Blimey, I didn't expect the Spanish Inquisition! |
Nobody expects the Spanish Inquisition! @brettcannon: please review the changes made to this pull request. |
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.
Once Travis goes green I'll merge!
Thanks for the work, @jarondl ! |
Convert the zipimport module to argument clinic. Mostly
straight-forward, had to rename a few argument names.
https://bugs.python.org/issue31109