Skip to content

Commit

Permalink
Do not allow empty identifiers in PythonIdentifier.
Browse files Browse the repository at this point in the history
This restores the previous behaviour of validate(); fromUnicode() previously did no validation at all.
  • Loading branch information
jamadden committed Sep 24, 2018
1 parent 36677d1 commit d315d89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/api/fields.rst
Expand Up @@ -43,7 +43,7 @@
Validation Error '3foo'
Validation Error 'foo:'
Validation Error '\\'
''
Validation Error ''

.. autoclass:: GlobalObject
:members:
Expand Down
7 changes: 6 additions & 1 deletion src/zope/configuration/fields.py
Expand Up @@ -35,9 +35,14 @@

class PythonIdentifier(schema_PythonIdentifier):
"""
This class is deprecated, prefer `zope.schema.PythonIdentifier`.
This class is like `zope.schema.PythonIdentifier`, but does not allow empty strings.
"""

def _validate(self, value):
super(PythonIdentifier, self)._validate(value)
if not value:
raise ValidationError(value).with_field_and_value(self, value)


@implementer(IFromUnicode)
class GlobalObject(Field):
Expand Down

0 comments on commit d315d89

Please sign in to comment.