Skip to content

Commit

Permalink
Call locale.setlocale() to load locale
Browse files Browse the repository at this point in the history
Fixes raising an exception on pip._internal.utils.encoding.auto_decode
when requirement.txt has unique symblols.
  • Loading branch information
atugushev committed May 5, 2019
1 parent fe98e45 commit 5cb1764
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions piptools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import locale

from piptools.click import secho

# Needed for locale.getpreferredencoding(False) to work
# in pip._internal.utils.encoding.auto_decode
try:
locale.setlocale(locale.LC_ALL, "")
except locale.Error as e: # pragma: no cover
# setlocale can apparently crash if locale are uninitialized
secho("Ignoring error when setting locale: {}".format(e), fg="red")

0 comments on commit 5cb1764

Please sign in to comment.