UTF-8 encoded wrapper around stdout for py3, to override ASCII stdout
| 162 | from io import TextIOWrapper, FileIO |
| 163 | |
| 164 | class _Py3Utf8Output(TextIOWrapper): |
| 165 | """UTF-8 encoded wrapper around stdout for py3, to override |
| 166 | ASCII stdout |
| 167 | """ |
| 168 | def __init__(self, f, **kwargs): |
| 169 | buf = FileIO(f.fileno(), 'w') |
| 170 | super(_Py3Utf8Output, self).__init__( |
| 171 | buf, |
| 172 | encoding='utf8', |
| 173 | errors='strict' |
| 174 | ) |
| 175 | |
| 176 | def write(self, s): |
| 177 | super(_Py3Utf8Output, self).write(s) |
| 178 | self.flush() |
| 179 | |
| 180 | _py3_print = getattr(builtins, 'print') |
| 181 | try: |