You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by "Andi Vajda (JIRA)" <ji...@apache.org> on 2015/10/28 05:32:27 UTC
[jira] [Commented] (PYLUCENE-35) UnicodeEncodeError when a
JavaException is raised
[ 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.
> 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
>
> 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)