Skip to content

Commit

Permalink
Merge pull request #3225 from pypa/bugfix/3223
Browse files Browse the repository at this point in the history
Fix encoding issues and python discovery
  • Loading branch information
techalchemy authored Nov 16, 2018
2 parents 3ada88f + 42ae127 commit 33e0718
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/steps/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
Write-Host "##vso[task.setvariable variable=TEMP]T:\"
$env:TEMP='T:\'
Write-Host "##vso[task.setvariable variable=TMP]T:\"
$env:TEMP='T:\'
$env:TMP='T:\'
D:\.venv\Scripts\pipenv run pytest -ra --ignore=pipenv\patched --ignore=pipenv\vendor --junitxml=test-results.xml tests
displayName: Run integration tests

Expand Down
1 change: 1 addition & 0 deletions news/3223.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue with attempting to render unicode output in non-unicode locales.
1 change: 1 addition & 0 deletions news/3224.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug which could cause failures to occur when parsing python entries from global pyenv version files.
10 changes: 6 additions & 4 deletions pipenv/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import warnings
import vistir
from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp
from .utils import logging, rmtree

try:
from tempfile import _infer_return_type
Expand Down Expand Up @@ -55,6 +54,7 @@ def _infer_return_type(*args):

class finalize(object):
def __init__(self, *args, **kwargs):
from .utils import logging
logging.warn("weakref.finalize unavailable, not cleaning...")

def detach(self):
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(self, suffix="", prefix="", dir=None):

@classmethod
def _cleanup(cls, name, warn_message):
rmtree(name)
vistir.path.rmtree(name)
warnings.warn(warn_message, ResourceWarning)

def __repr__(self):
Expand All @@ -114,7 +114,7 @@ def __exit__(self, exc, value, tb):

def cleanup(self):
if self._finalizer.detach():
rmtree(self.name)
vistir.path.rmtree(self.name)


def _sanitize_params(prefix, suffix, dir):
Expand Down Expand Up @@ -365,7 +365,9 @@ def force_encoding():

UNICODE_TO_ASCII_TRANSLATION_MAP = {
8230: u"...",
8211: u"-"
8211: u"-",
10004: u"x",
10008: u"Ok"
}


Expand Down
5 changes: 3 additions & 2 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from click_didyoumean import DYMCommandCollection

from .. import environments
from ..__version__ import __version__
from .options import (
CONTEXT_SETTINGS, PipenvGroup, code_option, common_options, deploy_option,
Expand Down Expand Up @@ -115,6 +114,7 @@ def cli(
return 1
if envs:
echo("The following environment variables can be set, to do various things:\n")
from .. import environments
for key in environments.__dict__:
if key.startswith("PIPENV"):
echo(" - {0}".format(crayons.normal(key, bold=True)))
Expand Down Expand Up @@ -161,7 +161,8 @@ def cli(
# --rm was passed…
elif rm:
# Abort if --system (or running in a virtualenv).
if environments.PIPENV_USE_SYSTEM:
from ..environments import PIPENV_USE_SYSTEM
if PIPENV_USE_SYSTEM:
echo(
crayons.red(
"You are attempting to remove a virtualenv that "
Expand Down
7 changes: 4 additions & 3 deletions pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import os
import sys
from appdirs import user_cache_dir
from .vendor.vistir.misc import fs_str, to_text
from .vendor.vistir.misc import fs_str
from ._compat import fix_utf8


# HACK: avoid resolver.py uses the wrong byte code files.
Expand Down Expand Up @@ -275,6 +276,6 @@ def is_quiet(threshold=-1):
return PIPENV_VERBOSITY <= threshold


PIPENV_SPINNER_FAIL_TEXT = fs_str(to_text(u"✘ {0}")) if not PIPENV_HIDE_EMOJIS else ("{0}")
PIPENV_SPINNER_FAIL_TEXT = fix_utf8(u"✘ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")

PIPENV_SPINNER_OK_TEXT = fs_str(to_text(u"✔ {0}")) if not PIPENV_HIDE_EMOJIS else ("{0}")
PIPENV_SPINNER_OK_TEXT = fix_utf8(u"✔ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")
4 changes: 2 additions & 2 deletions pipenv/vendor/pythonfinder/models/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def get_version_order(self):
]
versions = {v.name: v for v in version_paths}
if self.is_pyenv:
version_order = [versions[v] for v in parse_pyenv_version_order()]
version_order = [versions[v] for v in parse_pyenv_version_order() if v in versions]
elif self.is_asdf:
version_order = [versions[v] for v in parse_asdf_version_order()]
version_order = [versions[v] for v in parse_asdf_version_order() if v in versions]
for version in version_order:
version_paths.remove(version)
if version_order:
Expand Down

0 comments on commit 33e0718

Please sign in to comment.