Revision: 2827
Author: pekka.klarck
Date: Wed Mar 31 09:00:56 2010
Log: Convert arguments to Unicode already when got from the CLI to prevent problems explained in issue 522.
http://code.google.com/p/robotframework/source/detail?r=2827

Modified:
 /trunk/src/robot/parsing/model.py
 /trunk/src/robot/parsing/rawdata.py
 /trunk/src/robot/utils/__init__.py
 /trunk/src/robot/utils/argumentparser.py
 /trunk/src/robot/utils/encoding.py

=======================================
--- /trunk/src/robot/parsing/model.py   Fri Feb 26 03:49:09 2010
+++ /trunk/src/robot/parsing/model.py   Wed Mar 31 09:00:56 2010
@@ -12,9 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-
 import os
-import sys

 from robot import utils
 from robot.errors import DataError
@@ -60,8 +58,6 @@

     def _get_name_and_source(self, path):
         source = self._get_source(path)
-        if not utils.is_jython:
-            source = source.decode(sys.getfilesystemencoding(), 'ignore')
         return self._get_name(source), source

     def _get_name(self, source):
=======================================
--- /trunk/src/robot/parsing/rawdata.py Tue Mar 23 04:15:41 2010
+++ /trunk/src/robot/parsing/rawdata.py Wed Mar 31 09:00:56 2010
@@ -12,10 +12,8 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-
 import re
 import os
-import sys

 from robot import utils
 from robot.errors import DataError
@@ -124,13 +122,7 @@
         self._table = None
         self._strip_comments = strip_comments
         # ${CURDIR} is replaced the data and thus must be escaped
-        self._curdir = self._get_curdir(path)
-
-    def _get_curdir(self, path):
-        curdir = utils.get_directory(path).replace('\\','\\\\')
-        if not utils.is_jython:
-            curdir = curdir.decode(sys.getfilesystemencoding(), 'ignore')
-        return curdir
+        self._curdir = utils.get_directory(path).replace('\\','\\\\')

     def start_table(self, name):
         """Makes rawdata instance ready to receive new data
=======================================
--- /trunk/src/robot/utils/__init__.py  Mon Mar 29 15:50:58 2010
+++ /trunk/src/robot/utils/__init__.py  Wed Mar 31 09:00:56 2010
@@ -38,7 +38,8 @@
         is_boolean, is_number, is_list_of_str, to_boolean, to_list, \
         dict2map, type_as_str
 from unic import unic
-from encoding import encode_to_file_system, decode_output, encode_output
+from encoding import encode_to_file_system, decode_from_file_system, \
+        decode_output, encode_output
 from robotversion import get_version, get_java_version
 from text import cut_long_message, cut_long_assign_msg, wrap
 from xmlwriter import XmlWriter
=======================================
--- /trunk/src/robot/utils/argumentparser.py    Fri Feb 26 03:36:44 2010
+++ /trunk/src/robot/utils/argumentparser.py    Wed Mar 31 09:00:56 2010
@@ -25,6 +25,7 @@
 from misc import plural_or_not
 from robottypes import is_list, is_boolean
 from text import wrap
+from encoding import decode_from_file_system


ESCAPES = { 'space' : ' ', 'apos' : "'", 'quot' : '"', 'lt' : '<',
@@ -127,6 +128,7 @@

Possible errors in processing arguments are reported using DataError.
         """
+        args_list = [ decode_from_file_system(a) for a in args_list ]
         if argfile:
             args_list = self._add_args_from_file(args_list, argfile)
         opts, args = self._parse_args(args_list)
=======================================
--- /trunk/src/robot/utils/encoding.py  Mon Mar 29 15:52:57 2010
+++ /trunk/src/robot/utils/encoding.py  Wed Mar 31 09:00:56 2010
@@ -8,6 +8,10 @@
     enc = sys.getfilesystemencoding()
     return string.encode(enc) if enc else string

+def decode_from_file_system(string):
+    enc = sys.getfilesystemencoding()
+    return string.decode(enc) if enc else string
+
 def decode_output(string):
     if _output_encoding:
         return unic(string, _output_encoding)

Reply via email to