Antonio Cuni committed c8036c0 Draft

rpython fix: use unicode strings for error messages, because we need to use %s on unicode args

Comments (0)

Files changed (1)


     def error(self, msg):
         space =
-        msg = 'line %d: %s' % (self.line_num, msg)
+        msg = u'line %d: %s' % (self.line_num, msg)
         w_module = space.getbuiltinmodule('_csv')
         w_error = space.getattr(w_module, space.wrap('Error'))
         raise OperationError(w_error, space.wrap(msg))
     def add_char(self, field_builder, c):
         assert field_builder is not None
         if field_builder.getlength() >= field_limit.limit:
-            raise self.error("field larger than field limit")
+            raise self.error(u"field larger than field limit")
     def save_field(self, field_builder):
                             (len( > 0 or
                              state == IN_QUOTED_FIELD)):
                         if dialect.strict:
-                            raise self.error("newline inside string")
+                            raise self.error(u"newline inside string")
             line = space.unicode_w(w_line)
             for c in line:
                 if c == u'\0':
-                    raise self.error("line contains NULL byte")
+                    raise self.error(u"line contains NULL byte")
                 if state == START_RECORD:
                     if c == u'\n' or c == u'\r':
                         state = IN_FIELD
                         # illegal
-                        raise self.error("'%s' expected after '%s'" % (
+                        raise self.error(u"'%s' expected after '%s'" % (
                             dialect.delimiter, dialect.quotechar))
                 elif state == EAT_CRNL:
                     if not (c == u'\n' or c == u'\r'):
-                        raise self.error("new-line character seen in unquoted "
-                                        "field - do you need to open the file "
-                                        "in universal-newline mode?")
+                        raise self.error(u"new-line character seen in unquoted "
+                                         u"field - do you need to open the file "
+                                         u"in universal-newline mode?")
             if state == IN_FIELD or state == QUOTE_IN_QUOTED_FIELD:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.