(data)
| 727 | return |
| 728 | |
| 729 | def write(data): |
| 730 | if not isinstance(data, basestring): |
| 731 | data = str(data) |
| 732 | # If the file has an encoding, encode unicode with it. |
| 733 | if (isinstance(fp, file) and |
| 734 | isinstance(data, unicode) and |
| 735 | fp.encoding is not None): |
| 736 | errors = getattr(fp, "errors", None) |
| 737 | if errors is None: |
| 738 | errors = "strict" |
| 739 | data = data.encode(fp.encoding, errors) |
| 740 | fp.write(data) |
| 741 | want_unicode = False |
| 742 | sep = kwargs.pop("sep", None) |
| 743 | if sep is not None: |