(py)
| 205 | |
| 206 | |
| 207 | def py2bytes(py): |
| 208 | if isinstance(py, (bytes, bytearray, memoryview)): |
| 209 | s = ffi.from_buffer(py) |
| 210 | return len(s), s |
| 211 | elif isinstance(py, str): |
| 212 | s = ffi.from_buffer(py.encode('utf8')) |
| 213 | return len(s), s |
| 214 | |
| 215 | |
| 216 | def string2bytes(py, encoding='utf8'): |
no test coverage detected