Discussion:
[jira] [Created] (PYLUCENE-35) UnicodeEncodeError when a JavaException is raised
Vic Luo (JIRA)
2015-10-26 15:22:28 UTC
Permalink
Vic Luo created PYLUCENE-35:
-------------------------------

Summary: UnicodeEncodeError when a JavaException is raised
Key: PYLUCENE-35
URL: https://issues.apache.org/jira/browse/PYLUCENE-35
Project: PyLucene
Issue Type: Bug
Environment: Arch Linux x86_64
LANG=zh_CN.UTF-8
Reporter: Vic Luo


When a javaException is raised and the stacktrace includes unicode characters, the stacktrace will not be printed. Instead, line 11 of __init__.py will raise a UnicodeEncodingError:

!!! File "/usr/lib/python2.7/site-packages/lucene-4.9.0-py2.7-linux-x86_64.egg/lucene/__init__.py", line 17, in __str__!!!
!!! return "\n".join((super(JavaError, self).__str__(), " Java stacktrace:", str(writer)))!!!
!!!UnicodeEncodeError: 'ascii' codec can't encode characters in position 102-103: ordinal not in range(128)!!!

I found a workaround: change that line to
return u"\n".join((unicode(super(JavaError, self)), u" Java stacktrace:", unicode(writer)))

,then it could print the correct stacktrace which contains unicode characters in file path.





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda (JIRA)
2015-10-28 04:31:28 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-35?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Vajda resolved PYLUCENE-35.
--------------------------------
Resolution: Fixed

in JCC's svn rev 1710939.
Post by Vic Luo (JIRA)
UnicodeEncodeError when a JavaException is raised
-------------------------------------------------
Key: PYLUCENE-35
URL: https://issues.apache.org/jira/browse/PYLUCENE-35
Project: PyLucene
Issue Type: Bug
Environment: Arch Linux x86_64
LANG=zh_CN.UTF-8
Reporter: Vic Luo
Labels: easyfix, encoding
Original Estimate: 2h
Remaining Estimate: 2h
!!! File "/usr/lib/python2.7/site-packages/lucene-4.9.0-py2.7-linux-x86_64.egg/lucene/__init__.py", line 17, in __str__!!!
!!! return "\n".join((super(JavaError, self).__str__(), " Java stacktrace:", str(writer)))!!!
!!!UnicodeEncodeError: 'ascii' codec can't encode characters in position 102-103: ordinal not in range(128)!!!
I found a workaround: change that line to
return u"\n".join((unicode(super(JavaError, self)), u" Java stacktrace:", unicode(writer)))
,then it could print the correct stacktrace which contains unicode characters in file path.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda (JIRA)
2015-10-28 04:32:27 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-35?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14977701#comment-14977701 ]

Andi Vajda commented on PYLUCENE-35:
------------------------------------

Thank you for the patch.
Post by Vic Luo (JIRA)
UnicodeEncodeError when a JavaException is raised
-------------------------------------------------
Key: PYLUCENE-35
URL: https://issues.apache.org/jira/browse/PYLUCENE-35
Project: PyLucene
Issue Type: Bug
Environment: Arch Linux x86_64
LANG=zh_CN.UTF-8
Reporter: Vic Luo
Labels: easyfix, encoding
Original Estimate: 2h
Remaining Estimate: 2h
!!! File "/usr/lib/python2.7/site-packages/lucene-4.9.0-py2.7-linux-x86_64.egg/lucene/__init__.py", line 17, in __str__!!!
!!! return "\n".join((super(JavaError, self).__str__(), " Java stacktrace:", str(writer)))!!!
!!!UnicodeEncodeError: 'ascii' codec can't encode characters in position 102-103: ordinal not in range(128)!!!
I found a workaround: change that line to
return u"\n".join((unicode(super(JavaError, self)), u" Java stacktrace:", unicode(writer)))
,then it could print the correct stacktrace which contains unicode characters in file path.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...