From ed3de3f2dece0459b68bc687dcb6293c78d16635 Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Thu, 28 Jun 2018 21:47:38 +0300 Subject: [PATCH] Fix `UnicodeEncodeError` in help.py --- pipenv/help.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pipenv/help.py b/pipenv/help.py index e08c6173b9..0d06680d27 100644 --- a/pipenv/help.py +++ b/pipenv/help.py @@ -9,6 +9,13 @@ from .pep508checker import lookup +def print_utf(line): + try: + print(line) + except UnicodeEncodeError: + print(line.encode('utf-8')) + + def main(): print('
$ python -m pipenv.help output') print('') @@ -45,13 +52,13 @@ def main(): for key in os.environ: print(' - `{0}`'.format(key)) print('') - print(u'Pipenv–specific environment variables:') + print_utf(u'Pipenv–specific environment variables:') print('') for key in os.environ: if key.startswith('PIPENV'): print(' - `{0}`: `{1}`'.format(key, os.environ[key])) print('') - print(u'Debug–specific environment variables:') + print_utf(u'Debug–specific environment variables:') print('') for key in ('PATH', 'SHELL', 'EDITOR', 'LANG', 'PWD', 'VIRTUAL_ENV'): if key in os.environ: @@ -61,7 +68,7 @@ def main(): print('---------------------------') print('') if project.pipfile_exists: - print( + print_utf( u'Contents of `Pipfile` ({0!r}):'.format(project.pipfile_location) ) print('') @@ -72,7 +79,7 @@ def main(): print('') if project.lockfile_exists: print('') - print( + print_utf( u'Contents of `Pipfile.lock` ({0!r}):'.format( project.lockfile_location ) @@ -87,3 +94,4 @@ def main(): if __name__ == '__main__': main() +