Revision: 4a9ababb2a10
Author: Pekka Klärck
Date: Tue Mar 20 15:39:21 2012
Log: Handle non-ASCII chars in PYTHONPATH (and CLASSPATH) correctly
when reporting errors with imports.
Update issue 1092
Status: Done
The problem ought to be fixed now. Thanks for a report!
While investigating this problem I noticed an other similar issue. I need to
investigate that a bit more but most likely it requires a separate issue.
http://code.google.com/p/robotframework/source/detail?r=4a9ababb2a10
Modified:
/src/robot/utils/importer.py
/utest/utils/test_importer_util.py
=======================================
--- /src/robot/utils/importer.py Tue Mar 6 00:46:30 2012
+++ /src/robot/utils/importer.py Tue Mar 20 15:39:21 2012
@@ -21,6 +21,7 @@
from robot.errors import DataError
+from .encoding import decode_from_system
from .error import get_error_details
from .robotpath import abspath, normpath
@@ -104,7 +105,8 @@
yield '%s:' % type
for item in items:
if item:
- yield ' %s' % item
+ yield ' %s' % (item if isinstance(item, unicode)
+ else decode_from_system(item))
def _instantiate_if_needed(self, imported, args):
if args is None:
=======================================
--- /utest/utils/test_importer_util.py Tue Feb 21 07:11:23 2012
+++ /utest/utils/test_importer_util.py Tue Mar 20 15:39:21 2012
@@ -356,6 +356,15 @@
for line in lines[1:]:
assert_true(line.startswith(' '))
+ def test_non_ascii_bytes_in_pythonpath(self):
+ sys.path.append('hyv\xe4')
+ try:
+ error = self._failing_import('NoneExisting')
+ finally:
+ sys.path.pop()
+ last_line = self._get_pythonpath(error).splitlines()[-1].strip()
+ assert_true(last_line.startswith('hyv'))
+
if sys.platform.startswith('java'):
def test_classpath(self):