This function is used to write raw bytes to stdout.
(statement, stdout=None)
| 218 | |
| 219 | |
| 220 | def bytes_print(statement, stdout=None): |
| 221 | """ |
| 222 | This function is used to write raw bytes to stdout. |
| 223 | """ |
| 224 | if stdout is None: |
| 225 | stdout = sys.stdout |
| 226 | |
| 227 | if getattr(stdout, 'buffer', None): |
| 228 | stdout.buffer.write(statement) |
| 229 | else: |
| 230 | # If it is not possible to write to the standard out buffer. |
| 231 | # The next best option is to decode and write to standard out. |
| 232 | stdout.write(statement.decode('utf-8')) |
| 233 | |
| 234 | |
| 235 | def get_stdout_text_writer(): |