(b)
| 127 | |
| 128 | @staticmethod |
| 129 | def __tobytes(b): |
| 130 | if b is None: |
| 131 | return None |
| 132 | if isinstance(b, bytes): |
| 133 | return b |
| 134 | try: # keep Python 2 compatibility |
| 135 | return bytes(b, 'utf-8') |
| 136 | except TypeError: |
| 137 | return bytes(b) |
| 138 | |
| 139 | def file(self, filename): |
| 140 | """ |