Poetry: AttributeError: Table object has no attribute decode in urllib parse

Created on 6 Oct 2020  ยท  2Comments  ยท  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] 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/r-pytb-auth-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โ”‚ 
Bug Triage

Most helpful comment

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 ๐Ÿ˜„ ๐ŸŽ‰ !

All 2 comments

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).?

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 ๐Ÿ˜„ ๐ŸŽ‰ !

Was this page helpful?
0 / 5 - 0 ratings