Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnicodeEncodeError in help.py #2466

Merged
merged 3 commits into from
Jun 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()