~ubuntu-branches/ubuntu/saucy/lxml/saucy-updates

« back to all changes in this revision

Viewing changes to src/lxml/apihelpers.pxi

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-02-19 21:47:31 UTC
  • mfrom: (2.1.35 experimental)
  • Revision ID: package-import@ubuntu.com-20130219214731-jbkip7ycyvzlth3m
Tags: 3.1.0-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1301
1301
    cdef Py_ssize_t slen
1302
1302
    cdef const_xmlChar* spos
1303
1303
    cdef bint is_non_ascii
1304
 
    if python.IS_PYTHON3:
 
1304
    if python.LXML_UNICODE_STRINGS:
1305
1305
        return s.decode('UTF-8')
1306
1306
    spos = s
1307
1307
    is_non_ascii = 0
1340
1340
            u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters"
1341
1341
    return utf8_string
1342
1342
 
 
1343
cdef bytes _utf8orNone(object s):
 
1344
    return _utf8(s) if s is not None else None
 
1345
 
1343
1346
cdef bint _isFilePath(const_xmlChar* c_path):
1344
1347
    u"simple heuristic to see if a path is a filename"
1345
1348
    cdef xmlChar c
1548
1551
cdef object _namespacedNameFromNsName(const_xmlChar* href, const_xmlChar* name):
1549
1552
    if href is NULL:
1550
1553
        return funicode(name)
1551
 
    elif python.IS_PYTHON3:
 
1554
    elif python.LXML_UNICODE_STRINGS and python.PY_VERSION_HEX >= 0x02060000:
1552
1555
        return python.PyUnicode_FromFormat("{%s}%s", href, name)
1553
1556
    else:
1554
1557
        s = python.PyBytes_FromFormat("{%s}%s", href, name)
1555
 
        if isutf8(href) or isutf8(name):
 
1558
        if python.LXML_UNICODE_STRINGS or isutf8(_xcstr(s)):
1556
1559
            return python.PyUnicode_FromEncodedObject(s, 'UTF-8', NULL)
1557
1560
        else:
1558
1561
            return s