rstcheck / rstcheck-core

Core library behind rstcheck.
http://rstcheck-core.rtfd.io/
MIT License
4 stars 8 forks source link

[Bug]: SyntaxError: source code string cannot contain null bytes #97

Closed giampaolo closed 4 months ago

giampaolo commented 7 months ago

To Dos

Example Code (rst)

git ls-files '*.rst' | xargs rstcheck --config=pyproject.toml

...against psutil code base.

Relevant log output

2024-04-06T19:52:07.4410323Z make lint-rst
2024-04-06T19:52:07.4425054Z make[1]: Entering directory '/home/runner/work/psutil/psutil'
2024-04-06T19:52:07.8247347Z Traceback (most recent call last):
2024-04-06T19:52:07.8257753Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/bin/rstcheck", line 5, in <module>
2024-04-06T19:52:07.8258871Z     from rstcheck._cli import main
2024-04-06T19:52:07.8260727Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/rstcheck/_cli.py", line 11, in <module>
2024-04-06T19:52:07.8263628Z     from rstcheck_core import _extras, config as config_mod, runner
2024-04-06T19:52:07.8265684Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/rstcheck_core/runner.py", line 13, in <module>
2024-04-06T19:52:07.8267086Z     from . import _sphinx, checker, config, types
2024-04-06T19:52:07.8268090Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/rstcheck_core/checker.py", line 7, in <module>
2024-04-06T19:52:07.8268985Z     import doctest
2024-04-06T19:52:07.8269417Z SyntaxError: source code string cannot contain null bytes

Description

Hi. I have rstcheck integrated as part of psutil CI pipeline. It suddenly started failing due to SyntaxError: source code string cannot contain null bytes https://github.com/giampaolo/psutil/actions/runs/8583440387/job/23522647404

Operating System

Linux

Operating System Details

No response

Python Version

3.12

rstcheck Version

6.2.1 (CLI), 1.2.1 (core)

Additional Context

No response

Cielquan commented 4 months ago

Sorry for the long silence. I hope I can take a deeper look at this soon.

Cielquan commented 4 months ago

On a first glace this issue seems to come from cPython and not rstcheck_core/rstcheck. The error happens when doctest is imported, which is part of the standard lib: https://github.com/python/cpython/blob/v3.12.2/Lib/doctest.py. But I cannot imagine that a module is shipped which errors on import.

Have to check if I can reproduce and if 3.12.3 or 3.12.4 fixes this.

Cielquan commented 4 months ago

Seems like the issue solved itself. I took a look at the latest CI runs in your repo.