Title: Unicode hex string decode failure
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7.2
Milestone: Jython 2.7.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: jeff.allen, wfouche2
Priority: normal Keywords:

Created on 2019-11-06.07:19:43 by wfouche2, last changed 2020-02-01.08:51:38 by jeff.allen.

msg12762 (view) Author: Werner Fouché (wfouche2) Date: 2019-11-06.07:19:43
Jython 2.7.2b3 at change, fails to execute the following code:

import base64

JMSMessageID = u'38303762646637342d386137632d346637632d393364632d'
JMSMessageID_hex = JMSMessageID .decode("hex")
JMSMessageID_b64 = base64.b64encode(JMSMessageID_hex)

print JMSMessageID 
print JMSMessageID_hex
print JMSMessageID_b64

It fails with:

Traceback (most recent call last):
  File "", line 4, in <module>
    JMSMessageID_hex = JMSMessageID .decode("hex")
  File "C:\jython27\jython-standalone.jar\Lib\encodings\", line 42, in hex_decode
TypeError: a2b_hex() argument 1 must bytes or unicode, not unicode

Jython 2.5.4.rc1 and Python 2.7.16 produces the following output:

msg12876 (view) Author: Jeff Allen (jeff.allen) Date: 2019-12-22.16:43:58
That's an annoying error message. :-/
msg12878 (view) Author: Jeff Allen (jeff.allen) Date: 2019-12-23.15:28:04
Good now on my local repo:
>>> u'38303762646637342d386137632d346637632d393364632d'.decode('hex')

In fact, there were quite a few places in binascii where the same tolerance for unicode should exist, so thanks for reporting.
msg12890 (view) Author: Jeff Allen (jeff.allen) Date: 2019-12-24.15:11:27
Fixed at with some clean-up in next change set.
Date User Action Args
2020-02-01 08:51:38jeff.allensetstatus: pending -> closed
2019-12-24 15:11:27jeff.allensetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg12890
2019-12-23 15:28:04jeff.allensettype: behaviour
messages: + msg12878
title: Unicode hex string decode fails with Jython 2.7.2.b3 -> Unicode hex string decode failure
2019-12-22 16:43:58jeff.allensetassignee: jeff.allen
resolution: accepted
messages: + msg12876
components: + Library, - Core
nosy: + jeff.allen
2019-12-14 10:09:48jeff.allensetpriority: normal
milestone: Jython 2.7.2
2019-11-06 07:19:43wfouche2create