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

PYTHONOPTIMIZE=2 breaks zope.component.Interface #67

Closed
teythoon opened this issue Jan 2, 2023 · 2 comments · Fixed by #69
Closed

PYTHONOPTIMIZE=2 breaks zope.component.Interface #67

teythoon opened this issue Jan 2, 2023 · 2 comments · Fixed by #69

Comments

@teythoon
Copy link

teythoon commented Jan 2, 2023

What I did:

Trying to reduce the memory consumption of Mailman3 which uses Zope. Turns out that dropping docstrings reduces the memory usage by around 10%, which amounts to ~100MB on 64 bit Python. However, this breaks in Zope.

% python -c "from zope.component import Interface"
% PYTHONOPTIMIZE=1 python -c "from zope.component import Interface"
% PYTHONOPTIMIZE=2 python -c "from zope.component import Interface"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/venv/lib/python3.10/site-packages/zope/component/__init__.py", line 37, in <module>
    from zope.component.globalregistry import getGlobalSiteManager
  File "/tmp/venv/lib/python3.10/site-packages/zope/component/globalregistry.py", line 63, in <module>
    def getGlobalSiteManager():
  File "/tmp/venv/lib/python3.10/site-packages/zope/component/interfaces.py", line 378, in inherits_arch_docs
    return _inherits_docs(func, IComponentArchitecture)
  File "/tmp/venv/lib/python3.10/site-packages/zope/component/interfaces.py", line 370, in _inherits_docs
    doc += "\n        .. seealso::"
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

What I expect to happen:

This not to crash.

What actually happened:

Crash trying to amend the docstring which is None under PYTHONOPTIMIZE=2.

What version of Python and Zope/Addons I am using:

% uname -a
Linux thinkbox 6.0.0-6-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.0.12-1 (2022-12-09) x86_64 GNU/Linux
% python --version
Python 3.10.9
% pip list zope.component
Package        Version
-------------- -------
pip            22.3.1
setuptools     65.5.0
wheel          0.38.4
zope.component 5.0.1
zope.event     4.6
zope.hookable  5.4
zope.interface 5.5.2
teythoon added a commit to teythoon/zope.component that referenced this issue Jan 2, 2023
When executing under PYTHONOPTIMIZE=2, the docstrings are dropped.
This saves a significant amount of space on the heap.

Fixes zopefoundation#67.
teythoon added a commit to teythoon/zope.component that referenced this issue Jan 2, 2023
When executing under PYTHONOPTIMIZE=2, the docstrings are dropped.
This saves a significant amount of space on the heap.

Fixes zopefoundation#67.
@dataflake
Copy link
Member

I just released zope.component version 5.1.0 with the fix.

@teythoon
Copy link
Author

teythoon commented Jan 4, 2023

Thanks for the quick fix and release!

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