Title: `getpass`'s `echo_char` should be restricted to a single ASCII character · Issue #138514 · python/cpython · GitHub
Open Graph Title: `getpass`'s `echo_char` should be restricted to a single ASCII character · Issue #138514 · python/cpython
X Title: `getpass`'s `echo_char` should be restricted to a single ASCII character · Issue #138514 · python/cpython
Description: Bug report Bug description: Running getpass.getpass(echo_char="***") works until a character is entered, at which point a traceback error occurs. import getpass getpass.getpass(echo_char="***") Password: Traceback (most recent call last)...
Open Graph Description: Bug report Bug description: Running getpass.getpass(echo_char="***") works until a character is entered, at which point a traceback error occurs. import getpass getpass.getpass(echo_char="***") Pas...
X Description: Bug report Bug description: Running getpass.getpass(echo_char="***") works until a character is entered, at which point a traceback error occurs. import getpass getpass.getpass(echo_char=...
Opengraph URL: https://github.com/python/cpython/issues/138514
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`getpass`'s `echo_char` should be restricted to a single ASCII character","articleBody":"# Bug report\n\n### Bug description:\n\nRunning `getpass.getpass(echo_char=\"***\")` works until a character is entered, at which point a traceback error occurs.\n\n```python\nimport getpass\ngetpass.getpass(echo_char=\"***\")\n```\n\n```text\nPassword: Traceback (most recent call last):\n File \"\u003cpython-input-10\u003e\", line 1, in \u003cmodule\u003e\n getpass.getpass(echo_char=\"***\")\n ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^\n File \"...\\pythoncore-3.14-64\\Lib\\getpass.py\", line 129, in win_getpass\n msvcrt.putwch(echo_char)\n ~~~~~~~~~~~~~^^^^^^^^^^^\nTypeError: putwch(): argument must be a unicode character, not a string of length 3\n```\n\nValidation should occur upon input for this argument, and `getpass` should raise a `ValueError` stating: \"'echo_char' must be a single-character **ASCII** string, not a string of length 3\" (with ASCII only being bolded in this write-up for emphasis that a Unicode character cannot be used).\n\nAdditionally, the error message language should be revised when a non-ASCII string is entered:\n\n```python\nimport getpass\ngetpass.getpass(echo_char=\"Æ\")\n```\n\n```text\nTraceback (most recent call last):\n File \"\u003cpython-input-11\u003e\", line 1, in \u003cmodule\u003e\n getpass.getpass(echo_char=\"Æ\")\n ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^\n File \"...\\pythoncore-3.14-64\\Lib\\getpass.py\", line 109, in win_getpass\n _check_echo_char(echo_char)\n ~~~~~~~~~~~~~~~~^^^^^^^^^^^\n File \"...\\pythoncore-3.14-64\\Lib\\getpass.py\", line 149, in _check_echo_char\n raise ValueError(\"'echo_char' must be a printable ASCII string, \"\n f\"got: {echo_char!r}\")\nValueError: 'echo_char' must be a printable ASCII string, got: 'Æ'\n```\n\nBetter language would be: \"'echo_char' must be a single-character ASCII string, got: 'Æ'\".\n\nWith agreement, I can submit a pull request.\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-138591\n* gh-138988\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/bkjoh","@type":"Person","name":"bkjoh"},"datePublished":"2025-09-04T21:17:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/138514/cpython/issues/138514"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9f169ba0-65c1-7ec9-b41d-6661713ff9f2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A04E:1B9CED:2FF7692:43522F1:6A50E7E6 |
| html-safe-nonce | dc4802fbc5fbdacc9447783947cc959fd6fa92eba631ebb505da80461833f8f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDRFOjFCOUNFRDoyRkY3NjkyOjQzNTIyRjE6NkE1MEU3RTYiLCJ2aXNpdG9yX2lkIjoiNTg0ODI0ODUyNTM5NDA3NzY3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fb9f304db0c039f92b195458cf073ebc9795b374d8ee67e788d83744047fb4ae |
| hovercard-subject-tag | issue:3385499212 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/138514/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6cf30dbfbf02623dd7376bb4c80903438555bac31e7fdb79386f5b3fd05997da/python/cpython/issues/138514 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6cf30dbfbf02623dd7376bb4c80903438555bac31e7fdb79386f5b3fd05997da/python/cpython/issues/138514 |
| og:image:alt | Bug report Bug description: Running getpass.getpass(echo_char="***") works until a character is entered, at which point a traceback error occurs. import getpass getpass.getpass(echo_char="***") Pas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bkjoh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fb19d617b534959801b4b7453938ecf1dfa22131 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width