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

AttributeError: Table object has no attribute decode in urllib parse #3104

Closed
3 tasks done
pawamoy opened this issue Oct 6, 2020 · 6 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@pawamoy
Copy link

pawamoy commented Oct 6, 2020

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Red Hat Enterprise Linux Server 7.6 (Maipo)
  • Poetry version: 1.1.1 and 1.1.0
  • Python version: 3.6.12 (same with 3.6.11)

RHEL is known for packaging custom versions of Python, but in this case I installed Python with pyenv, so it should be the main, official Python version (or maybe pyenv installs the RHEL version as well? I doubt it)

Issue

Poetry 1.1.0rc1, 1.1.0b4 and 1.1.0b3 work fine.

Poetry 1.1.1 and 1.1.0 fail with an AttributeError: 'Table' object has no attribute 'decode' in urllib/parse.py

Poetry 1.1.1:

$ poetry lock -vv

  Stack trace:

  16  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/console_application.py:131 in run
      status_code = command.handle(parsed_args, io)

  15  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:120 in handle
      status_code = self._do_handle(args, io)

  14  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:163 in _do_handle
      self._dispatcher.dispatch(PRE_HANDLE, event)

  13  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
      self._do_dispatch(listeners, event_name, event)

  12  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
      listener(event, event_name, self)

  11  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/config/application_config.py:116 in set_env
      poetry = command.poetry

  10  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/commands/command.py:10 in poetry
      return self.application.poetry

   9  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/application.py:69 in poetry
      self._poetry = Factory().create_poetry(Path.cwd())

   8  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/factory.py:74 in create_poetry
      repository = self.create_legacy_repository(source, config)

   7  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/factory.py:158 in create_legacy_repository
      client_cert=get_client_cert(auth_config, name),

   6  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/repositories/legacy_repository.py:195 in __init__
      username, password = self._authenticator.get_credentials_for_url(self._url)

   5  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/authenticator.py:118 in get_credentials_for_url
      credentials = self._get_credentials_for_netloc_from_config(netloc)

   4  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/authenticator.py:159 in _get_credentials_for_netloc_from_config
      parsed_url = urlparse.urlsplit(url)

   3  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:418 in urlsplit
      url, scheme, _coerce_result = _coerce_args(url, scheme)

   2  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:123 in _coerce_args
      return _decode_args(args) + (_encode_result,)

   1  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:107 in _decode_args
      return tuple(x.decode(encoding, errors) if x else '' for x in args)

  AttributeError

  'Table' object has no attribute 'decode'

  at ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:107 in <genexpr>
       103│     return obj.encode(encoding, errors)
       104│ 
       105│ def _decode_args(args, encoding=_implicit_encoding,
       106│                        errors=_implicit_errors):
    →  107│     return tuple(x.decode(encoding, errors) if x else '' for x in args)
       108│ 
       109│ def _coerce_args(*args):
       110│     # Invokes decode if necessary to create str args
       111│     # and returns the coerced inputs along with

Poetry 1.1.0:

$ poetry lock -vv

  Stack trace:

  16  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/console_application.py:131 in run
      status_code = command.handle(parsed_args, io)

  15  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:120 in handle
      status_code = self._do_handle(args, io)

  14  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:163 in _do_handle
      self._dispatcher.dispatch(PRE_HANDLE, event)

  13  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
      self._do_dispatch(listeners, event_name, event)

  12  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
      listener(event, event_name, self)

  11  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/config/application_config.py:116 in set_env
      poetry = command.poetry

  10  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/commands/command.py:10 in poetry
      return self.application.poetry

   9  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/application.py:69 in poetry
      self._poetry = Factory().create_poetry(Path.cwd())

   8  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/factory.py:72 in create_poetry
      repository = self.create_legacy_repository(source, config)

   7  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/factory.py:156 in create_legacy_repository
      client_cert=get_client_cert(auth_config, name),

   6  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/repositories/legacy_repository.py:195 in __init__
      username, password = self._authenticator.get_credentials_for_url(self._url)

   5  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/authenticator.py:118 in get_credentials_for_url
      credentials = self._get_credentials_for_netloc_from_config(netloc)

   4  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/authenticator.py:159 in _get_credentials_for_netloc_from_config
      parsed_url = urlparse.urlsplit(url)

   3  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:418 in urlsplit
      url, scheme, _coerce_result = _coerce_args(url, scheme)

   2  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:123 in _coerce_args
      return _decode_args(args) + (_encode_result,)

   1  ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:107 in _decode_args
      return tuple(x.decode(encoding, errors) if x else '' for x in args)

  AttributeError

  'Table' object has no attribute 'decode'

  at ~/.pyenv/versions/3.6.12/lib/python3.6/urllib/parse.py:107 in <genexpr>
       103│     return obj.encode(encoding, errors)
       104│ 
       105│ def _decode_args(args, encoding=_implicit_encoding,
       106│                        errors=_implicit_errors):
    →  107│     return tuple(x.decode(encoding, errors) if x else '' for x in args)
       108│ 
       109│ def _coerce_args(*args):
       110│     # Invokes decode if necessary to create str args
       111│     # and returns the coerced inputs along with

