(self, obj: t.Any, value: t.Any)
| 2951 | ... |
| 2952 | |
| 2953 | def validate(self, obj: t.Any, value: t.Any) -> G: |
| 2954 | if isinstance(value, str): |
| 2955 | return value # type:ignore[return-value] |
| 2956 | if isinstance(value, bytes): |
| 2957 | try: |
| 2958 | return value.decode("ascii", "strict") # type:ignore[return-value] |
| 2959 | except UnicodeDecodeError as e: |
| 2960 | msg = "Could not decode {!r} for unicode trait '{}' of {} instance." |
| 2961 | raise TraitError(msg.format(value, self.name, class_of(obj))) from e |
| 2962 | self.error(obj, value) |
| 2963 | |
| 2964 | def from_string(self, s: str) -> G: |
| 2965 | if self.allow_none and s == "None": |
nothing calls this directly
no test coverage detected