petertodd/python-bitcoinlib — pull request #25 by icook (2014-11-16 20:22:29+00:00)
Title: Add a test for proper exception raising on bad start

A test to confirm the fix on https://github.com/icook/python-bitcoinlib/commit/bdfc18a2b564853b007f3b36585d2c668a769ba2#commitcomment-8588990. It appears the actual issue is passing a string instead of bytes object in Python 2.7. I read several docs that stated "bytes in Python 2.7 is simply an alias for str" but in this case it appears to not behave quite the same. In the test I wrote on Python 2.7 if I remove the "b" before my string it raises a formatting exception. With the b it works fine. This is likely a systemic issue, and I'm not sure of a clever way to catch it and provide helpful exceptions to users... It seems silly/wasteful/painful to try and wrap all format bytes calls with b2x.