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

TOML parsing fails for outline tables #2960

Closed
greysteil opened this issue Oct 9, 2018 · 2 comments
Closed

TOML parsing fails for outline tables #2960

greysteil opened this issue Oct 9, 2018 · 2 comments

Comments

@greysteil
Copy link
Contributor

greysteil commented Oct 9, 2018

Issue description

When using Pipenv with outline tables like the below, parsing the Pipfile fails:

[[source]]
name = "pypi"
url = "https://pypi.python.org/simple/"
verify_ssl = true

[packages.raven]
version = "== 5.27.1"

Expected result

Successful install

Actual result

Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 308, in lock
    ensure_project(three=state.three, python=state.python, pypi_mirror=state.pypi_mirror)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 565, in ensure_project
    if project.required_python_version:
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 229, in required_python_version
    required = self.parsed_pipfile.get("requires", {}).get(
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 448, in parsed_pipfile
    parsed = self._parse_pipfile(contents)
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 480, in _parse_pipfile
    data[section][package] = toml._get_empty_inline_table(dict)
AttributeError: module 'toml' has no attribute '_get_empty_inline_table'

Steps to replicate

Call pipenv lock on the above Pipfile, using v2018.10.9


$ pipenv --support

Pipenv version: '2018.10.9'

Pipenv location: '/usr/local/lib/python3.6/site-packages/pipenv'

Python location: '/usr/local/opt/python/bin/python3.6'

Python installations found:

Error %s while executing command %s name 'WindowsError' is not defined /usr/local/bin/pythonz -c import sys; print(sys.version.split()[0])

@greysteil greysteil changed the title TOML parsing fails for inline tables TOML parsing fails for outline tables Oct 9, 2018
@prkumar
Copy link

prkumar commented Oct 9, 2018

For one, ad2d6c9 upgraded the vendored toml to 0.10.0, but toml.py (the previous version of the library) still exists in the vendor subpackage. Notably, my local build points to the new version, so "no harm, no foul", I suppose:

/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/toml/__init__.py

Second, the new version of toml doesn't include the _get_empty_inline_table function anymore, hence the AttributeError.

As @greysteil mentions in the referenced PR, a workaround is to replace outline tables with inline ones:

To do that, replace:

[packages.configparser]

version = "==3.5.0"
markers = "python_version < '3.5'"

With:

configparser = {version = "==3.5.0", markers = "python_version < '3.5'"}

prkumar added a commit to prkumar/uplink that referenced this issue Oct 9, 2018
@greysteil
Copy link
Contributor Author

Good catch @prkumar. Have put together a PR to fix at #2971.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants