This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hct
Recipients Arfrever, christian.heimes, eric.araujo, georg.brandl, gotgenes, hct, mark.dickinson, martin.panter, ncoghlan, pitrou, rhettinger, serhiy.storchaka, terry.reedy, vstinner, wiggin15
Date 2014-09-10.22:30:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410388231.07.0.0835302690733.issue9951@psf.upfronthosting.co.za>
In-reply-to
Content
@Victor

binascii.hexlify('abc') doesn't work in 3.4. I assume this is a new thing for 3.5

>>> import binascii
>>> binascii.hexlify('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>>
>>> binascii.hexlify(b'abc')
b'616263'


@Terry
I think that space shouldn't be done by the hex function. if you allow space between each hex, then what do you do if the bytes are actually from array of 64-bit ints? getting into support separating space for every X bytes is probably not the scope of this.


I propose the hex functions for bytes/memoryview/bytearray should be as follow. I prefer to not have the '0x' prefix at all, but I understand all other hex functions adds it. would be good to have the option to not have the prefix.

bytes.hex( byte_order = sys.byteorder ) returns a hex string in small letter. ex. c0ffee

bytes.HEX( byte_order = sys.byteorder ) returns a hex string in capital letters. ex. DEADBEEF

bytes.from_hex( hex_str, byte_order = sys.byteorder ) returns a bytes object. ex. b'\xFE\xFF'


another more flexible way is to have hex function accept a format similar to how sscanf works, but this will probably bring lots of trouble for all kinds of variants to support and the required error checks.
History
Date User Action Args
2014-09-10 22:30:31hctsetrecipients: + hct, georg.brandl, rhettinger, terry.reedy, mark.dickinson, ncoghlan, pitrou, vstinner, gotgenes, christian.heimes, eric.araujo, Arfrever, wiggin15, martin.panter, serhiy.storchaka
2014-09-10 22:30:31hctsetmessageid: <1410388231.07.0.0835302690733.issue9951@psf.upfronthosting.co.za>
2014-09-10 22:30:31hctlinkissue9951 messages
2014-09-10 22:30:30hctcreate