Skip to content

Commit

Permalink
Making tests work wirh all versions of python is harder than one migh…
Browse files Browse the repository at this point in the history
…t think.
  • Loading branch information
gogobd committed Feb 14, 2020
1 parent 8dc845f commit 173a19e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/zope/schema/_bootstrapfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,16 @@ def fromUnicode(self, value):
...
zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: (u'foo spam', '')
"""
if not PY2:
unicode = str
if isinstance(value, unicode):
try:
text_type = unicode
except NameError:
text_type = str
if isinstance(value, text_type):
if self.unicode_normalization:
value = unicodedata.normalize(self.unicode_normalization, value)
self.validate(value)
return value


class TextLine(Text):
"""A text field with no newlines."""
Expand Down

0 comments on commit 173a19e

Please sign in to comment.