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

Failure to produce documentation with python3.11. #1450

Merged
merged 3 commits into from
Jan 5, 2023

Conversation

emollier
Copy link
Contributor

@emollier emollier commented Jan 4, 2023

In Debian Bug#1027936, Adrian Bunk noticed that the documentation failed to be produced with python3.11 with the following symptom:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 350, in eval_config_file
    exec(code, namespace)
  File "/<<PKGBUILDDIR>>/docs_sphinx/conf.py", line 71, in <module>
    generate_examples.main(root_dir, target_dir)
  File "/<<PKGBUILDDIR>>/debian/tmp/usr/lib/python3.11/dist-packages/brian2/sphinxext/generate_examples.py", line 72, in main
    with codecs.open(fname, 'rU', encoding='utf-8') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen codecs>", line 906, in open
ValueError: invalid mode: 'rUb'

This patch removes a couple of uses of unified newline "open" invocations, which have no effect since the first version of python3. This may cause changes of behavior with python2, but this interpreter is unmaintained since 2020.

Signed-off-by: Étienne Mollier emollier@debian.org

emollier and others added 3 commits January 4, 2023 22:44
In [Debian Bug#1027936], Adrian Bunk noticed that the documentation
failed to be produced with python3.11 with the following symptom:

	Traceback (most recent call last):
	  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 350, in eval_config_file
	    exec(code, namespace)
	  File "/<<PKGBUILDDIR>>/docs_sphinx/conf.py", line 71, in <module>
	    generate_examples.main(root_dir, target_dir)
	  File "/<<PKGBUILDDIR>>/debian/tmp/usr/lib/python3.11/dist-packages/brian2/sphinxext/generate_examples.py", line 72, in main
	    with codecs.open(fname, 'rU', encoding='utf-8') as f:
	         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "<frozen codecs>", line 906, in open
	ValueError: invalid mode: 'rUb'

This patch removes a couple of uses of unified newline "open"
invocations, which have no effect since the first version of python3.
This may cause changes of behavior with python2, but this interpreter
is unmaintained since 2020.

[Debian Bug#1027936]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1027936

Signed-off-by: Étienne Mollier <emollier@debian.org>
@mstimberg
Copy link
Member

Many thanks for the report and fix. I was a bit surprised that we still had the U flags in there, since I thought that the pyupgrade tool had taken care of this. It turns out that it only did for open calls, not for codecs.open. I think we only used codecs.open here since we needed to enforce utf-8, but with modern Python versions, we can also do this with open. I therefore commited a change that gets rid of the use of codecs here. I also updated our test suite so that it tests building the HTML docs with the latest Python version – hopefully that should avoid this type of issue in the future. Thanks again, I'll go ahead with the merge as soon as the tests have passed.

@mstimberg mstimberg merged commit 9e2906a into brian-team:master Jan 5, 2023
@emollier emollier deleted the python3.11 branch January 5, 2023 21:16
@emollier
Copy link
Contributor Author

emollier commented Jan 5, 2023

Hi Marcel,
Great, glad this helped!
Have a nice day, :)
Étienne.

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

Successfully merging this pull request may close these issues.

None yet

2 participants