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

group name character constraints #290

Closed
cckuailong opened this issue Mar 29, 2020 · 2 comments
Closed

group name character constraints #290

cckuailong opened this issue Mar 29, 2020 · 2 comments

Comments

@cckuailong
Copy link

First, Thank you for the excellent toml paser.
I have a problem here
When I parse the toml

[测试]
url = "test"

I got an error:
toml.decoder.TomlDecodeError: Invalid group name '测试'. Try quoting it.

I read the decoder.py, I find the constraints of the group name here

_groupname_re = re.compile(r'^[A-Za-z0-9_-]+$')

I don't know why constraints here. If I modify it to

_groupname_re = re.compile(r'^.*?$')

Everything is ok.

So, is it a bug or the special design.

@eksortso
Copy link

As of v0.5 of the TOML standard, which the toml module conforms to: bare keys, like unquoted table names, "may only contain ASCII letters, ASCII digits, underscores, and dashes," so what you're seeing is intentional behavior. It's not special; it's standard.

So, like the error message said, try quoting it. toml does parse this:

["测试"]
url = "test"

There is action being taken in the standard to allow more Unicode characters in bare keys, including Chinese text. But that will take some time.

@cckuailong
Copy link
Author

Thank u for reply, I didn't see the standard of toml before. Thank u

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