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

pdm always crashes on a poetry project with names including comma #2665

Closed
1 task done
alsrbbk opened this issue Mar 5, 2024 · 6 comments · Fixed by #2743 or j178/pdm#1
Closed
1 task done

pdm always crashes on a poetry project with names including comma #2665

alsrbbk opened this issue Mar 5, 2024 · 6 comments · Fixed by #2743 or j178/pdm#1
Labels
🐛 bug Something isn't working

Comments

@alsrbbk
Copy link

alsrbbk commented Mar 5, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

On my test project with pyproject.toml of which name contains any comma(,), e.g.:

[tool.poetry]
name = "test"
version = "1.0.0"
descrption = "test project"
authors = ["Min-Gyu, Kim <[email protected]>"]

[tool.poetry.dependencies]
python = "~3.11.6"

pdm command-line execution always crashes.

Actual behavior

I got a main error when executing any CLI commands.

It seems to be due to a regex, unmatching commas.

Example as follows:

$ pdm
Traceback (most recent call last):
  File "/home/alsrbbk/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 288, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 181, in main
    args = self._get_cli_args(args, obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 163, in _get_cli_args
    config = project.pyproject.settings.get("options", {})
             ^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.pyenv/versions/3.11.6/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/project/core.py", line 112, in pyproject
    return PyProject(self.root / self.PYPROJECT_FILENAME, ui=self.core.ui)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/project/toml_file.py", line 18, in __init__
    self._data = self.read()
                 ^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/project/project_file.py", line 33, in read
    metadata, settings = converter.convert(None, self._path, None)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/formats/poetry.py", line 213, in convert
    return converter.convert()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/alsrbbk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/formats/base.py", line 85, in convert
    raise MetaConvertError(errors, data=self._data, settings=self.settings)
pdm.formats.base.MetaConvertError: 
authors: 'NoneType' object has no attribute 'groupdict'

Expected behavior

$ pdm execution succeeded and show a help page.

Environment Information

(cannot launch CLI)

@alsrbbk alsrbbk added the 🐛 bug Something isn't working label Mar 5, 2024
@frostming
Copy link
Collaborator

According to the specification the name can't contain commas, if I interpret it correctly

@dimbleby
Copy link

dimbleby commented Mar 6, 2024

I assume the specification has very little to say about what the tool.poetry part of the file is allowed to contain

core metadata certainly seems to allow commas in the "author" field per the example https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata-author

@pawamoy
Copy link
Contributor

pawamoy commented Mar 6, 2024

Oh, so PDM reads and tries to convert the Poetry table on the fly 🤔? I thought this would only happen when "importing" a project.

Regarding the spec:

  • PEP 621 does say that commas are forbidden in author/maintainer fields, probably because "Multiple values should be separated by commas".
  • I'm not sure to understand why one would separate multiple values with commas when the field itself is an array.
  • Furthermore, the link posted by @dimbleby shows that commas are accepted in the core metadata.
  • The PEP is a marked as historical document, and the canonical spec is now https://packaging.python.org/en/latest/specifications/pyproject-toml/#pyproject-toml-spec, but it just repeats the same thing as the PEP for the author field.

Maybe worth asking on discuss.python.org.

@pawamoy
Copy link
Contributor

pawamoy commented Mar 6, 2024

@alsrbbk
Copy link
Author

alsrbbk commented Mar 7, 2024

An email name needs to be non-comma according to the spec., so I have to change my name.

As @pawamoy said, PDM should not be crashed on a poetry project even if it contains an invalid name before any convertion. Maybe it can warn us to correct the name format. I had to spend a bit of time to figure out the reason.

@rooterkyberian
Copy link
Contributor

rooterkyberian commented Mar 29, 2024

This topic is related to #2651 and to state it clearly:
, in author name is most certainly supported in the spec (see https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata-author ), but is just bugged in pdm. It work fine with other tools and PyPI.

As for how it is possible for commas to be supported in name, if they are used for seperating values as well, the answer lies in https://packaging.python.org/en/latest/specifications/core-metadata/#author-email -> RFC-822, assumes use of quotes to escape them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
5 participants