-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Issue description
Running pipenv install foo blows up with bytes being passed around where unicode is expected.
Expected result
foo is installed.
Actual result
Traceback (most recent call last):
File "/Users/Julian/.local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/cli.py", line 435, in install
selective_upgrade=selective_upgrade,
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 2046, in do_install
skip_lock=skip_lock
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 1312, in do_init
pypi_mirror=pypi_mirror,
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 1140, in do_lock
project.write_lockfile(lockfile)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/project.py", line 651, in write_lockfile
f.write(s)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/_compat.py", line 216, in func_wrapper
return func(*args, **kwargs)
TypeError: unicode argument expected, got 'str'
Steps to replicate
⊙ rm -rf ~/.local/share/virtualenvs/Foo-mHoil3nZ && mkdir Foo && cd Foo && echo "[packages]" >Pipfile && pipenv install requests Julian@Macnetic ●
Installing requests...
Collecting requests
Using cached https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.8,>=2.5 (from requests)
Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
Collecting urllib3<1.24,>=1.21.1 (from requests)
Using cached https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Installing collected packages: chardet, idna, urllib3, certifi, requests
Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23
Adding requests to Pipfile's [packages]...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Traceback (most recent call last):
File "/Users/Julian/.local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/cli.py", line 435, in install
selective_upgrade=selective_upgrade,
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 2046, in do_install
skip_lock=skip_lock
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 1312, in do_init
pypi_mirror=pypi_mirror,
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/core.py", line 1140, in do_lock
project.write_lockfile(lockfile)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/project.py", line 651, in write_lockfile
f.write(s)
File "/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/_compat.py", line 216, in func_wrapper
return func(*args, **kwargs)
TypeError: unicode argument expected, got 'str'
/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv/_compat.py:113: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/var/folders/kh/mscfrt910qb_qb8wqrz7t_7w0000gn/T/pipenv-C4owd0-requirements'>
warnings.warn(warn_message, ResourceWarning)
Instrumenting pipenv.project to just have it print the reprs of what it's trying to do shows that it's trying to call simplejson.dumps on
{u'_meta': {u'sources': [{u'url': u'https://pypi.org/simple', u'verify_ssl': True, u'name': u'pypi'}], u'requires': {}, u'hash': {u'sha256': u'70e8bf6bc774f5ca177467cab4e67d4264d0536857993326abc13ff43063bec0'}, u'pipfile-spec': 6}, u'default': {u'certifi': {'version': '==2018.4.16', 'hashes': [u'sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7', u'sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0']}, u'chardet': {'version': '==3.0.4', 'hashes': [u'sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae', u'sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691']}, u'idna': {'version': '==2.7', 'hashes': [u'sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e', u'sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16']}, u'requests': {'version': '==2.19.1', 'hashes': [u'sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1', u'sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a'], 'index': u'pypi'}, u'urllib3': {'version': '==1.23', 'hashes': [u'sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf', u'sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5'], 'markers': "python_version >= '2.6' and python_version != '3.0.*' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.3.*' and python_version < '4'"}}, u'develop': {}}
producing
'{\n "_meta": {\n "hash": {\n "sha256": "70e8bf6bc774f5ca177467cab4e67d4264d0536857993326abc13ff43063bec0"\n },\n "pipfile-spec": 6,\n "requires": {},\n "sources": [\n {\n "name": "pypi",\n "url": "https://pypi.org/simple",\n "verify_ssl": true\n }\n ]\n },\n "default": {\n "certifi": {\n "hashes": [\n "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7",\n "sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0"\n ],\n "version": "==2018.4.16"\n },\n "chardet": {\n "hashes": [\n "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",\n "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"\n ],\n "version": "==3.0.4"\n },\n "idna": {\n "hashes": [\n "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",\n "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"\n ],\n "version": "==2.7"\n },\n "requests": {\n "hashes": [\n "sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1",\n "sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a"\n ],\n "index": "pypi",\n "version": "==2.19.1"\n },\n "urllib3": {\n "hashes": [\n "sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",\n "sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"\n ],\n "markers": "python_version >= \'2.6\' and python_version != \'3.0.*\' and python_version != \'3.1.*\' and python_version != \'3.2.*\' and python_version != \'3.3.*\' and python_version < \'4\'",\n "version": "==1.23"\n }\n },\n "develop": {}\n}'
which is a str (this is Py2).
Note that things like the version key there in the dict has bytes as its value, not unicode (and despite a comment in the code there saying " # Send Unicode in to guarentee Unicode out.", which the code at least locally there seems to expect to be receiving).
(Possible aside: from just glancing at that function, it seems like it's suffering from trying to use unicode on both Py2 and Py3, rather than using native strings on Py2 and Py3, which IME is way easier to do when dealing with files.)
$ pipenv --support
Pipenv version: '2018.7.1'
Pipenv location: '/Users/Julian/.local/share/virtualenvs/pipenv/site-packages/pipenv'
Python location: '/Users/Julian/.local/share/virtualenvs/pipenv/bin/python'
Other Python installations in PATH:
-
2.7:/usr/local/bin/python2.7 -
2.7:/usr/local/bin/python2.7 -
2.7:/usr/bin/python2.7 -
3.7:/usr/local/bin/python3.7m -
3.7:/usr/local/bin/python3.7 -
2.7.13:/Users/Julian/.local/bin/python -
2.7.15:/usr/local/bin/python -
2.7.10:/usr/bin/python -
2.7.15:/Users/Julian/.local/bin/python2 -
2.7.15:/usr/local/bin/python2 -
3.7.0:/usr/local/bin/python3
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '0',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'PyPy',
'platform_release': '17.6.0',
'platform_system': 'Darwin',
'platform_version': 'Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64',
'python_full_version': '2.7.13',
'python_version': '2.7',
'sys_platform': 'darwin'}
System environment variables:
ANSIBLE_CONFIGANSIBLE_HOSTSANSIBLE_RETRY_FILES_SAVE_PATHANSIBLE_VAULT_PASSWORD_FILEAWS_CONFIG_FILEAWS_SHARED_CREDENTIALS_FILEApple_PubSub_Socket_RenderBOTO_CONFIGBROWSERBUNDLE_CONFIGCENTOS_7_AMICHEF_PATHCOLORFGBGCOLORTERMCOMMAND_MODECTAGSDELETE_ON_TERMINATIONDEVELOPMENTDISPLAYDOCKER_CONFIGEDITORGEM_HOMEGEM_SPEC_CACHEGIT_TEMPLATE_DIRGNUPGHOMEGPG_TTYHOMEHTTPIE_CONFIG_DIRINPUTRCIS_DEVELOPMENT_WORKSTATIONITERM_PROFILEITERM_SESSION_IDLANGUAGELEIN_HOMELESSHISTFILELOGNAMELS_COLORSM2_HOMEMAGNETIC_DEVELOPMENTMYSQL_HISTFILENOTMUCH_CONFIGNPM_CONFIG_USERCONFIGNVIM_TUI_ENABLE_CURSOR_SHAPEOLDPWDPATHPERL5LIBPERL_CPANM_HOMEPERL_LOCAL_LIB_ROOTPERL_MB_OPTPERL_MM_OPTPIP_CONFIG_FILEPSQL_HISTORYPWDPYTHONDONTWRITEBYTECODEPYTHONSTARTUPPYTHONWARNINGSPYTHON_TEST_RUNNERSECURITYSESSIONIDSHELLSHLVLSSH_AUTH_SOCKSTARDICT_DATA_DIRTASKRCTERMTERM_PROGRAMTERM_PROGRAM_VERSIONTERM_SESSION_IDTMPDIRTMUXTMUX_PANEUSERVIRTUALENVSXDG_CACHE_HOMEXDG_CONFIG_HOMEXDG_DATA_HOMEXDG_DESKTOP_DIRXDG_DOCUMENTS_DIRXDG_DOWNLOAD_DIRXDG_MUSIC_DIRXDG_PICTURES_DIRXDG_PUBLICSHARE_DIRXDG_TEMPLATES_DIRXDG_VIDEOS_DIRXINITRCXPC_FLAGSXPC_SERVICE_NAMEZDOTDIRZSHPLUGINS__CF_USER_TEXT_ENCODINGC_INCLUDE_PATHCPLUS_INCLUDE_PATHGOPATHLIBRARY_PATHLD_LIBRARY_PATHPKG_CONFIG_PATHNODEPATHPYTHONPATHHGRCPATHWORKON_HOMELANGLC_ALL_PIP_PYTHON_PATH
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH:/Users/Julian/.local/bin:/usr/local/bin:/usr/local/sbin:/Users/Julian/.local/share/gem/bin:/Users/Julian/Library/Application Support/go/bin:/usr/local/share/pypy:/usr/local/share/pypy3:/usr/local/share/npm/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/Julian/Library/Application Support/perl5/binSHELL:/usr/local/bin/zshEDITOR:nvimLANG:en_US.UTF-8PWD:/Users/Julian/Desktop