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 Padmanabhan.Tr
Recipients Padmanabhan.Tr, steven.daprano
Date 2015-07-08.14:50:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485663175.588766.1436367052388.JavaMail.yahoo@mail.yahoo.com>
In-reply-to <1004483660.603783.1436365559960.JavaMail.yahoo@mail.yahoo.com>
Content
On Wednesday, July 8, 2015 7:56 PM, padmanabhan T R <trpuma@yahoo.com> wrote:

 Dear Mr Steven D'ApranoI have not gone through the relevant Source Codes; purely based on my working with Python3 (Version 3.4.2) and the 'The Python Library Reference manual, Release 3.4.2' document, I have the following to suggest as additions to this Manual:   
   - Insert the following under 'codecs.decode(obj [,encoding[,errors]])' - Section 7.2, Page 142 :   

When a bytes objectis decoded with 'hex' decoding, the corresponding returned array hasASCII characters for byte pairs wherever possible; other byte pairsappear as such. The reverse holds good for encoding.
>>> import codecs
>>> codecs.encode(b'\x1d\x1e\x1f !"','hex')
b'1d1e1f202122'
>>> codecs.encode(b'\x1d\x1e\x1f\x20\x21\x22','hex')
b'1d1e1f202122'
>>> codecs.decode(b'1d1e1f202122','hex')
b'\x1d\x1e\x1f !"'
>>> codecs.encode(_,'hex')
b'1d1e1f202122'
>>> codecs.decode(b'3031323334','hex')                   
b'01234'
>>> codecs.encode(_,'hex')
b'3031323334'
>>> codecs.decode(b'797a7b7c7d7e7f8081','hex')
b'yz{|}~\x7f\x80\x81'
>>> codecs.encode(_,'hex') 
b'797a7b7c7d7e7f8081'
>>> codecs.encode(b'\x79\x7a\x7b\x7c\x7d\7e\x7f\x80\x81','hex')
b'797a7b7c7d07657f8081'
>>> 

   - Under 'int.to_bytes() -  classmethod int.to_bytes()' - Section 4.4.2, Page 31 insert: 'See codecs.decode() also'
   - Under 'int.to_bytes() -  classmethod int.frombytes()' - Section 4.4.2, Page 31 insert: 'See codecs.decode() also'
   - Under 'classmethod bytes.fromhex(string)' - Section 7.2, Page 142 insert: 'See codecs.decode() also'
Padmanabhanm

     On Wednesday, July 8, 2015 8:57 AM, padmanabhan T R <trpuma@yahoo.com> wrote:

      On Tuesday, July 7, 2015 9:22 PM, Steven D'Aprano <report@bugs.python.org> wrote:

Steven D'Aprano added the comment:

Bytes in Python 3 do use ASCII representation:

py> b'\x41' == b'A'  # ASCII
True

If you think the documentation is unclear, please tell us which part of the docs you read (provide a URL) and we will see if it can be improved.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue24551>
_______________________________________
History
Date User Action Args
2015-07-08 14:50:57Padmanabhan.Trsetrecipients: + Padmanabhan.Tr, steven.daprano
2015-07-08 14:50:57Padmanabhan.Trlinkissue24551 messages
2015-07-08 14:50:56Padmanabhan.Trcreate