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

copyright accepts different values when SOURCE_DATE_EPOCH is/is not in the environment #11913

Closed
loqs opened this issue Jan 24, 2024 · 2 comments · Fixed by #11914
Closed

copyright accepts different values when SOURCE_DATE_EPOCH is/is not in the environment #11913

loqs opened this issue Jan 24, 2024 · 2 comments · Fixed by #11914

Comments

@loqs
Copy link

loqs commented Jan 24, 2024

Describe the bug

Docs say the copyright comes with a form of: '2008, Author Name'.
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-copyright

However, some projects do not define the author and up until Sphinx 7.1.1 this was an input that successfully generated the pages: copyright = "2012-2023"
For environments where SOURCE_DATE_EPOCH is not set, which is possibly the most often encountered use case, this still works. The value of the copyright key is taken in the exact form as it's defined in conf.py.

If SOURCE_DATE_EPOCH is set the value read from conf.py is processed via the logic introduced here: 8452300

Producing:

Extension error (sphinx.config):
Handler <function correct_copyright_year at 0x77f66be49080> for event 'config-inited' threw an exception (exception: string index out of range)

This behavior is inconsistent.

How to Reproduce

change tests/roots/test-copyright-multiline/conf.py to:

copyright = (
    '2006',
    '2006-2009',
    '2006-2009, Alice',
    '2010-2013, Bob',
    '2014-2017, Charlie',
    '2018-2021, David',
    '2022-2025, Eve',
)
html_theme = 'basic'

Run tox tests.
Test without SOURCE_DATE_EPOCH set will pass while the ones with it will fail.

Environment Information

Sphinx 7.2.6

Sphinx extensions

No response

Additional context

Very similar issue #11627
Project using the '2012-2023' format https://github.com/Flask-Middleware/flask-security https://github.com/Flask-Middleware/flask-security/blob/5.3.3/docs/conf.py#L53

@jayaddison
Copy link
Contributor

This bug originates from this line of code:

if copyright_line[5:9].isdigit() and copyright_line[9] in ' ,':

We make a direct array index access to copyright_line[9], that in the example provided (2012-2023) is outside-of-range.

Personally I don't love automatically rewriting copyright entries; but we shouldn't break existing documentation builds, so I have a fix coming up for this.

@loqs
Copy link
Author

loqs commented Jan 25, 2024

Thank you for the fast response and fix. I have tested #11914 and it resolves the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants