Skip to content

Remove unused cgitb import from live imaging example (Python 3.13) - #70

Open
kasparovabi wants to merge 2 commits into
directelectron:mainfrom
kasparovabi:chore/py313-unused-cgitb
Open

kasparovabi wants to merge 2 commits into
directelectron:mainfrom
kasparovabi:chore/py313-unused-cgitb

Conversation

@kasparovabi

Copy link
Copy Markdown

examples/live_imaging/taking_an_image_every_minute.py starts with from cgitb import enable. cgitb was removed from the standard library in Python 3.13 (PEP 594, What's New in 3.13), and the package declares 3.13 support in pyproject.toml, so on 3.13 the example stops before it reaches deapi:

Traceback (most recent call last):
  File "/r/examples/live_imaging/taking_an_image_every_minute.py", line 14, in <module>
    from cgitb import enable
ModuleNotFoundError: No module named 'cgitb'

The imported name is never used. The enable="Off" on line 40 is the keyword argument of Client.scan, so the import can go without a replacement.

Python 3.13.17
before ModuleNotFoundError: No module named 'cgitb' at line 14
after runs against deapi/simulated_server/initialize_server.py 13240, prints "Taking image 1..5 of 10", exit 0

On 3.12 the import still works but raises a DeprecationWarning that names 3.13 as the removal release.

The docs build uses Python 3.11, so the gallery itself was not affected. I added a doc fragment in upcoming_changes/.

Happy to adjust this or close it if it does not fit the project.

cgitb was removed from the standard library in Python 3.13 (PEP 594), so
the example stopped at import with ModuleNotFoundError. The imported name
was never used; enable="Off" further down is a keyword argument to
Client.scan.

This branch has not been deployed

No deployments
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.

1 participant