(self, str_in, *args, **kwargs)
| 22 | def _takes_ascii(f): |
| 23 | @wraps(f) |
| 24 | def func(self, str_in, *args, **kwargs): |
| 25 | # If it's a stream, read the whole thing |
| 26 | str_in = getattr(str_in, 'read', lambda: str_in)() |
| 27 | |
| 28 | # If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII |
| 29 | if isinstance(str_in, six.text_type): |
| 30 | # ASCII is the same in UTF-8 |
| 31 | try: |
| 32 | str_in = str_in.encode('ascii') |
| 33 | except UnicodeEncodeError as e: |
| 34 | msg = 'ISO-8601 strings should contain only ASCII characters' |
| 35 | six.raise_from(ValueError(msg), e) |
| 36 | |
| 37 | return f(self, str_in, *args, **kwargs) |
| 38 | |
| 39 | return func |
| 40 |
no outgoing calls