Skip to content

Commit fae6b63

Browse files
committed
fix #116
1 parent d852113 commit fae6b63

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

twine/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import absolute_import, division, print_function
1515
from __future__ import unicode_literals
1616

17+
import os
1718
import os.path
1819
import functools
1920
import getpass
@@ -113,6 +114,14 @@ def get_userpass_value(cli_value, config, key, prompt_strategy):
113114
else:
114115
return prompt_strategy()
115116

117+
118+
def password_prompt(prompt_text): # Always expects unicode for our own sanity
119+
prompt = prompt_text
120+
# Workaround for https://github.com/pypa/twine/issues/116
121+
if os.name == 'nt' and sys.version_info < (3, 0):
122+
prompt = prompt_text.encode('utf8')
123+
return functools.partial(getpass.getpass, prompt=prompt)
124+
116125
get_username = functools.partial(
117126
get_userpass_value,
118127
key='username',
@@ -121,7 +130,5 @@ def get_userpass_value(cli_value, config, key, prompt_strategy):
121130
get_password = functools.partial(
122131
get_userpass_value,
123132
key='password',
124-
prompt_strategy=functools.partial(
125-
getpass.getpass, 'Enter your password: ',
126-
),
133+
prompt_strategy=password_prompt('Enter your password: '),
127134
)

0 commit comments

Comments
 (0)