Skip to content

gh-95423: Updated winreg.DeleteKeyEx documentation for 32-bit OS. #95521

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

Merged
merged 14 commits into from
Aug 3, 2022

Conversation

derekdkim
Copy link
Contributor

Documentation updates to address:

Issue #95423

Please let me know if my wording could use some improvement or if I missed any other part of the documentation.

Fixed some inaccuracies and added clarifications in the docstrings and documentation for winreg.DeleteKeyEx for how it behaves on 32-bit Windows.
@derekdkim derekdkim requested a review from a team as a code owner August 1, 2022 05:39
@ghost
Copy link

ghost commented Aug 1, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@zooba
Copy link
Member

zooba commented Aug 1, 2022

Thanks, it's a good start.

We don't need the note about NT 5.2 in here, because that applies to all of our supported platforms. We can also really simplify the note about 32-bit OS, since that's a vanishingly small number of machines these days.

The aim of our docs is to help Python developers use Python correctly. We don't need to provide historical or internal details of the platform, except where they are directly relevant to decisions that Python devs will have to make (and we are confident they won't change on us). Hopefully that helps guide your revisions.

@zooba zooba added docs Documentation in the Doc dir skip news labels Aug 1, 2022
@derekdkim
Copy link
Contributor Author

derekdkim commented Aug 1, 2022

Thanks for the feedback @zooba. I tried my best to cut down some of the bloat. Let me know if you think it can be simplified further.

Also, should I be committing the regenerated configure and topics.py? I wasn't sure what exactly needs to be done for the build step "Check if generated files are up to date" so I left it uncommitted for the time being.

@zooba
Copy link
Member

zooba commented Aug 1, 2022

Ah yeah, because you modified the docstrings, you need to run python Tools\clinic\clinic.py PC\winreg.c to update the generated code that includes them. Once you've done that, it should pass that check.

pythongh-95423: Regenerated winreg code with updated docstrings.
pythongh-95423: Fixed default role backticks
@zooba
Copy link
Member

zooba commented Aug 2, 2022

For future, please don't force push once people have started reviewing. We always squash merge and edit commit messages, so no need to worry about that, and force pushes just break incremental reviews (i.e. I can't see what changes you just made, I have to start reading again).

@derekdkim
Copy link
Contributor Author

Ah sorry, my bad. Noted.

Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

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

I checked out the current state of the Reg function, and think we can drastically simplify. There aren't really any edge cases here anymore - it's just RegDeleteKeyExW all the time, and the WOW64 constants are ignored when they aren't relevant, so you can pass in anything you like.

Comment on lines 147 to 151
.. note::
The :func:`DeleteKeyEx` function is implemented with the RegDeleteKeyEx
Windows API function, which is specific to 64-bit versions of Windows.
Windows API function, which is intended to be used for 64-bit Windows.
On 32-bit systems, it is strongly recommended to use :func:`DeleteKey()`
instead.
Copy link
Member

Choose a reason for hiding this comment

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

I did some more research, and it seems that there's no distinction on any modern Windows OS. RegDeleteKey just calls RegDeleteKeyEx directly and passes in zero for the extra parameter, so there isn't really any need for this note at all.

Copy link
Contributor Author

@derekdkim derekdkim Aug 3, 2022

Choose a reason for hiding this comment

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

Got it, I removed the note completely.

PC/winreg.c Outdated
Comment on lines 1003 to 1007
Deletes the specified key (intended for 64-bit OS).

While this function is intended to be used for 64-bit OS, it is also
available on 32-bit systems.
To use with 32-bit Windows, 0 must be passed in as the access argument.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Deletes the specified key (intended for 64-bit OS).
While this function is intended to be used for 64-bit OS, it is also
available on 32-bit systems.
To use with 32-bit Windows, 0 must be passed in as the access argument.
Deletes the specified key.

As above

@bedevere-bot
Copy link

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.

derekdkim and others added 6 commits August 2, 2022 23:04
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@derekdkim
Copy link
Contributor Author

Thanks for the suggestions. I have made the requested changes; please review again. I think I was way too wordy and tunnel visioned on keeping the notes mentioned in the issue.

I also simplified winreg_DeleteKeyEx_impl() as per your suggestions. I removed the dynamic loading from the .dll and just called it directly similar to how winreg_DeleteKey_impl() is implemented. Let me know if I missed anything.

@bedevere-bot
Copy link

Thanks for making the requested changes!

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

@bedevere-bot bedevere-bot requested a review from zooba August 3, 2022 04:35
Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

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

With the one change (which I'll commit myself), this looks great!

@derekdkim
Copy link
Contributor Author

derekdkim commented Aug 3, 2022

@zooba Ah thanks for the note about the GIL around RegDeleteKeyExW(). Is there a reason why the same doesn't apply for RegDeleteKeyW() in winreg_DeleteKey_impl()?

@zooba
Copy link
Member

zooba commented Aug 3, 2022

Hmm... that seems like an oversight. Would you like to get it? I'm fine to not worry about it and just merge as it is.

@derekdkim
Copy link
Contributor Author

No problem, I got it.

@zooba zooba merged commit ebd6601 into python:main Aug 3, 2022
@zooba
Copy link
Member

zooba commented Aug 3, 2022

Awesome work, thanks!

@zooba zooba added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Aug 3, 2022
@miss-islington
Copy link
Contributor

Thanks @derekdkim for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @derekdkim for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @derekdkim and @zooba, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ebd660156d80bbb17899ca393731da5548100fc1 3.11

@miss-islington
Copy link
Contributor

Sorry @derekdkim and @zooba, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker ebd660156d80bbb17899ca393731da5548100fc1 3.10

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Aug 3, 2022
@bedevere-bot
Copy link

GH-95619 is a backport of this pull request to the 3.11 branch.

zooba pushed a commit to zooba/cpython that referenced this pull request Aug 3, 2022
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Aug 3, 2022
@bedevere-bot
Copy link

GH-95622 is a backport of this pull request to the 3.10 branch.

zooba pushed a commit to zooba/cpython that referenced this pull request Aug 3, 2022
zooba added a commit that referenced this pull request Aug 3, 2022
…function load (GH-95521)

Co-authored-by: Derek Kim <ddkim1024@gmail.com>
zooba added a commit that referenced this pull request Aug 3, 2022
…function load (GH-95521)

Co-authored-by: Derek Kim <ddkim1024@gmail.com>
@derekdkim derekdkim deleted the gh-95423 branch August 3, 2022 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants