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

Some Pipfiles trigger AttributeError: 'OutOfOrderTableProxy' object has no attribute '_body' #5794

Closed
flichtenheld opened this issue Jul 17, 2023 · 2 comments · Fixed by #5797
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. Type: Bug 🐛 This issue is a bug.

Comments

@flichtenheld
Copy link
Contributor

flichtenheld commented Jul 17, 2023

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues before posting! We may close your issue if it is very similar to one of them. Please be considerate, or be on your way.

Make sure to mention your debugging experience if the documented solution failed.

Issue description

When the Pipfile has a certain TOML layout, specifically a packages section and later a packages.<package> section,
which are not directly adjacent to each other, an exception is thrown when trying to write to the Pipfile.

Expected result

Pipfile is updated successfully.

Actual result

Loading .env environment variables...
Installing distro...
Resolving distro...
Adding distro to Pipfile's [packages] ...
Traceback (most recent call last):
  File "/home/flichtenheld/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 233, in install
    do_install(
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/routines/install.py", line 270, in do_install
    added, cat = project.add_package_to_pipfile(pkg_requirement, dev)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/project.py", line 994, in add_package_to_pipfile
    self.write_toml(p)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/project.py", line 813, in write_toml
    data = convert_toml_outline_tables(data, self)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/utils/toml.py", line 69, in convert_toml_outline_tables
    result = convert_tomlkit_table(table_data)
  File "/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv/utils/toml.py", line 40, in convert_tomlkit_table
    body = section._body
AttributeError: 'OutOfOrderTableProxy' object has no attribute '_body'

Steps to replicate

Given the following Pipfile (which has worked fine in older versions of pipenv):

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

[packages]
boto3 = "*"
docutils = "*"
pyyaml = "*"
python-jenkins = "*"
gitpython = "*"
click = "*"
pygments = "==2.7.2"
packaging = "*"
jmespath = "==0.10.0"
typing-extensions = "==4.1.1"
dohq-artifactory = "*"
dirhash = "*"

[pipenv]
allow_prereleases = false

[packages.atlassian-python-api]
git = "https://github.com/flichtenheld/atlassian-python-api"
editable = true
ref = "bitbucket-commits"

run a pipenv install, e.g. I wanted to run pipenv install distro.

It works if you move the "pipenv" section below the "packages.atlassian-python-api".


$ pipenv --support

Pipenv version: '2023.7.11'

Pipenv location: '/home/flichtenheld/.local/lib/python3.10/site-packages/pipenv'

Python location: '/usr/bin/python3'

OS Name: 'posix'

User pip version: '22.2.2'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.10.6',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '6.2.0-10011-tuxedo',
 'platform_system': 'Linux',
 'platform_version': '#14 SMP PREEMPT_DYNAMIC Wed Jun 28 18:29:09 UTC 2023',
 'python_full_version': '3.10.6',
 'python_version': '3.10',
 'sys_platform': 'linux'}

System environment variables:

  • SHELL
  • SESSION_MANAGER
  • QT_ACCESSIBILITY
  • COLORTERM
  • PYENV_SHELL
  • XDG_CONFIG_DIRS
  • SSH_AGENT_LAUNCHER
  • XDG_MENU_PREFIX
  • GNOME_DESKTOP_SESSION_ID
  • TERMINATOR_DBUS_PATH
  • LC_ADDRESS
  • GNOME_SHELL_SESSION_MODE
  • LC_NAME
  • SSH_AUTH_SOCK
  • GIT_PS1_SHOWDIRTYSTATE
  • AWS_DEFAULT_REGION
  • DEBFULLNAME
  • TERMINATOR_UUID
  • XMODIFIERS
  • DESKTOP_SESSION
  • LC_MONETARY
  • GTK_MODULES
  • PWD
  • LOGNAME
  • XDG_SESSION_DESKTOP
  • XDG_SESSION_TYPE
  • SYSTEMD_EXEC_PID
  • XAUTHORITY
  • GJS_DEBUG_TOPICS
  • HOME
  • USERNAME
  • IM_CONFIG_PHASE
  • LC_PAPER
  • LANG
  • LS_COLORS
  • XDG_CURRENT_DESKTOP
  • SAML2AWS_DISABLE_KEYCHAIN
  • VTE_VERSION
  • WAYLAND_DISPLAY
  • DEBEMAIL
  • INVOCATION_ID
  • TERMINATOR_DBUS_NAME
  • MANAGERPID
  • GJS_DEBUG_OUTPUT
  • GNOME_SETUP_DISPLAY
  • XDG_SESSION_CLASS
  • IBUS_DISABLE_SNOOPER
  • TERM
  • LC_IDENTIFICATION
  • USER
  • DISPLAY
  • SHLVL
  • LC_TELEPHONE
  • QT_IM_MODULE
  • LC_MEASUREMENT
  • XDG_RUNTIME_DIR
  • PYENV_ROOT
  • LC_TIME
  • EMAIL
  • JOURNAL_STREAM
  • XDG_DATA_DIRS
  • PATH
  • GDMSESSION
  • DBUS_SESSION_BUS_ADDRESS
  • GIO_LAUNCHED_DESKTOP_FILE_PID
  • GIO_LAUNCHED_DESKTOP_FILE
  • LC_NUMERIC
  • OLDPWD
  • _
  • PYTHONDONTWRITEBYTECODE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • BB_USER
  • BB_PASSWORD
  • JENKINS_USER
  • JENKINS_PASSWORD
  • AWS_PROFILE
  • JOB_NAME
  • JENKINS_URL
  • RUN_DISPLAY_URL
  • ART_API_KEY
  • BUILD_URL
  • FAST
  • SPACE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/flichtenheld/.pyenv/versions/3.11.4/bin:/home/flichtenheld/.pyenv/shims:/home/flichtenheld/.pyenv/bin:/home/flichtenheld/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /home/flichtenheld/openvpn/ovpn3-build

Contents of Pipfile ('/home/flichtenheld/openvpn/ovpn3-build/Pipfile'):

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

[packages]
boto3 = "*"
docutils = "*"
pyyaml = "*"
python-jenkins = "*"
gitpython = "*"
click = "*"
pygments = "==2.7.2"
packaging = "*"
jmespath = "==0.10.0"
typing-extensions = "==4.1.1"
dohq-artifactory = "*"
dirhash = "*"

[pipenv]
allow_prereleases = false

[packages.atlassian-python-api]
git = "https://github.com/flichtenheld/atlassian-python-api"
editable = true
ref = "bitbucket-commits"
@flichtenheld
Copy link
Contributor Author

Note: This is broken since 2023.4.20, presumably due to #5657

@matteius
Copy link
Member

It works if you move the "pipenv" section below the "packages.atlassian-python-api".

Weird ...

There is the test test_rewrite_outline_table for this case, but probably related to the above somehow.

@matteius matteius added Type: Bug 🐛 This issue is a bug. Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. labels Jul 18, 2023
flichtenheld added a commit to flichtenheld/pipenv that referenced this issue Jul 18, 2023
We get this when we have subtables that do not
directly follow their parent table.

Fixes: pypa#5794

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
flichtenheld added a commit to flichtenheld/pipenv that referenced this issue Jul 18, 2023
We get this when we have subtables that do not
directly follow their parent table.

Fixes: pypa#5794

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
matteius pushed a commit that referenced this issue Jul 19, 2023
We get this when we have subtables that do not
directly follow their parent table.

Fixes: #5794

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. Type: Bug 🐛 This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants