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

Passing a string into zope.interface.implements causes infinite recursion #4

Open
tseaver opened this issue Jan 11, 2015 · 2 comments
Labels

Comments

@tseaver
Copy link
Member

tseaver commented Jan 11, 2015

In https://bugs.launchpad.net/zope.interface/+bug/113672, @faassen reported

We know you're not supposed to pass a stirng into zope.interface.implements, but try the following:

>>> from zope.interface import implements
>>> class Foo(object):
... implements('foo')

the prompt will hang for a while. Then we get this error:

File "/home/faassen/buildout/grok-eggs/eggs/tmpxXgh8b/zope.interface-3.4.0a1-py2.4-linux-i686.egg/zope/interface/declarations.py", line 1370, in _normalizeargs
File "/home/faassen/buildout/grok-eggs/eggs/tmpxXgh8b/zope.interface-3.4.0a1-py2.4-linux-i686.egg/zope/interface/declarations.py", line 1370, in _normalizeargs
File "/home/faassen/buildout/grok-eggs/eggs/tmpxXgh8b/zope.interface-3.4.0a1-py2.4-linux-i686.egg/zope/interface/declarations.py", line 1366, in _normalizeargs
RuntimeError: maximum recursion depth exceeded in cmp

Perhaps something can be done to prevent this infinite recursion. Not urgent, but would be nice as this is rather surprising.

@tseaver tseaver added the bug label Jan 11, 2015
@tseaver
Copy link
Member Author

tseaver commented Jan 11, 2015

Note that the more modern @implementer idiom fails similarly.

@jamadden
Copy link
Member

jamadden commented Feb 6, 2020

The variety of things that _normalizeargs accepts makes this a complicated problem, especially since it's involved at import time and we don't want to slow that down. Perhaps a simple assert not isinstance(sequence, str) handles this well enough?

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

No branches or pull requests

2 participants