Accepting request 487430 from home:matejcik:branches:devel:languages:python

- lxml-fix-attribute-quoting.patch - stabilize attribute entity encoding
  across platforms
- force-regenerate C code from Cython sources

OBS-URL: https://build.opensuse.org/request/show/487430
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-lxml?expand=0&rev=94
This commit is contained in:
Jan Matejek 2017-04-11 17:15:01 +00:00 committed by Git OBS Bridge
parent 650aff5862
commit cb3e4ae097
3 changed files with 109 additions and 3 deletions

View File

@ -0,0 +1,95 @@
Index: lxml-3.7.3/src/lxml/tests/test_incremental_xmlfile.py
===================================================================
--- lxml-3.7.3.orig/src/lxml/tests/test_incremental_xmlfile.py
+++ lxml-3.7.3/src/lxml/tests/test_incremental_xmlfile.py
@@ -430,7 +430,7 @@ class HtmlFileTestCase(_XmlFileTestCaseB
with xf.element("tagname", attrib={"attr": _str('"misquöted\\u3344\\U00013344"')}):
xf.write("foo")
- self.assertXml('<tagname attr="&quot;misqu&#246;ted&#13124;&#78660;&quot;">foo</tagname>')
+ self.assertXml('<tagname attr="&quot;misqu&#xF6;ted&#x3344;&#x13344;&quot;">foo</tagname>')
def test_unescaped_script(self):
with etree.htmlfile(self._file) as xf:
Index: lxml-3.7.3/src/lxml/serializer.pxi
===================================================================
--- lxml-3.7.3.orig/src/lxml/serializer.pxi
+++ lxml-3.7.3/src/lxml/serializer.pxi
@@ -481,6 +481,7 @@ cdef unsigned char *xmlSerializeHexCharR
cdef _write_attr_string(tree.xmlOutputBuffer* buf, const char *string):
cdef const char *base
cdef const char *cur
+ cdef const unsigned char *ucur
cdef unsigned char tmp[12]
cdef int val = 0
@@ -546,42 +547,44 @@ cdef _write_attr_string(tree.xmlOutputBu
cur += 1
base = cur
- elif (cur[0] >= 0x80) and (cur[1] != 0):
+ elif (<const unsigned char>cur[0] >= 0x80) and (cur[1] != 0):
if (base != cur):
tree.xmlOutputBufferWrite(buf, cur - base, base)
- if (cur[0] < 0xC0):
+ ucur = <const unsigned char *>cur
+
+ if (ucur[0] < 0xC0):
# invalid UTF-8 sequence
- val = cur[0]
+ val = ucur[0]
l = 1
- elif (cur[0] < 0xE0):
- val = (cur[0]) & 0x1F
+ elif (ucur[0] < 0xE0):
+ val = (ucur[0]) & 0x1F
val <<= 6
- val |= (cur[1]) & 0x3F
+ val |= (ucur[1]) & 0x3F
l = 2
- elif ((cur[0] < 0xF0) and (cur[2] != 0)):
- val = (cur[0]) & 0x0F
+ elif ((ucur[0] < 0xF0) and (ucur[2] != 0)):
+ val = (ucur[0]) & 0x0F
val <<= 6
- val |= (cur[1]) & 0x3F
+ val |= (ucur[1]) & 0x3F
val <<= 6
- val |= (cur[2]) & 0x3F
+ val |= (ucur[2]) & 0x3F
l = 3
- elif ((cur[0] < 0xF8) and (cur[2] != 0) and (cur[3] != 0)):
- val = (cur[0]) & 0x07
+ elif ((ucur[0] < 0xF8) and (ucur[2] != 0) and (ucur[3] != 0)):
+ val = (ucur[0]) & 0x07
val <<= 6
- val |= (cur[1]) & 0x3F
+ val |= (ucur[1]) & 0x3F
val <<= 6
- val |= (cur[2]) & 0x3F
+ val |= (ucur[2]) & 0x3F
val <<= 6
- val |= (cur[3]) & 0x3F
+ val |= (ucur[3]) & 0x3F
l = 4
else:
# invalid UTF-8 sequence
- val = cur[0]
+ val = ucur[0]
l = 1
if ((l == 1) or (not tree.xmlIsCharQ(val))):
@@ -590,7 +593,7 @@ cdef _write_attr_string(tree.xmlOutputBu
# We could do multiple things here. Just save
# as a char ref
xmlSerializeHexCharRef(tmp, val)
- tree.xmlOutputBufferWrite(buf, -1, <const char*> tmp)
+ tree.xmlOutputBufferWrite(buf, len(tmp), <const char*> tmp)
cur += l
base = cur

View File

@ -1,7 +1,10 @@
-------------------------------------------------------------------
Fri Apr 7 18:20:52 UTC 2017 - jmatejek@suse.com
Tue Apr 11 16:29:04 UTC 2017 - jmatejek@suse.com
- temporarily disable Source URL for pdf doc (it became unavailable)
- lxml-fix-attribute-quoting.patch - stabilize attribute entity encoding
across platforms
- force-regenerate C code from Cython sources
-------------------------------------------------------------------
Wed Mar 8 18:55:12 UTC 2017 - axel.braun@gmx.de

View File

@ -27,6 +27,8 @@ Url: https://lxml.de/
Source: https://files.pythonhosted.org/packages/source/l/lxml/lxml-%{version}.tar.gz
#Source1: https://lxml.de/lxmldoc-%{version}.pdf
Source1: lxmldoc-%{version}.pdf
# PATCH-FIX-UPSTREAM fix attribute quoting inactive code https://github.com/lxml/lxml/pull/238
Patch0: lxml-fix-attribute-quoting.patch
BuildRequires: %{python_module Cython >= 0.22.1}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools >= 18.0.1}
@ -75,16 +77,22 @@ This package contains header files needed to use lxml's C API.
%prep
%setup -q -n lxml-%{version}
cp %{SOURCE1} .
%patch0 -p1
# remove generated files
rm src/lxml/lxml.etree.c
rm src/lxml/lxml.etree.h
rm src/lxml/lxml.etree_api.h
rm src/lxml/lxml.objectify.c
%build
export CFLAGS="%{optflags}"
%python_build
%python_build --with-cython
%check
# The tests fail on SLE 11 due to broken incremental parsing
# in libxml2
export CFLAGS="%{optflags}"
%python_exec setup.py build_ext --inplace
LANG=en_US.UTF-8 PYTHONUNBUFFERED=x make test
LANG=en_US.UTF-8 PYTHONUNBUFFERED=x make test3