Skip to content

Commit

Permalink
Merge pull request #2466 from maxkrivich/fix-unicode-error
Browse files Browse the repository at this point in the history
Fix `UnicodeEncodeError` in help.py
  • Loading branch information
techalchemy authored Jun 29, 2018
2 parents e8f00b6 + 35f309f commit 9d826c4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pipenv/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<details><summary>$ python -m pipenv.help output</summary>')
print('')
Expand Down Expand Up @@ -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:
Expand All @@ -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('')
Expand All @@ -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
)
Expand All @@ -87,3 +94,4 @@ def main():

if __name__ == '__main__':
main()

0 comments on commit 9d826c4

Please sign in to comment.