daleroberts / itermplot

An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.
1.49k stars 51 forks source link

Python2.7 Support #11

Closed brenshanny closed 7 years ago

brenshanny commented 7 years ago

Added in a check for the 'getbuffer' attribute for the BytesIO object. It will default to the 'getvalue' attribute if not found, which is the attribute compatable with Python2.7.

Removed 'utf-8' formatting when adding the file size info to the buffer. Python2.7 doesn't support multiple arguments to bytes().

Lastly, added in a check for the 'buffer' attribute for sys.stdout. It will default to sys.stdout.write if not found. These changes seem to provide support for Python2.7 and maintains Python3.

daleroberts commented 7 years ago

Thanks! It breaks Python 3 support but I think I know how to fix that.

That said, supporting Python 2 makes me want to cry 😭