Poetry 1.1.0b2 (but that's another story):

$ poetry lock -vv
Using virtualenv: /home/ldap/mazzucti/.cache/pypoetry/virtualenvs/project-xK4FtSux-py3.6

  Stack trace:

  8  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/console_application.py:131 in run
     status_code = command.handle(parsed_args, io)

  7  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:120 in handle
     status_code = self._do_handle(args, io)

  6  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/command/command.py:163 in _do_handle
     self._dispatcher.dispatch(PRE_HANDLE, event)

  5  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
     self._do_dispatch(listeners, event_name, event)

  4  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
     listener(event, event_name, self)

  3  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/console/config/application_config.py:147 in set_installer
     poetry.config,

  2  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/installer.py:65 in __init__
     installed = self._get_installed()

  1  ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/installation/installer.py:531 in _get_installed
     return InstalledRepository.load(self._env)

  AttributeError

  can't set attribute

  at ~/.local/pipx/venvs/poetry/lib/python3.6/site-packages/poetry/repositories/installed_repository.py:113 in load
      109│                     package.source_type = "git"
      110│                     package.source_url = url
      111│                     package.source_reference = revision
      112│                 except ValueError:
    → 113│                     package.source_type = "directory"
      114│                     package.source_url = str(path.parent)
      115│ 
      116│         return repo
      117│ 
@pawamoy pawamoy added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 6, 2020
@abn
Copy link
Member

abn commented Oct 8, 2020

Does this happen only when locking?

Can you please post the source configuration from your pyproject.toml as well as the output of poetry config repositories (sanitised ofcourse).?

@pawamoy
Copy link
Author

pawamoy commented Oct 9, 2020

OK I think I know why it happens. I had some left overs in Poetry's global config:

[repositories.private_pypi_a]
[repositories.private_pypi_a.url]
url = "https://some_private_pypi_a_url"

Newest repositories were added like this:

[repositories.private_pypi_b]
url = "https://some_private_pypi_b_url"

After removing the left-overs, everything works fine, in previously mentioned versions: 1.1.0, 1.1.1, and 1.1.2.

Thank you for pointing/forcing me to check my global Poetry config @abn, it solved the issue for me 😄 🎉 !

@nschrader
Copy link

Still having this issue with Poetry 1.2.0a2
Ran

> poetry config repositories.xyz.url "http://python.repo/an/index/"

and ended up with

> cat ~/.config/pypoetry/config.toml
[repositories]
[repositories.xyz]
[repositories.xyz.url]
url = "http://python.repo/an/index/"

so that

> poetry config --list

  AttributeError

  'Table' object has no attribute 'decode'

  at /usr/lib/python3.8/urllib/parse.py:108 in <genexpr>
       104│     return obj.encode(encoding, errors)
       105│ 
       106│ def _decode_args(args, encoding=_implicit_encoding,
       107│                        errors=_implicit_errors):
    →  108│     return tuple(x.decode(encoding, errors) if x else '' for x in args)
       109│ 
       110│ def _coerce_args(*args):
       111│     # Invokes decode if necessary to create str args
       112│     # and returns the coerced inputs along with

After removing [repositories.xyz.url] everything is alright

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@MorganLindqvist
Copy link

Hi,

Ran into the same issue. For me it worked when changing the command from

poetry config repositories.xyz.url "http://python.repo/an/index/"

To

poetry config repositories.xyz "http://python.repo/an/index/"

@farhanhubble
Copy link

Still an issue in poetry 1.6.1. It seems there are a million ways to nuke poetry config and the parsers are just not able to provide meaningful errors.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

6 participants