steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 100 forks source link

Unify Handling of Bytes Objects across Python 2.7 & 3.6 #157

Closed cyon1c closed 6 years ago

cyon1c commented 6 years ago

A major source of inconsistency across the 2 platforms is how bytes is handled in 2.7 and 3.6. In 2.7, bytes is simply an alias for str. This causes several issues.

  1. Many of the types defined in the library define the __bytes__ function for serialization, etc, which will not be called in 2.7, as bytes calls down to str.

  2. There are a fair number of instances of performing integer math on bytes arrays, which fails because in 2.7, the bytes object is interpreted as str.

I've attempted to solve this issue with guidance from @john-g-g under the broader python 2 compat work, however, I am going to look at implementing the python-futures, which offers to create a unified bytes object across both platforms.

Doneness: Library passes 65/65 current tests in both Python 2.7 and 3.6