Commit 069a83bc authored by Stefan Behnel's avatar Stefan Behnel

unicode fixes

parent b33174e7
...@@ -23,9 +23,9 @@ class Context(object): ...@@ -23,9 +23,9 @@ class Context(object):
self.errors = [] self.errors = []
def regref(self, obj, lineno, is_null): def regref(self, obj, lineno, is_null):
log(LOG_ALL, 'regref', "<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'regref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
self.errors.append("NULL argument on line %d" % lineno) self.errors.append(u"NULL argument on line %d" % lineno)
return return
id_ = id(obj) id_ = id(obj)
count, linenumbers = self.refs.get(id_, (0, [])) count, linenumbers = self.refs.get(id_, (0, []))
...@@ -33,14 +33,14 @@ class Context(object): ...@@ -33,14 +33,14 @@ class Context(object):
linenumbers.append(lineno) linenumbers.append(lineno)
def delref(self, obj, lineno, is_null): def delref(self, obj, lineno, is_null):
log(LOG_ALL, 'delref', "<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'delref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
self.errors.append("NULL argument on line %d" % lineno) self.errors.append(u"NULL argument on line %d" % lineno)
return return
id_ = id(obj) id_ = id(obj)
count, linenumbers = self.refs.get(id_, (0, [])) count, linenumbers = self.refs.get(id_, (0, []))
if count == 0: if count == 0:
self.errors.append("Too many decrefs on line %d, reference acquired on lines %r" % self.errors.append(u"Too many decrefs on line %d, reference acquired on lines %r" %
(lineno, linenumbers)) (lineno, linenumbers))
elif count == 1: elif count == 1:
del self.refs[id_] del self.refs[id_]
...@@ -49,12 +49,12 @@ class Context(object): ...@@ -49,12 +49,12 @@ class Context(object):
def end(self): def end(self):
if len(self.refs) > 0: if len(self.refs) > 0:
msg = "" msg = u""
for count, linenos in self.refs.itervalues(): for count, linenos in self.refs.itervalues():
msg += "\n Acquired on lines: " + ", ".join(["%d" % x for x in linenos]) msg += u"\n Acquired on lines: " + u", ".join([u"%d" % x for x in linenos])
self.errors.append("References leaked: %s" % msg) self.errors.append(u"References leaked: %s" % msg)
if self.errors: if self.errors:
return "\n".join(self.errors) return u"\n".join(self.errors)
else: else:
return None return None
...@@ -134,7 +134,7 @@ cdef int FinishContext(PyObject** ctx) except -1: ...@@ -134,7 +134,7 @@ cdef int FinishContext(PyObject** ctx) except -1:
Py_XDECREF(<object>ctx[0]) Py_XDECREF(<object>ctx[0])
ctx[0] = NULL ctx[0] = NULL
if errors: if errors:
print "%s: %s()" % pos print u"%s: %s()" % pos
print errors # raise Error(errors) print errors # raise Error(errors)
return 0 return 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment