Show More
@@ -31,12 +31,11 b' class FilenameExtension(TraitType):' | |||||
31 | info_text = 'a filename extension, beginning with a dot' |
|
31 | info_text = 'a filename extension, beginning with a dot' | |
32 |
|
32 | |||
33 | def validate(self, obj, value): |
|
33 | def validate(self, obj, value): | |
34 | if isinstance(value, bytes): |
|
34 | try: | |
35 | try: |
|
35 | value = py3compat.cast_bytes_py2(value) | |
36 | value = value.decode('ascii', 'strict') |
|
36 | except UnicodeDecodeError: | |
37 | except UnicodeDecodeError: |
|
37 | msg = "Could not decode {!r} for extension trait '{}'." | |
38 | msg = "Could not decode {!r} for extension trait '{}'." |
|
38 | raise TraitError(msg.format(value, self.name)) | |
39 | raise TraitError(msg.format(value, self.name)) |
|
|||
40 |
|
39 | |||
41 | if not value.startswith('.'): |
|
40 | if not value.startswith('.'): | |
42 | msg = "Extension trait '{}' does not begin with a dot: {!r}" |
|
41 | msg = "Extension trait '{}' does not begin with a dot: {!r}" |
General Comments 0
You need to be logged in to leave comments.
Login now