Message10863

Author laurio
Recipients laurio
Date 2016-06-02.04:59:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464843550.53.0.929396760263.issue2503@psf.upfronthosting.co.za>
In-reply-to
Content
Jython doesn't handle Unicode strings properly when using sun.locale.formatasdefault=true flag. 

Preconditions:
- Window 7, OS language English and regional settings (including date formats) set to Finnish

Steps to reproduce:
- start Jython by "java -Dsun.locale.formatasdefault=true -jar jython-standalone-2.7.0.jar"
- enter to console:
-- from datetime import datetime
-- datetime.strptime('pe tammi 22 14:00:00 2016', u'%a %b %d %H:%M:%S %Y')

Result:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Z:\Lauri\jython-standalone-2.7.0.jar\Lib\datetime.py", line 1778, in strptime
  File "Z:\Lauri\jython-standalone-2.7.0.jar\Lib\_strptime.py", line 308, in _strptime
  File "Z:\Lauri\jython-standalone-2.7.0.jar\Lib\_strptime.py", line 308, in _strptime
  File "Z:\Lauri\jython-standalone-2.7.0.jar\Lib\_strptime.py", line 265, in compile
  File "Z:\Lauri\jython-standalone-2.7.0.jar\Lib\_strptime.py", line 257, in pattern
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 18: ordinal not in range(128)

After removing the "u" from format-string this issue doesn't reproduce.

Originally happens when using RobotFramwork's DateTime-library and apparently there strings are using Unicode so using this without the "u" is not an option for me.

Related issue in RobotFramework that lead to the discovery that this is Jython bug: https://github.com/robotframework/robotframework/issues/2306
History
Date User Action Args
2016-06-02 04:59:10lauriosetrecipients: + laurio
2016-06-02 04:59:10lauriosetmessageid: <1464843550.53.0.929396760263.issue2503@psf.upfronthosting.co.za>
2016-06-02 04:59:10lauriolinkissue2503 messages
2016-06-02 04:59:09lauriocreate