Return whether the given writable file-like object requires Unicode to be written to it.
(x)
| 520 | |
| 521 | |
| 522 | def file_requires_unicode(x): |
| 523 | """ |
| 524 | Return whether the given writable file-like object requires Unicode to be |
| 525 | written to it. |
| 526 | """ |
| 527 | try: |
| 528 | x.write(b'') |
| 529 | except TypeError: |
| 530 | return True |
| 531 | else: |
| 532 | return False |
| 533 | |
| 534 | |
| 535 | def to_filehandle(fname, flag='r', return_opened=False, encoding=None): |
no test coverage detected
searching dependent graphs…