diff --git a/lxml-fix-attribute-quoting.patch b/lxml-fix-attribute-quoting.patch
new file mode 100644
index 0000000..fd3e039
--- /dev/null
+++ b/lxml-fix-attribute-quoting.patch
@@ -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('foo')
++ self.assertXml('foo')
+
+ 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 (cur[0] >= 0x80) and (cur[1] != 0):
+
+ if (base != cur):
+ tree.xmlOutputBufferWrite(buf, cur - base, base)
+
+- if (cur[0] < 0xC0):
++ ucur = 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, tmp)
++ tree.xmlOutputBufferWrite(buf, len(tmp), tmp)
+ cur += l
+ base = cur
+
diff --git a/python-lxml.changes b/python-lxml.changes
index 750e82a..548b5ba 100644
--- a/python-lxml.changes
+++ b/python-lxml.changes
@@ -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
diff --git a/python-lxml.spec b/python-lxml.spec
index 9a2f662..ef33215 100644
--- a/python-lxml.spec
+++ b/python-lxml.spec
@@ -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