Skip to content

Commit 760f5f8

Browse files
committed
fix #116
1 parent d852113 commit 760f5f8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

twine/utils.py

Lines changed: 9 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,13 @@ def get_userpass_value(cli_value, config, key, prompt_strategy):
113114
else:
114115
return prompt_strategy()
115116

117+
def password_prompt(prompt_text): # Always expects unicode for our own sanity
118+
prompt = prompt_text
119+
# Workaround for https://github.com/pypa/twine/issues/116
120+
if os.name == 'nt' and sys.version_info < (3, 0):
121+
prompt = prompt_text.encode('utf8')
122+
return functools.partial(getpass.getpass, prompt=prompt)
123+
116124
get_username = functools.partial(
117125
get_userpass_value,
118126
key='username',
@@ -121,7 +129,5 @@ def get_userpass_value(cli_value, config, key, prompt_strategy):
121129
get_password = functools.partial(
122130
get_userpass_value,
123131
key='password',
124-
prompt_strategy=functools.partial(
125-
getpass.getpass, 'Enter your password: ',
126-
),
132+
prompt_strategy=password_prompt('Enter your password: '),
127133
)

0 commit comments

Comments
 (0)