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

4.2.0 crashes upon import when PYTHONOPTIMIZE is set to 2 or larger #321

Closed
ntamas opened this issue Apr 24, 2024 · 2 comments
Closed

4.2.0 crashes upon import when PYTHONOPTIMIZE is set to 2 or larger #321

ntamas opened this issue Apr 24, 2024 · 2 comments
Assignees
Milestone

Comments

@ntamas
Copy link

ntamas commented Apr 24, 2024

Steps to reproduce:

PYTHONOPTIMIZE=2 venv/bin/python3
Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bitstring
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]/venv/lib/python3.12/site-packages/bitstring/__init__.py", line 305, in <module>
    Bits.__doc__ = Bits.__doc__.replace('[GENERATED_PROPERTY_DESCRIPTIONS]', property_docstring)
                   ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

This is because starting Pyhton with PYTHONOPTIMIZE=2 or with the -O0 argument strips away the docstrings so Bits.__doc__ becomes None.

@scott-griffiths
Copy link
Owner

Ah, that's not something I had considered!

I've reproduced it and will get a fix in for version 4.2.1 shortly.

Thank you for the bug report.

@scott-griffiths
Copy link
Owner

This should be working again the 4.2.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants