Project

General

Profile

« Previous | Next » 

Revision 4492

Replaced repr() with strings.urepr() (or equivalent) everywhere needed, to avoid future UnicodeEncodeErrors

View differences:

lib/sql.py
43 43

  
44 44
class ExceptionWithValue(DbException):
45 45
    def __init__(self, value, cause=None):
46
        DbException.__init__(self, 'for value: '+strings.as_tt(repr(value)),
47
            cause)
46
        DbException.__init__(self, 'for value: '
47
            +strings.as_tt(strings.urepr(value)), cause)
48 48
        self.value = value
49 49

  
50 50
class ExceptionWithNameType(DbException):
lib/xpath.py
4 4
import warnings
5 5

  
6 6
from Parser import Parser
7
import strings
7 8
import util
8 9
import xml_dom
9 10

  
......
28 29
        if self.name == '': str_ += '""'
29 30
        else: str_ += self.name
30 31
        if self.is_lookup_only: str_ += '?'
31
        if self.keys != []: str_ += repr(self.keys)
32
        if self.attrs != []: str_ += ':'+repr(self.attrs)
32
        if self.keys != []: str_ += strings.urepr(self.keys)
33
        if self.attrs != []: str_ += ':'+strings.urepr(self.attrs)
33 34
        if self.is_ptr: str_ += '->'
34
        if self.other_branches != []: str_ += '{'+repr(self.other_branches)+'}'
35
        if self.value != None: str_ += '='+repr(self.value)
35
        if self.other_branches != []:
36
            str_ += '{'+strings.urepr(self.other_branches)+'}'
37
        if self.value != None: str_ += '='+strings.urepr(self.value)
36 38
        return str_
37 39
    
38 40
    def __eq__(self, other): return self.__dict__ == other.__dict__
lib/objects.py
1 1
# Objects
2 2

  
3
import strings
3 4
import util
4 5

  
5 6
class BasicObject:
6 7
    '''Provides default implementations of commonly-used methods'''
7 8
    
8
    def __str__(self): return util.class_name(self)+repr(self.__dict__)
9
    def __str__(self): return util.class_name(self)+strings.urepr(self.__dict__)
9 10
    
10 11
    def __repr__(self): return self.__str__()
11 12
    
lib/parallelproc.py
11 11
import dicts
12 12
import exc
13 13
from Runnable import Runnable
14
import strings
14 15

  
15 16
def try_pickle(value):
16 17
    try: cPickle.dumps(value)
17 18
    except Exception, e:
18
        exc.add_msg(e, 'Tried to pickle: '+repr(value))
19
        exc.add_msg(e, 'Tried to pickle: '+strings.urepr(value))
19 20
        raise
20 21

  
21 22
def prepickle(value, vars_id_dict_):
lib/sql_io.py
420 420
            
421 421
            sql.add_index(db, in_col, insert_in_table) # enable fast filtering
422 422
            if value != None and in_col not in not_null_cols:
423
                log_debug('Replacing invalid value '+strings.as_tt(repr(value))
424
                    +' with NULL in column '+strings.as_tt(in_col.to_str(db)))
423
                log_debug('Replacing invalid value '
424
                    +strings.as_tt(strings.urepr(value))+' with NULL in column '
425
                    +strings.as_tt(in_col.to_str(db)))
425 426
                sql.update(db, insert_in_table, [(in_col, None)],
426 427
                    sql_gen.ColValueCond(in_col, value))
427 428
            else:
428 429
                log_debug('Ignoring rows with '+strings.as_tt(in_col.to_str(db))
429
                    +' = '+strings.as_tt(repr(value)))
430
                    +' = '+strings.as_tt(strings.urepr(value)))
430 431
                sql.delete(db, insert_in_table,
431 432
                    sql_gen.ColValueCond(in_col, value))
432 433
                if value == None: not_null_cols.add(in_col)
......
501 502
        if limit_ref[0] == 0:
502 503
            if is_literals or default == None:
503 504
                default = sql_gen.remove_col_rename(default)
504
                log_debug('Returning default: '+strings.as_tt(repr(default)))
505
                log_debug('Returning default: '
506
                    +strings.as_tt(strings.urepr(default)))
505 507
                return default
506 508
            elif is_function: pass # empty pkeys table already created
507 509
            else:
......
649 651
    
650 652
    if limit_ref[0] == 0 or not is_function: # is_function doesn't leave holes
651 653
        log_debug('Setting pkeys of missing rows to '
652
            +strings.as_tt(repr(default)))
654
            +strings.as_tt(strings.urepr(default)))
653 655
        missing_rows_joins = [full_in_table, sql_gen.Join(into,
654 656
            {in_pkey: sql_gen.join_same_not_null}, sql_gen.filter_out)]
655 657
            # must use join_same_not_null or query will take forever
bin/map
288 288
                    log_debug('Getting '+strings.ustr(in_))
289 289
                    value = metadata_value(in_)
290 290
                    if value == None: value = cleanup(get_value(in_, row))
291
                    log_debug('Putting '+repr(value)+' to '+strings.ustr(out))
291
                    log_debug('Putting '+strings.urepr(value)+' to '
292
                        +strings.ustr(out))
292 293
                    if out_is_db: # out is list of XML nodes
293 294
                        for node in out: xml_dom.set_value(node, value)
294 295
                    elif value != None: # out is XPath

Also available in: Unified diff