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

On Windows only: TOML parsing error: "Couldn't read config file pyproject.toml: Unescaped '\' in a string" #210

Closed
AndydeCleyre opened this issue Oct 26, 2022 · 2 comments
Labels
invalid This doesn't seem right

Comments

@AndydeCleyre
Copy link

I wrote out the details at nedbat/coveragepy#1481, as the problem was encountered during use of coveragepy in a Windows CI run. I don't have a local Windows environment handy to test with.

The meat of it is, I have this entry in a TOML file, and I think it's valid, and it parses fine on Linux and MacOS, but not Windows, using tomli 2.0.1:

install = "if [ $VIRTUAL_ENV ]; then pip install -r local-requirements.txt; else printf '%s\n' 'Please activate a venv first'; return 1; fi"

Result on Windows:

Couldn't read config file pyproject.toml: Unescaped '\' in a string (at line 62, column 21)
@hauntsaninja
Copy link
Collaborator

I unfortunately don't have a Windows machine at hand, so can't repro. One thing that would help is if you could test whether you get a failure when using tomli directly. I suspect this is related to the weird substitution stuff that coverage seems to be doing: https://github.com/nedbat/coveragepy/blob/57d86492daeca737ce4dfaff648d00dfe070b965/coverage/tomlconfig.py#L55

That is, do things fail with:

import tomli

with open("pyproject.toml", "rb") as f:
    tomli.load(f)

with open("pyproject.toml", "r", encoding="utf-8") as f:
    tomli.loads(f.read())

@AndydeCleyre
Copy link
Author

Thanks! I added your repro snippet as a nox session running with Python 3.10, and it ran successfully even on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants