-
Notifications
You must be signed in to change notification settings - Fork 0
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
RuntimeError: maximum recursion depth exceeded while calling a Python object #26
Comments
class InvalidValue(sch_interfaces.InvalidValue):
"""
InvalidValue(*args, field=None, value=None)
Adds a field specifically to carry the value that is invalid.
.. deprecated:: 1.4.0
This is now just a convenience wrapper around
:class:`zope.schema.interfaces.InvalidValue` that calls
:meth:`.zope.schema.interfaces.ValidationError.with_field_and_value`
before returning the exception. You should always catch
:class:`zope.schema.interfaces.InvalidValue`.
"""
# We can't write the syntax we want to in Python 2.
def __init__(self, *args, **kwargs):
field = kwargs.pop('field', None)
value = kwargs.pop('value', None)
if kwargs:
raise TypeError("Too many kwargs for function InvalidValue")
**super(InvalidValue, self).__init__(self, *args)**
self.with_field_and_value(field, value) |
(FYI, code snippets are introduced with three backticks and the name, not double quotes.) |
Can you provide an edited traceback? I can't reproduce any problems in a test. def test_subclass_constructor(self):
from nti.schema.interfaces import InvalidValue
class InvalidData(InvalidValue):
"""
Invalid Value
"""
i18n_message = None
def __str__(self):
if self.i18n_message:
return translate(self.i18n_message)
return super(InvalidData, self).__str__()
def doc(self):
if self.i18n_message:
return self.i18n_message
return self.__class__.__doc__
class EmailAddressInvalid(InvalidData):
"""
Invalid email address.
"""
i18n_message = "The email address you have entered is not valid."
def __init__(self, address):
super(EmailAddressInvalid, self).__init__(address, value=address)
EmailAddressInvalid('foo') |
I think the problem is in line 158 of nti.schema.interfaces.py class InvalidValue(sch_interfaces.InvalidValue):
"""
InvalidValue(*args, field=None, value=None)
Adds a field specifically to carry the value that is invalid.
.. deprecated:: 1.4.0
This is now just a convenience wrapper around
:class:`zope.schema.interfaces.InvalidValue` that calls
:meth:`.zope.schema.interfaces.ValidationError.with_field_and_value`
before returning the exception. You should always catch
:class:`zope.schema.interfaces.InvalidValue`.
"""
# We can't write the syntax we want to in Python 2.
def __init__(self, *args, **kwargs):
field = kwargs.pop('field', None)
value = kwargs.pop('value', None)
if kwargs:
raise TypeError("Too many kwargs for function InvalidValue")
super(InvalidValue, self).__init__(self, *args)
self.with_field_and_value(field, value) when calling the super constructor.. (there seems to be an extra self) |
Yeah, that would mess up the |
|
There it is. You're printing the |
Apologies ... I just saw it myself |
Fix the repr of InvalidValue. Fixes #26.
Jason,
with the latest release of nti.schema, we are getting a maximum recursion depth error.. in one of our legacy class.
we raise a EmailAddressInvalid(address) if an invalid address is given. but this generates the recursion error
I take we need to overwrite the with_field_and_value method?
Carlos
The text was updated successfully, but these errors were encountered: