On Fri, 30 Dec 2011 11:21:03 -0500
"Edward K. Ream" <[email protected]> wrote:

> On Wed, Dec 28, 2011 at 10:49 AM, Terry Brown <[email protected]> wrote:
> 
> > There's a lot of discussion on the web about this, but I can't find a
> > solution.  
> 
> Do you mean http://bugs.python.org/issue6137 ?

That's part of the discussion.  It may just be my py 2/3 encoding issue
skills aren't up to the task, it's just a matter of getting the test
script (attached again here) working in py 3.x.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

import sys
from pickle import loads
from binascii import a2b_hex
d = '7d71005509636f6d706c6574656471016364617465746' \
    '96d650a6461746574696d650a710228550a07db0c1a16' \
    '3226013e477103747104527105732e'
    
if sys.version_info >= (3, 0):
    
    assert d.__class__.__name__ == 'str'
    d = d.encode('ascii')
    assert d.__class__.__name__ == 'bytes'
    
    data = a2b_hex(d)
    
    assert data.__class__.__name__ == 'bytes'
    
    # obj = loads(data, fix_imports=True)
    # obj = loads(data.decode('ascii'), fix_imports=True, encoding='ascii')
    # obj = loads(data.decode('latin-1'), fix_imports=True, encoding='latin-1')
    obj = loads(data, fix_imports=True, encoding='latin-1')
    
    print(obj)

else:
    
    assert d.__class__.__name__ == 'str'
    
    data = a2b_hex(d)
    obj = loads(data)
    print(obj)

Reply via email to