Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-77065: Add optional keyword-only argumentecho_char forgetpass.getpass#130496

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 24 commits intopython:mainfromdonBarbos:issue-77065
May 6, 2025

Conversation

donBarbos
Copy link
Contributor

@donBarbosdonBarbos commentedFeb 24, 2025
edited by github-actionsbot
Loading

@donBarbos
Copy link
ContributorAuthor

donBarbos commentedFeb 27, 2025
edited
Loading

@picnixz sorry for choosing you, I just haven't found anyone else from the core team who is active yet (I looked at who is involved in issue and experts table). could you review?

@picnixzpicnixz self-requested a reviewMarch 1, 2025 15:17
@picnixz
Copy link
Member

You can ping me for anything that is remotely related to security and cryptography

donBarbos reacted with thumbs up emoji

picnixz
picnixz previously requested changesMar 1, 2025
Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

Amask is something else for me. So I would either name it "echochar" or "maskchar" or "hidechar", at least with some "char" inside it.

In addition, for termios, you should useECHOE to handle ERASE

@bedevere-app
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 phraseI 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.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@donBarbos
Copy link
ContributorAuthor

@picnixz I chosemask because it was used in the issue examples and also it seems that*char assumes one character while our argument can take arbitrary length. But it's not very important for me.
As for using keyword-only argument, I don't quite understand why that is.

@picnixz
Copy link
Member

As for using keyword-only argument, I don't quite understand why that is.

Because if you were to use it, you would writegetpass(mask="*"), likely not changing the prompt nor the stream value. And keyword-only arguments is good for future compatibility (e.g., if we want to add more options, we are not held back by the order of the arguments)

donBarbos reacted with thumbs up emoji

@picnixz
Copy link
Member

I chose mask because it was used in the issue examples and also it seems that *char

Usually, you expect 1 character indeed. I don't think we should write something else than 1 char (or maybe we do but it's because of colors?) I would not expectwords to be put as placeholders. Maybe colorized characters, which in this case are allowed to be strings of length > 1, but not real words.

Also, what we are echoing is really the corresponding passwordcharacter. Foreach character, we use that placeholder.mask is really not a good idea because it could hint that we would (bitwise) mask the password (namely perform some& operation). But this is something we can think of at the end.

@donBarbos
Copy link
ContributorAuthor

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

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

@bedevere-appbedevere-appbot requested a review frompicnixzMarch 1, 2025 18:15
@donBarbosdonBarbos changed the titlegh-77065: Add optional argumentmask forgetpass.getpassgh-77065: Add optional keyword-only argumentechochar forgetpass.getpassMar 1, 2025
@donBarbos
Copy link
ContributorAuthor

donBarbos commentedMar 1, 2025
edited
Loading

@picnixz I just thought maybe we also should to add, *, echochar=None togetpass.fallback_getpass to have a unified interface

@bedevere-app
Copy link

Thanks for making the requested changes!

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

@bedevere-appbedevere-appbot requested a review frompicnixzMarch 25, 2025 23:18
@donBarbos
Copy link
ContributorAuthor

@picnixz, I added test cases, what do you think about them?

Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

Can we have tests where we exercise control characters? this is quite important because we want to get the correct feedback

@donBarbos
Copy link
ContributorAuthor

Can we have tests where we exercise control characters? this is quite important because we want to get the correct feedback

I added test case with control chars\t and\b. butmock_output.getvalue() have***\x08 \x08 in the end of string without removing* unlike the real console where* is removed by itself and\x08 is not displayed

@donBarbos
Copy link
ContributorAuthor

Can we have tests where we exercise control characters? this is quite important because we want to get the correct feedback

I added test case with control chars\t and\b. butmock_output.getvalue() have***\x08 \x08 in the end of string without removing* unlike the real console where* is removed by itself and\x08 is not displayed

cc@picnixz

@donBarbos
Copy link
ContributorAuthor

@picnixz It seems that all the tests that you requested already exist, but maybe it will be possible to add more since there is already an issue for covering the module with tests

I would like to have time to accept before feature freeze :-)

@picnixz
Copy link
Member

picnixz commentedMay 4, 2025
edited
Loading

I am travelling (I'm back after the beta release) so I won't merge anything on mobile. I'll defer this to@gpshead, sorry but it passed under my radar :( (in the future, a request for review is more likely to be noticed)

donBarbos reacted with thumbs up emoji

@@ -151,6 +176,42 @@ def _raw_input(prompt="", stream=None, input=None):
return line


def _input_with_echochar(prompt, stream, input, echochar):
Copy link
Member

Choose a reason for hiding this comment

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

rather than duplicating so much of _raw_input's logic, I suggest making a _readline_with_echochar() function and just conditionally calling that vs the existing input.readline() call within _raw_input().

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

sounds reasonable, please check my diff

@donBarbosdonBarbos requested a review fromgpsheadMay 5, 2025 17:17
@donBarbosdonBarbos requested a review fromhugovkMay 6, 2025 10:53
@donBarbosdonBarbos changed the titlegh-77065: Add optional keyword-only argumentechochar forgetpass.getpassgh-77065: Add optional keyword-only argumentecho_char forgetpass.getpassMay 6, 2025
@hugovkhugovk merged commitbf8bbe9 intopython:mainMay 6, 2025
39 checks passed
@donBarbos
Copy link
ContributorAuthor

Thank you everyone!

mjbear reacted with hooray emoji

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

@picnixzpicnixzpicnixz left review comments

@gpsheadgpsheadAwaiting requested review from gpshead

@hugovkhugovkAwaiting requested review from hugovk

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@donBarbos@picnixz@gpshead@hugovk

[8]ページ先頭

©2009-2025 Movatter.jp