Skip to content

Commit

Permalink
Replace unicode() with six.text_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemacfarlane committed Oct 11, 2014
1 parent c770396 commit 593840b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/z3c/rml/attr.py
Expand Up @@ -77,7 +77,7 @@ def fromUnicode(self, ustr):
"""See zope.schema.interfaces.IField"""
if self.context is None:
raise ValueError('Attribute not bound to a context.')
return super(RMLAttribute, self).fromUnicode(unicode(ustr))
return super(RMLAttribute, self).fromUnicode(six.text_type(ustr))

def get(self):
"""See zope.schema.interfaces.IField"""
Expand Down Expand Up @@ -533,7 +533,7 @@ class TextNode(RMLAttribute):
def get(self):
if self.context.element.text is None:
return u''
return unicode(self.context.element.text).strip()
return six.text_type(self.context.element.text).strip()


class FirstLevelTextNode(TextNode):
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/rml2pdf.py
Expand Up @@ -24,7 +24,7 @@


def parseString(xml, removeEncodingLine=True, filename=None):
if isinstance(xml, unicode) and removeEncodingLine:
if isinstance(xml, six.text_type) and removeEncodingLine:
# RML is a unicode string, but oftentimes documents declare their
# encoding using <?xml ...>. Unfortuantely, I cannot tell lxml to
# ignore that directive. Thus we remove it.
Expand Down
5 changes: 3 additions & 2 deletions src/z3c/rml/special.py
Expand Up @@ -13,6 +13,7 @@
##############################################################################
"""Special Element Processing
"""
import six
from z3c.rml import attr, directive, interfaces


Expand Down Expand Up @@ -68,7 +69,7 @@ def _getManager(self):
return attr.getManager(self)

def getPageNumber(self, elem, canvas):
return unicode(
return six.text_type(
canvas.getPageNumber() + int(elem.get('countingFrom', 1)) - 1
)

Expand Down Expand Up @@ -111,4 +112,4 @@ def _getText(self, node, canvas, include_final_tail=True):

def do_eval(value):
# Maybe still not safe
return unicode(eval(value.strip(), {'__builtins__': None}, {}))
return six.text_type(eval(value.strip(), {'__builtins__': None}, {}))

0 comments on commit 593840b

Please sign in to comment.