Show More
@@ -1024,7 +1024,11 b' class Unicode(TraitType):' | |||
|
1024 | 1024 | if isinstance(value, py3compat.unicode_type): |
|
1025 | 1025 | return value |
|
1026 | 1026 | if isinstance(value, bytes): |
|
1027 | return py3compat.unicode_type(value) | |
|
1027 | try: | |
|
1028 | return value.decode('ascii', 'strict') | |
|
1029 | except UnicodeDecodeError: | |
|
1030 | msg = "Could not decode {!r} for unicode trait '{}' of {} instance." | |
|
1031 | raise TraitError(msg.format(value, self.name, class_of(obj))) | |
|
1028 | 1032 | self.error(obj, value) |
|
1029 | 1033 | |
|
1030 | 1034 |
General Comments 0
You need to be logged in to leave comments.
Login now