1629da73580fe8286787d2b90909eb514c770751
[platform/upstream/python-lxml.git] / src / lxml / html / diff.c
1 /* Generated by Cython 0.29.18 */
2
3 /* BEGIN: Cython Metadata
4 {
5     "distutils": {
6         "define_macros": [
7             [
8                 "CYTHON_CLINE_IN_TRACEBACK",
9                 "0"
10             ]
11         ],
12         "extra_compile_args": [
13             "-w"
14         ],
15         "include_dirs": [
16             "/usr/include/libxml2",
17             "src",
18             "src/lxml/includes"
19         ],
20         "name": "lxml.html.diff",
21         "sources": [
22             "src/lxml/html/diff.py"
23         ]
24     },
25     "module_name": "lxml.html.diff"
26 }
27 END: Cython Metadata */
28
29 #define PY_SSIZE_T_CLEAN
30 #include "Python.h"
31 #ifndef Py_PYTHON_H
32     #error Python headers needed to compile C extensions, please install development version of Python.
33 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
34     #error Cython requires Python 2.6+ or Python 3.3+.
35 #else
36 #define CYTHON_ABI "0_29_18"
37 #define CYTHON_HEX_VERSION 0x001D12F0
38 #define CYTHON_FUTURE_DIVISION 1
39 #include <stddef.h>
40 #ifndef offsetof
41   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
42 #endif
43 #if !defined(WIN32) && !defined(MS_WINDOWS)
44   #ifndef __stdcall
45     #define __stdcall
46   #endif
47   #ifndef __cdecl
48     #define __cdecl
49   #endif
50   #ifndef __fastcall
51     #define __fastcall
52   #endif
53 #endif
54 #ifndef DL_IMPORT
55   #define DL_IMPORT(t) t
56 #endif
57 #ifndef DL_EXPORT
58   #define DL_EXPORT(t) t
59 #endif
60 #define __PYX_COMMA ,
61 #ifndef HAVE_LONG_LONG
62   #if PY_VERSION_HEX >= 0x02070000
63     #define HAVE_LONG_LONG
64   #endif
65 #endif
66 #ifndef PY_LONG_LONG
67   #define PY_LONG_LONG LONG_LONG
68 #endif
69 #ifndef Py_HUGE_VAL
70   #define Py_HUGE_VAL HUGE_VAL
71 #endif
72 #ifdef PYPY_VERSION
73   #define CYTHON_COMPILING_IN_PYPY 1
74   #define CYTHON_COMPILING_IN_PYSTON 0
75   #define CYTHON_COMPILING_IN_CPYTHON 0
76   #undef CYTHON_USE_TYPE_SLOTS
77   #define CYTHON_USE_TYPE_SLOTS 0
78   #undef CYTHON_USE_PYTYPE_LOOKUP
79   #define CYTHON_USE_PYTYPE_LOOKUP 0
80   #if PY_VERSION_HEX < 0x03050000
81     #undef CYTHON_USE_ASYNC_SLOTS
82     #define CYTHON_USE_ASYNC_SLOTS 0
83   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
84     #define CYTHON_USE_ASYNC_SLOTS 1
85   #endif
86   #undef CYTHON_USE_PYLIST_INTERNALS
87   #define CYTHON_USE_PYLIST_INTERNALS 0
88   #undef CYTHON_USE_UNICODE_INTERNALS
89   #define CYTHON_USE_UNICODE_INTERNALS 0
90   #undef CYTHON_USE_UNICODE_WRITER
91   #define CYTHON_USE_UNICODE_WRITER 0
92   #undef CYTHON_USE_PYLONG_INTERNALS
93   #define CYTHON_USE_PYLONG_INTERNALS 0
94   #undef CYTHON_AVOID_BORROWED_REFS
95   #define CYTHON_AVOID_BORROWED_REFS 1
96   #undef CYTHON_ASSUME_SAFE_MACROS
97   #define CYTHON_ASSUME_SAFE_MACROS 0
98   #undef CYTHON_UNPACK_METHODS
99   #define CYTHON_UNPACK_METHODS 0
100   #undef CYTHON_FAST_THREAD_STATE
101   #define CYTHON_FAST_THREAD_STATE 0
102   #undef CYTHON_FAST_PYCALL
103   #define CYTHON_FAST_PYCALL 0
104   #undef CYTHON_PEP489_MULTI_PHASE_INIT
105   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
106   #undef CYTHON_USE_TP_FINALIZE
107   #define CYTHON_USE_TP_FINALIZE 0
108   #undef CYTHON_USE_DICT_VERSIONS
109   #define CYTHON_USE_DICT_VERSIONS 0
110   #undef CYTHON_USE_EXC_INFO_STACK
111   #define CYTHON_USE_EXC_INFO_STACK 0
112 #elif defined(PYSTON_VERSION)
113   #define CYTHON_COMPILING_IN_PYPY 0
114   #define CYTHON_COMPILING_IN_PYSTON 1
115   #define CYTHON_COMPILING_IN_CPYTHON 0
116   #ifndef CYTHON_USE_TYPE_SLOTS
117     #define CYTHON_USE_TYPE_SLOTS 1
118   #endif
119   #undef CYTHON_USE_PYTYPE_LOOKUP
120   #define CYTHON_USE_PYTYPE_LOOKUP 0
121   #undef CYTHON_USE_ASYNC_SLOTS
122   #define CYTHON_USE_ASYNC_SLOTS 0
123   #undef CYTHON_USE_PYLIST_INTERNALS
124   #define CYTHON_USE_PYLIST_INTERNALS 0
125   #ifndef CYTHON_USE_UNICODE_INTERNALS
126     #define CYTHON_USE_UNICODE_INTERNALS 1
127   #endif
128   #undef CYTHON_USE_UNICODE_WRITER
129   #define CYTHON_USE_UNICODE_WRITER 0
130   #undef CYTHON_USE_PYLONG_INTERNALS
131   #define CYTHON_USE_PYLONG_INTERNALS 0
132   #ifndef CYTHON_AVOID_BORROWED_REFS
133     #define CYTHON_AVOID_BORROWED_REFS 0
134   #endif
135   #ifndef CYTHON_ASSUME_SAFE_MACROS
136     #define CYTHON_ASSUME_SAFE_MACROS 1
137   #endif
138   #ifndef CYTHON_UNPACK_METHODS
139     #define CYTHON_UNPACK_METHODS 1
140   #endif
141   #undef CYTHON_FAST_THREAD_STATE
142   #define CYTHON_FAST_THREAD_STATE 0
143   #undef CYTHON_FAST_PYCALL
144   #define CYTHON_FAST_PYCALL 0
145   #undef CYTHON_PEP489_MULTI_PHASE_INIT
146   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
147   #undef CYTHON_USE_TP_FINALIZE
148   #define CYTHON_USE_TP_FINALIZE 0
149   #undef CYTHON_USE_DICT_VERSIONS
150   #define CYTHON_USE_DICT_VERSIONS 0
151   #undef CYTHON_USE_EXC_INFO_STACK
152   #define CYTHON_USE_EXC_INFO_STACK 0
153 #else
154   #define CYTHON_COMPILING_IN_PYPY 0
155   #define CYTHON_COMPILING_IN_PYSTON 0
156   #define CYTHON_COMPILING_IN_CPYTHON 1
157   #ifndef CYTHON_USE_TYPE_SLOTS
158     #define CYTHON_USE_TYPE_SLOTS 1
159   #endif
160   #if PY_VERSION_HEX < 0x02070000
161     #undef CYTHON_USE_PYTYPE_LOOKUP
162     #define CYTHON_USE_PYTYPE_LOOKUP 0
163   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
164     #define CYTHON_USE_PYTYPE_LOOKUP 1
165   #endif
166   #if PY_MAJOR_VERSION < 3
167     #undef CYTHON_USE_ASYNC_SLOTS
168     #define CYTHON_USE_ASYNC_SLOTS 0
169   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
170     #define CYTHON_USE_ASYNC_SLOTS 1
171   #endif
172   #if PY_VERSION_HEX < 0x02070000
173     #undef CYTHON_USE_PYLONG_INTERNALS
174     #define CYTHON_USE_PYLONG_INTERNALS 0
175   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
176     #define CYTHON_USE_PYLONG_INTERNALS 1
177   #endif
178   #ifndef CYTHON_USE_PYLIST_INTERNALS
179     #define CYTHON_USE_PYLIST_INTERNALS 1
180   #endif
181   #ifndef CYTHON_USE_UNICODE_INTERNALS
182     #define CYTHON_USE_UNICODE_INTERNALS 1
183   #endif
184   #if PY_VERSION_HEX < 0x030300F0
185     #undef CYTHON_USE_UNICODE_WRITER
186     #define CYTHON_USE_UNICODE_WRITER 0
187   #elif !defined(CYTHON_USE_UNICODE_WRITER)
188     #define CYTHON_USE_UNICODE_WRITER 1
189   #endif
190   #ifndef CYTHON_AVOID_BORROWED_REFS
191     #define CYTHON_AVOID_BORROWED_REFS 0
192   #endif
193   #ifndef CYTHON_ASSUME_SAFE_MACROS
194     #define CYTHON_ASSUME_SAFE_MACROS 1
195   #endif
196   #ifndef CYTHON_UNPACK_METHODS
197     #define CYTHON_UNPACK_METHODS 1
198   #endif
199   #ifndef CYTHON_FAST_THREAD_STATE
200     #define CYTHON_FAST_THREAD_STATE 1
201   #endif
202   #ifndef CYTHON_FAST_PYCALL
203     #define CYTHON_FAST_PYCALL 1
204   #endif
205   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
206     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
207   #endif
208   #ifndef CYTHON_USE_TP_FINALIZE
209     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
210   #endif
211   #ifndef CYTHON_USE_DICT_VERSIONS
212     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
213   #endif
214   #ifndef CYTHON_USE_EXC_INFO_STACK
215     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
216   #endif
217 #endif
218 #if !defined(CYTHON_FAST_PYCCALL)
219 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
220 #endif
221 #if CYTHON_USE_PYLONG_INTERNALS
222   #include "longintrepr.h"
223   #undef SHIFT
224   #undef BASE
225   #undef MASK
226   #ifdef SIZEOF_VOID_P
227     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
228   #endif
229 #endif
230 #ifndef __has_attribute
231   #define __has_attribute(x) 0
232 #endif
233 #ifndef __has_cpp_attribute
234   #define __has_cpp_attribute(x) 0
235 #endif
236 #ifndef CYTHON_RESTRICT
237   #if defined(__GNUC__)
238     #define CYTHON_RESTRICT __restrict__
239   #elif defined(_MSC_VER) && _MSC_VER >= 1400
240     #define CYTHON_RESTRICT __restrict
241   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
242     #define CYTHON_RESTRICT restrict
243   #else
244     #define CYTHON_RESTRICT
245   #endif
246 #endif
247 #ifndef CYTHON_UNUSED
248 # if defined(__GNUC__)
249 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
250 #     define CYTHON_UNUSED __attribute__ ((__unused__))
251 #   else
252 #     define CYTHON_UNUSED
253 #   endif
254 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
255 #   define CYTHON_UNUSED __attribute__ ((__unused__))
256 # else
257 #   define CYTHON_UNUSED
258 # endif
259 #endif
260 #ifndef CYTHON_MAYBE_UNUSED_VAR
261 #  if defined(__cplusplus)
262      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
263 #  else
264 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
265 #  endif
266 #endif
267 #ifndef CYTHON_NCP_UNUSED
268 # if CYTHON_COMPILING_IN_CPYTHON
269 #  define CYTHON_NCP_UNUSED
270 # else
271 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
272 # endif
273 #endif
274 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
275 #ifdef _MSC_VER
276     #ifndef _MSC_STDINT_H_
277         #if _MSC_VER < 1300
278            typedef unsigned char     uint8_t;
279            typedef unsigned int      uint32_t;
280         #else
281            typedef unsigned __int8   uint8_t;
282            typedef unsigned __int32  uint32_t;
283         #endif
284     #endif
285 #else
286    #include <stdint.h>
287 #endif
288 #ifndef CYTHON_FALLTHROUGH
289   #if defined(__cplusplus) && __cplusplus >= 201103L
290     #if __has_cpp_attribute(fallthrough)
291       #define CYTHON_FALLTHROUGH [[fallthrough]]
292     #elif __has_cpp_attribute(clang::fallthrough)
293       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
294     #elif __has_cpp_attribute(gnu::fallthrough)
295       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
296     #endif
297   #endif
298   #ifndef CYTHON_FALLTHROUGH
299     #if __has_attribute(fallthrough)
300       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
301     #else
302       #define CYTHON_FALLTHROUGH
303     #endif
304   #endif
305   #if defined(__clang__ ) && defined(__apple_build_version__)
306     #if __apple_build_version__ < 7000000
307       #undef  CYTHON_FALLTHROUGH
308       #define CYTHON_FALLTHROUGH
309     #endif
310   #endif
311 #endif
312
313 #ifndef CYTHON_INLINE
314   #if defined(__clang__)
315     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
316   #elif defined(__GNUC__)
317     #define CYTHON_INLINE __inline__
318   #elif defined(_MSC_VER)
319     #define CYTHON_INLINE __inline
320   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
321     #define CYTHON_INLINE inline
322   #else
323     #define CYTHON_INLINE
324   #endif
325 #endif
326
327 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
328   #define Py_OptimizeFlag 0
329 #endif
330 #define __PYX_BUILD_PY_SSIZE_T "n"
331 #define CYTHON_FORMAT_SSIZE_T "z"
332 #if PY_MAJOR_VERSION < 3
333   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
334   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
335           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
336   #define __Pyx_DefaultClassType PyClass_Type
337 #else
338   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
339 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
340   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
341           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
342 #else
343   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
344           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
345 #endif
346   #define __Pyx_DefaultClassType PyType_Type
347 #endif
348 #ifndef Py_TPFLAGS_CHECKTYPES
349   #define Py_TPFLAGS_CHECKTYPES 0
350 #endif
351 #ifndef Py_TPFLAGS_HAVE_INDEX
352   #define Py_TPFLAGS_HAVE_INDEX 0
353 #endif
354 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
355   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
356 #endif
357 #ifndef Py_TPFLAGS_HAVE_FINALIZE
358   #define Py_TPFLAGS_HAVE_FINALIZE 0
359 #endif
360 #ifndef METH_STACKLESS
361   #define METH_STACKLESS 0
362 #endif
363 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
364   #ifndef METH_FASTCALL
365      #define METH_FASTCALL 0x80
366   #endif
367   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
368   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
369                                                           Py_ssize_t nargs, PyObject *kwnames);
370 #else
371   #define __Pyx_PyCFunctionFast _PyCFunctionFast
372   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
373 #endif
374 #if CYTHON_FAST_PYCCALL
375 #define __Pyx_PyFastCFunction_Check(func)\
376     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
377 #else
378 #define __Pyx_PyFastCFunction_Check(func) 0
379 #endif
380 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
381   #define PyObject_Malloc(s)   PyMem_Malloc(s)
382   #define PyObject_Free(p)     PyMem_Free(p)
383   #define PyObject_Realloc(p)  PyMem_Realloc(p)
384 #endif
385 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
386   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
387   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
388   #define PyMem_RawFree(p)             PyMem_Free(p)
389 #endif
390 #if CYTHON_COMPILING_IN_PYSTON
391   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
392   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
393 #else
394   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
395   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
396 #endif
397 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
398   #define __Pyx_PyThreadState_Current PyThreadState_GET()
399 #elif PY_VERSION_HEX >= 0x03060000
400   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
401 #elif PY_VERSION_HEX >= 0x03000000
402   #define __Pyx_PyThreadState_Current PyThreadState_GET()
403 #else
404   #define __Pyx_PyThreadState_Current _PyThreadState_Current
405 #endif
406 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
407 #include "pythread.h"
408 #define Py_tss_NEEDS_INIT 0
409 typedef int Py_tss_t;
410 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
411   *key = PyThread_create_key();
412   return 0;
413 }
414 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
415   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
416   *key = Py_tss_NEEDS_INIT;
417   return key;
418 }
419 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
420   PyObject_Free(key);
421 }
422 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
423   return *key != Py_tss_NEEDS_INIT;
424 }
425 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
426   PyThread_delete_key(*key);
427   *key = Py_tss_NEEDS_INIT;
428 }
429 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
430   return PyThread_set_key_value(*key, value);
431 }
432 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
433   return PyThread_get_key_value(*key);
434 }
435 #endif
436 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
437 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
438 #else
439 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
440 #endif
441 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
442   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
443   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
444 #else
445   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
446   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
447 #endif
448 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
449 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
450 #else
451 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
452 #endif
453 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
454   #define CYTHON_PEP393_ENABLED 1
455   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
456                                               0 : _PyUnicode_Ready((PyObject *)(op)))
457   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
458   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
459   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
460   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
461   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
462   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
463   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
464   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
465 #else
466   #define CYTHON_PEP393_ENABLED 0
467   #define PyUnicode_1BYTE_KIND  1
468   #define PyUnicode_2BYTE_KIND  2
469   #define PyUnicode_4BYTE_KIND  4
470   #define __Pyx_PyUnicode_READY(op)       (0)
471   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
472   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
473   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
474   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
475   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
476   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
477   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
478   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
479 #endif
480 #if CYTHON_COMPILING_IN_PYPY
481   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
482   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
483 #else
484   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
485   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
486       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
487 #endif
488 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
489   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
490 #endif
491 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
492   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
493 #endif
494 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
495   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
496 #endif
497 #define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
498 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
499 #if PY_MAJOR_VERSION >= 3
500   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
501 #else
502   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
503 #endif
504 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
505   #define PyObject_ASCII(o)            PyObject_Repr(o)
506 #endif
507 #if PY_MAJOR_VERSION >= 3
508   #define PyBaseString_Type            PyUnicode_Type
509   #define PyStringObject               PyUnicodeObject
510   #define PyString_Type                PyUnicode_Type
511   #define PyString_Check               PyUnicode_Check
512   #define PyString_CheckExact          PyUnicode_CheckExact
513 #ifndef PyObject_Unicode
514   #define PyObject_Unicode             PyObject_Str
515 #endif
516 #endif
517 #if PY_MAJOR_VERSION >= 3
518   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
519   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
520 #else
521   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
522   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
523 #endif
524 #ifndef PySet_CheckExact
525   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
526 #endif
527 #if CYTHON_ASSUME_SAFE_MACROS
528   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
529 #else
530   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
531 #endif
532 #if PY_MAJOR_VERSION >= 3
533   #define PyIntObject                  PyLongObject
534   #define PyInt_Type                   PyLong_Type
535   #define PyInt_Check(op)              PyLong_Check(op)
536   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
537   #define PyInt_FromString             PyLong_FromString
538   #define PyInt_FromUnicode            PyLong_FromUnicode
539   #define PyInt_FromLong               PyLong_FromLong
540   #define PyInt_FromSize_t             PyLong_FromSize_t
541   #define PyInt_FromSsize_t            PyLong_FromSsize_t
542   #define PyInt_AsLong                 PyLong_AsLong
543   #define PyInt_AS_LONG                PyLong_AS_LONG
544   #define PyInt_AsSsize_t              PyLong_AsSsize_t
545   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
546   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
547   #define PyNumber_Int                 PyNumber_Long
548 #endif
549 #if PY_MAJOR_VERSION >= 3
550   #define PyBoolObject                 PyLongObject
551 #endif
552 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
553   #ifndef PyUnicode_InternFromString
554     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
555   #endif
556 #endif
557 #if PY_VERSION_HEX < 0x030200A4
558   typedef long Py_hash_t;
559   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
560   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
561 #else
562   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
563   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
564 #endif
565 #if PY_MAJOR_VERSION >= 3
566   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
567 #else
568   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
569 #endif
570 #if CYTHON_USE_ASYNC_SLOTS
571   #if PY_VERSION_HEX >= 0x030500B1
572     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
573     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
574   #else
575     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
576   #endif
577 #else
578   #define __Pyx_PyType_AsAsync(obj) NULL
579 #endif
580 #ifndef __Pyx_PyAsyncMethodsStruct
581     typedef struct {
582         unaryfunc am_await;
583         unaryfunc am_aiter;
584         unaryfunc am_anext;
585     } __Pyx_PyAsyncMethodsStruct;
586 #endif
587
588 #if defined(WIN32) || defined(MS_WINDOWS)
589   #define _USE_MATH_DEFINESg
590 #endif
591 #include <math.h>
592 #ifdef NAN
593 #define __PYX_NAN() ((float) NAN)
594 #else
595 static CYTHON_INLINE float __PYX_NAN() {
596   float value;
597   memset(&value, 0xFF, sizeof(value));
598   return value;
599 }
600 #endif
601 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
602 #define __Pyx_truncl trunc
603 #else
604 #define __Pyx_truncl truncl
605 #endif
606
607 #define __PYX_MARK_ERR_POS(f_index, lineno) \
608     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
609 #define __PYX_ERR(f_index, lineno, Ln_error) \
610     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
611
612 #ifndef __PYX_EXTERN_C
613   #ifdef __cplusplus
614     #define __PYX_EXTERN_C extern "C"
615   #else
616     #define __PYX_EXTERN_C extern
617   #endif
618 #endif
619
620 #define __PYX_HAVE__lxml__html__diff
621 #define __PYX_HAVE_API__lxml__html__diff
622 /* Early includes */
623 #ifdef _OPENMP
624 #include <omp.h>
625 #endif /* _OPENMP */
626
627 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
628 #define CYTHON_WITHOUT_ASSERTIONS
629 #endif
630
631 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
632                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
633
634 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
635 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
636 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
637 #define __PYX_DEFAULT_STRING_ENCODING ""
638 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
639 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
640 #define __Pyx_uchar_cast(c) ((unsigned char)c)
641 #define __Pyx_long_cast(x) ((long)x)
642 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
643     (sizeof(type) < sizeof(Py_ssize_t))  ||\
644     (sizeof(type) > sizeof(Py_ssize_t) &&\
645           likely(v < (type)PY_SSIZE_T_MAX ||\
646                  v == (type)PY_SSIZE_T_MAX)  &&\
647           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
648                                 v == (type)PY_SSIZE_T_MIN)))  ||\
649     (sizeof(type) == sizeof(Py_ssize_t) &&\
650           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
651                                v == (type)PY_SSIZE_T_MAX)))  )
652 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
653     return (size_t) i < (size_t) limit;
654 }
655 #if defined (__cplusplus) && __cplusplus >= 201103L
656     #include <cstdlib>
657     #define __Pyx_sst_abs(value) std::abs(value)
658 #elif SIZEOF_INT >= SIZEOF_SIZE_T
659     #define __Pyx_sst_abs(value) abs(value)
660 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
661     #define __Pyx_sst_abs(value) labs(value)
662 #elif defined (_MSC_VER)
663     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
664 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
665     #define __Pyx_sst_abs(value) llabs(value)
666 #elif defined (__GNUC__)
667     #define __Pyx_sst_abs(value) __builtin_llabs(value)
668 #else
669     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
670 #endif
671 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
672 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
673 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
674 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
675 #define __Pyx_PyBytes_FromString        PyBytes_FromString
676 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
677 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
678 #if PY_MAJOR_VERSION < 3
679     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
680     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
681 #else
682     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
683     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
684 #endif
685 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
686 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
688 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
689 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
690 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
691 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
692 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
693 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
694 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
695 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
696 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
697 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
698 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
699 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
700 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
701 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
702     const Py_UNICODE *u_end = u;
703     while (*u_end++) ;
704     return (size_t)(u_end - u - 1);
705 }
706 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
707 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
708 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
709 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
710 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
711 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
712 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
713 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
714 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
715 #define __Pyx_PySequence_Tuple(obj)\
716     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
717 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
718 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
719 #if CYTHON_ASSUME_SAFE_MACROS
720 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
721 #else
722 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
723 #endif
724 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
725 #if PY_MAJOR_VERSION >= 3
726 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
727 #else
728 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
729 #endif
730 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
731 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
732 static int __Pyx_sys_getdefaultencoding_not_ascii;
733 static int __Pyx_init_sys_getdefaultencoding_params(void) {
734     PyObject* sys;
735     PyObject* default_encoding = NULL;
736     PyObject* ascii_chars_u = NULL;
737     PyObject* ascii_chars_b = NULL;
738     const char* default_encoding_c;
739     sys = PyImport_ImportModule("sys");
740     if (!sys) goto bad;
741     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
742     Py_DECREF(sys);
743     if (!default_encoding) goto bad;
744     default_encoding_c = PyBytes_AsString(default_encoding);
745     if (!default_encoding_c) goto bad;
746     if (strcmp(default_encoding_c, "ascii") == 0) {
747         __Pyx_sys_getdefaultencoding_not_ascii = 0;
748     } else {
749         char ascii_chars[128];
750         int c;
751         for (c = 0; c < 128; c++) {
752             ascii_chars[c] = c;
753         }
754         __Pyx_sys_getdefaultencoding_not_ascii = 1;
755         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
756         if (!ascii_chars_u) goto bad;
757         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
758         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
759             PyErr_Format(
760                 PyExc_ValueError,
761                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
762                 default_encoding_c);
763             goto bad;
764         }
765         Py_DECREF(ascii_chars_u);
766         Py_DECREF(ascii_chars_b);
767     }
768     Py_DECREF(default_encoding);
769     return 0;
770 bad:
771     Py_XDECREF(default_encoding);
772     Py_XDECREF(ascii_chars_u);
773     Py_XDECREF(ascii_chars_b);
774     return -1;
775 }
776 #endif
777 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
778 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
779 #else
780 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
781 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
782 static char* __PYX_DEFAULT_STRING_ENCODING;
783 static int __Pyx_init_sys_getdefaultencoding_params(void) {
784     PyObject* sys;
785     PyObject* default_encoding = NULL;
786     char* default_encoding_c;
787     sys = PyImport_ImportModule("sys");
788     if (!sys) goto bad;
789     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
790     Py_DECREF(sys);
791     if (!default_encoding) goto bad;
792     default_encoding_c = PyBytes_AsString(default_encoding);
793     if (!default_encoding_c) goto bad;
794     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
795     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
796     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
797     Py_DECREF(default_encoding);
798     return 0;
799 bad:
800     Py_XDECREF(default_encoding);
801     return -1;
802 }
803 #endif
804 #endif
805
806
807 /* Test for GCC > 2.95 */
808 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
809   #define likely(x)   __builtin_expect(!!(x), 1)
810   #define unlikely(x) __builtin_expect(!!(x), 0)
811 #else /* !__GNUC__ or GCC < 2.95 */
812   #define likely(x)   (x)
813   #define unlikely(x) (x)
814 #endif /* __GNUC__ */
815 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
816
817 static PyObject *__pyx_m = NULL;
818 static PyObject *__pyx_d;
819 static PyObject *__pyx_b;
820 static PyObject *__pyx_cython_runtime = NULL;
821 static PyObject *__pyx_empty_tuple;
822 static PyObject *__pyx_empty_bytes;
823 static PyObject *__pyx_empty_unicode;
824 static int __pyx_lineno;
825 static int __pyx_clineno = 0;
826 static const char * __pyx_cfilenm= __FILE__;
827 static const char *__pyx_filename;
828
829
830 static const char *__pyx_f[] = {
831   "src/lxml/html/diff.py",
832 };
833
834 /*--- Type declarations ---*/
835 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens;
836 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens;
837 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el;
838 struct __pyx_defaults;
839 typedef struct __pyx_defaults __pyx_defaults;
840 struct __pyx_defaults {
841   PyObject *__pyx_arg_markup;
842 };
843
844 /* "lxml/html/diff.py":137
845  *         tokens[-1] = merged
846  * 
847  * def markup_serialize_tokens(tokens, markup_func):             # <<<<<<<<<<<<<<
848  *     """
849  *     Serialize the list of tokens into a list of text chunks, calling
850  */
851 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens {
852   PyObject_HEAD
853   PyObject *__pyx_v_html;
854   PyObject *__pyx_v_markup_func;
855   PyObject *__pyx_v_post;
856   PyObject *__pyx_v_pre;
857   PyObject *__pyx_v_token;
858   PyObject *__pyx_v_tokens;
859   PyObject *__pyx_t_0;
860   Py_ssize_t __pyx_t_1;
861   PyObject *(*__pyx_t_2)(PyObject *);
862   PyObject *__pyx_t_3;
863   Py_ssize_t __pyx_t_4;
864   PyObject *(*__pyx_t_5)(PyObject *);
865 };
866
867
868 /* "lxml/html/diff.py":219
869  *     return result
870  * 
871  * def expand_tokens(tokens, equal=False):             # <<<<<<<<<<<<<<
872  *     """Given a list of tokens, return a generator of the chunks of
873  *     text for the data in the tokens.
874  */
875 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens {
876   PyObject_HEAD
877   PyObject *__pyx_v_equal;
878   PyObject *__pyx_v_post;
879   PyObject *__pyx_v_pre;
880   PyObject *__pyx_v_token;
881   PyObject *__pyx_v_tokens;
882   PyObject *__pyx_t_0;
883   Py_ssize_t __pyx_t_1;
884   PyObject *(*__pyx_t_2)(PyObject *);
885   PyObject *__pyx_t_3;
886   Py_ssize_t __pyx_t_4;
887   PyObject *(*__pyx_t_5)(PyObject *);
888 };
889
890
891 /* "lxml/html/diff.py":684
892  * 
893  * 
894  * def flatten_el(el, include_hrefs, skip_tag=False):             # <<<<<<<<<<<<<<
895  *     """ Takes an lxml element el, and generates all the text chunks for
896  *     that tag.  Each start tag is a chunk, each word is a chunk, and each
897  */
898 struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el {
899   PyObject_HEAD
900   PyObject *__pyx_v_child;
901   PyObject *__pyx_v_el;
902   PyObject *__pyx_v_end_words;
903   PyObject *__pyx_v_include_hrefs;
904   PyObject *__pyx_v_item;
905   PyObject *__pyx_v_skip_tag;
906   PyObject *__pyx_v_start_words;
907   PyObject *__pyx_v_word;
908   PyObject *__pyx_t_0;
909   Py_ssize_t __pyx_t_1;
910   PyObject *(*__pyx_t_2)(PyObject *);
911   PyObject *__pyx_t_3;
912   Py_ssize_t __pyx_t_4;
913   PyObject *(*__pyx_t_5)(PyObject *);
914 };
915
916
917 /* --- Runtime support code (head) --- */
918 /* Refnanny.proto */
919 #ifndef CYTHON_REFNANNY
920   #define CYTHON_REFNANNY 0
921 #endif
922 #if CYTHON_REFNANNY
923   typedef struct {
924     void (*INCREF)(void*, PyObject*, int);
925     void (*DECREF)(void*, PyObject*, int);
926     void (*GOTREF)(void*, PyObject*, int);
927     void (*GIVEREF)(void*, PyObject*, int);
928     void* (*SetupContext)(const char*, int, const char*);
929     void (*FinishContext)(void**);
930   } __Pyx_RefNannyAPIStruct;
931   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
932   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
933   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
934 #ifdef WITH_THREAD
935   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
936           if (acquire_gil) {\
937               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
938               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
939               PyGILState_Release(__pyx_gilstate_save);\
940           } else {\
941               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
942           }
943 #else
944   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
945           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
946 #endif
947   #define __Pyx_RefNannyFinishContext()\
948           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
949   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
950   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
951   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
952   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
953   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
954   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
955   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
956   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
957 #else
958   #define __Pyx_RefNannyDeclarations
959   #define __Pyx_RefNannySetupContext(name, acquire_gil)
960   #define __Pyx_RefNannyFinishContext()
961   #define __Pyx_INCREF(r) Py_INCREF(r)
962   #define __Pyx_DECREF(r) Py_DECREF(r)
963   #define __Pyx_GOTREF(r)
964   #define __Pyx_GIVEREF(r)
965   #define __Pyx_XINCREF(r) Py_XINCREF(r)
966   #define __Pyx_XDECREF(r) Py_XDECREF(r)
967   #define __Pyx_XGOTREF(r)
968   #define __Pyx_XGIVEREF(r)
969 #endif
970 #define __Pyx_XDECREF_SET(r, v) do {\
971         PyObject *tmp = (PyObject *) r;\
972         r = v; __Pyx_XDECREF(tmp);\
973     } while (0)
974 #define __Pyx_DECREF_SET(r, v) do {\
975         PyObject *tmp = (PyObject *) r;\
976         r = v; __Pyx_DECREF(tmp);\
977     } while (0)
978 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
979 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
980
981 /* PyObjectGetAttrStr.proto */
982 #if CYTHON_USE_TYPE_SLOTS
983 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
984 #else
985 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
986 #endif
987
988 /* GetBuiltinName.proto */
989 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
990
991 /* RaiseArgTupleInvalid.proto */
992 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
993     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
994
995 /* RaiseDoubleKeywords.proto */
996 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
997
998 /* ParseKeywords.proto */
999 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1000     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1001     const char* function_name);
1002
1003 /* PyDictVersioning.proto */
1004 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1005 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1006 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1007 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1008     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1009     (cache_var) = (value);
1010 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1011     static PY_UINT64_T __pyx_dict_version = 0;\
1012     static PyObject *__pyx_dict_cached_value = NULL;\
1013     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1014         (VAR) = __pyx_dict_cached_value;\
1015     } else {\
1016         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1017         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1018     }\
1019 }
1020 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1021 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1022 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1023 #else
1024 #define __PYX_GET_DICT_VERSION(dict)  (0)
1025 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1026 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1027 #endif
1028
1029 /* GetModuleGlobalName.proto */
1030 #if CYTHON_USE_DICT_VERSIONS
1031 #define __Pyx_GetModuleGlobalName(var, name)  {\
1032     static PY_UINT64_T __pyx_dict_version = 0;\
1033     static PyObject *__pyx_dict_cached_value = NULL;\
1034     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1035         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1036         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1037 }
1038 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1039     PY_UINT64_T __pyx_dict_version;\
1040     PyObject *__pyx_dict_cached_value;\
1041     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1042 }
1043 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1044 #else
1045 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1046 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1047 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1048 #endif
1049
1050 /* PyCFunctionFastCall.proto */
1051 #if CYTHON_FAST_PYCCALL
1052 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1053 #else
1054 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1055 #endif
1056
1057 /* PyFunctionFastCall.proto */
1058 #if CYTHON_FAST_PYCALL
1059 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1060     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1061 #if 1 || PY_VERSION_HEX < 0x030600B1
1062 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1063 #else
1064 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1065 #endif
1066 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1067     (sizeof(char [1 - 2*!(cond)]) - 1)
1068 #ifndef Py_MEMBER_SIZE
1069 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1070 #endif
1071   static size_t __pyx_pyframe_localsplus_offset = 0;
1072   #include "frameobject.h"
1073   #define __Pxy_PyFrame_Initialize_Offsets()\
1074     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1075      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1076   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1077     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1078 #endif
1079
1080 /* PyObjectCall.proto */
1081 #if CYTHON_COMPILING_IN_CPYTHON
1082 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1083 #else
1084 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1085 #endif
1086
1087 /* PyObjectCall2Args.proto */
1088 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1089
1090 /* PyObjectCallMethO.proto */
1091 #if CYTHON_COMPILING_IN_CPYTHON
1092 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1093 #endif
1094
1095 /* PyObjectCallOneArg.proto */
1096 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1097
1098 /* PyObjectFormatAndDecref.proto */
1099 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
1100 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
1101
1102 /* IncludeStringH.proto */
1103 #include <string.h>
1104
1105 /* JoinPyUnicode.proto */
1106 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
1107                                       Py_UCS4 max_char);
1108
1109 /* RaiseTooManyValuesToUnpack.proto */
1110 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1111
1112 /* RaiseNeedMoreValuesToUnpack.proto */
1113 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1114
1115 /* IterFinish.proto */
1116 static CYTHON_INLINE int __Pyx_IterFinish(void);
1117
1118 /* UnpackItemEndCheck.proto */
1119 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1120
1121 /* ListCompAppend.proto */
1122 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1123 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1124     PyListObject* L = (PyListObject*) list;
1125     Py_ssize_t len = Py_SIZE(list);
1126     if (likely(L->allocated > len)) {
1127         Py_INCREF(x);
1128         PyList_SET_ITEM(list, len, x);
1129         Py_SIZE(list) = len+1;
1130         return 0;
1131     }
1132     return PyList_Append(list, x);
1133 }
1134 #else
1135 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1136 #endif
1137
1138 /* GetItemInt.proto */
1139 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1140     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1141     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1142     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1143                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1144 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1145     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1146     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1147     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1148 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1149                                                               int wraparound, int boundscheck);
1150 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1151     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1152     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1153     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1154 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1155                                                               int wraparound, int boundscheck);
1156 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1157 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1158                                                      int is_list, int wraparound, int boundscheck);
1159
1160 /* SliceTupleAndList.proto */
1161 #if CYTHON_COMPILING_IN_CPYTHON
1162 static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
1163 static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
1164 #else
1165 #define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
1166 #define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
1167 #endif
1168
1169 /* PyObjectCallNoArg.proto */
1170 #if CYTHON_COMPILING_IN_CPYTHON
1171 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1172 #else
1173 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1174 #endif
1175
1176 /* PyObjectSetAttrStr.proto */
1177 #if CYTHON_USE_TYPE_SLOTS
1178 #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
1179 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
1180 #else
1181 #define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
1182 #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
1183 #endif
1184
1185 /* BytesEquals.proto */
1186 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1187
1188 /* UnicodeEquals.proto */
1189 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1190
1191 /* SliceObject.proto */
1192 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1193         PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1194         PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1195         int has_cstart, int has_cstop, int wraparound);
1196
1197 /* ListAppend.proto */
1198 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1199 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1200     PyListObject* L = (PyListObject*) list;
1201     Py_ssize_t len = Py_SIZE(list);
1202     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1203         Py_INCREF(x);
1204         PyList_SET_ITEM(list, len, x);
1205         Py_SIZE(list) = len+1;
1206         return 0;
1207     }
1208     return PyList_Append(list, x);
1209 }
1210 #else
1211 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1212 #endif
1213
1214 /* PyObjectGetMethod.proto */
1215 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1216
1217 /* PyObjectCallMethod1.proto */
1218 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
1219
1220 /* append.proto */
1221 static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);
1222
1223 /* SetItemInt.proto */
1224 #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1225     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1226     __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
1227     (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
1228                __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
1229 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
1230 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
1231                                                int is_list, int wraparound, int boundscheck);
1232
1233 /* GetTopmostException.proto */
1234 #if CYTHON_USE_EXC_INFO_STACK
1235 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1236 #endif
1237
1238 /* PyThreadStateGet.proto */
1239 #if CYTHON_FAST_THREAD_STATE
1240 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1241 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1242 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1243 #else
1244 #define __Pyx_PyThreadState_declare
1245 #define __Pyx_PyThreadState_assign
1246 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1247 #endif
1248
1249 /* SaveResetException.proto */
1250 #if CYTHON_FAST_THREAD_STATE
1251 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1252 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1253 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1254 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1255 #else
1256 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1257 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1258 #endif
1259
1260 /* PyErrFetchRestore.proto */
1261 #if CYTHON_FAST_THREAD_STATE
1262 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1263 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1264 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1265 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1266 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1267 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1268 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1269 #if CYTHON_COMPILING_IN_CPYTHON
1270 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1271 #else
1272 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1273 #endif
1274 #else
1275 #define __Pyx_PyErr_Clear() PyErr_Clear()
1276 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1277 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1278 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1279 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1280 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1281 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1282 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1283 #endif
1284
1285 /* FastTypeChecks.proto */
1286 #if CYTHON_COMPILING_IN_CPYTHON
1287 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1288 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1289 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1290 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1291 #else
1292 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1293 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1294 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1295 #endif
1296 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1297
1298 /* GetException.proto */
1299 #if CYTHON_FAST_THREAD_STATE
1300 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1301 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1302 #else
1303 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1304 #endif
1305
1306 /* PySequenceContains.proto */
1307 static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
1308     int result = PySequence_Contains(seq, item);
1309     return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1310 }
1311
1312 /* PyObjectCallMethod0.proto */
1313 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1314
1315 /* pop.proto */
1316 static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
1317 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1318 static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
1319 #define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
1320     __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
1321 #else
1322 #define __Pyx_PyList_Pop(L)  __Pyx__PyObject_Pop(L)
1323 #define __Pyx_PyObject_Pop(L)  __Pyx__PyObject_Pop(L)
1324 #endif
1325
1326 /* UnpackUnboundCMethod.proto */
1327 typedef struct {
1328     PyObject *type;
1329     PyObject **method_name;
1330     PyCFunction func;
1331     PyObject *method;
1332     int flag;
1333 } __Pyx_CachedCFunction;
1334
1335 /* CallUnboundCMethod0.proto */
1336 static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
1337 #if CYTHON_COMPILING_IN_CPYTHON
1338 #define __Pyx_CallUnboundCMethod0(cfunc, self)\
1339     (likely((cfunc)->func) ?\
1340         (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
1341          (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
1342             (PY_VERSION_HEX >= 0x030700A0 ?\
1343                 (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
1344                 (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
1345           (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
1346             (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
1347             (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
1348                ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
1349                __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
1350         __Pyx__CallUnboundCMethod0(cfunc, self))
1351 #else
1352 #define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
1353 #endif
1354
1355 /* ListExtend.proto */
1356 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
1357 #if CYTHON_COMPILING_IN_CPYTHON
1358     PyObject* none = _PyList_Extend((PyListObject*)L, v);
1359     if (unlikely(!none))
1360         return -1;
1361     Py_DECREF(none);
1362     return 0;
1363 #else
1364     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
1365 #endif
1366 }
1367
1368 /* PyErrExceptionMatches.proto */
1369 #if CYTHON_FAST_THREAD_STATE
1370 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1371 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1372 #else
1373 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1374 #endif
1375
1376 /* RaiseException.proto */
1377 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1378
1379 /* PyIntBinop.proto */
1380 #if !CYTHON_COMPILING_IN_PYPY
1381 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1382 #else
1383 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1384     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1385 #endif
1386
1387 /* pop_index.proto */
1388 static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix);
1389 static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix);
1390 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1391 static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix);
1392 #define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
1393     (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ?\
1394         __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
1395         (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
1396             __Pyx__PyObject_PopIndex(L, py_ix)))
1397 #define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
1398     __Pyx_fits_Py_ssize_t(ix, type, is_signed) ?\
1399         __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
1400         (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
1401             __Pyx__PyObject_PopIndex(L, py_ix)))
1402 #else
1403 #define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)\
1404     __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)
1405 #define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
1406     (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
1407         __Pyx__PyObject_PopIndex(L, py_ix))
1408 #endif
1409
1410 /* RaiseNoneIterError.proto */
1411 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1412
1413 /* UnpackTupleError.proto */
1414 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1415
1416 /* UnpackTuple2.proto */
1417 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1418     (likely(is_tuple || PyTuple_Check(tuple)) ?\
1419         (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1420             __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1421             (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1422         __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1423 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1424     PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1425 static int __Pyx_unpack_tuple2_generic(
1426     PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1427
1428 /* dict_iter.proto */
1429 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1430                                                    Py_ssize_t* p_orig_length, int* p_is_dict);
1431 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1432                                               PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1433
1434 /* SliceObject.proto */
1435 #define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\
1436     __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
1437 static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
1438         PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
1439         PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1440         int has_cstart, int has_cstop, int wraparound);
1441
1442 /* PyIntCompare.proto */
1443 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1444
1445 /* PyIntBinop.proto */
1446 #if !CYTHON_COMPILING_IN_PYPY
1447 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1448 #else
1449 #define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
1450     (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
1451 #endif
1452
1453 /* ObjectGetItem.proto */
1454 #if CYTHON_USE_TYPE_SLOTS
1455 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1456 #else
1457 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1458 #endif
1459
1460 /* PyIntBinop.proto */
1461 #if !CYTHON_COMPILING_IN_PYPY
1462 static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1463 #else
1464 #define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
1465     (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
1466 #endif
1467
1468 /* PyObject_GenericGetAttrNoDict.proto */
1469 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1470 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1471 #else
1472 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1473 #endif
1474
1475 /* Import.proto */
1476 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1477
1478 /* ImportFrom.proto */
1479 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1480
1481 /* FetchCommonType.proto */
1482 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1483
1484 /* CythonFunctionShared.proto */
1485 #define __Pyx_CyFunction_USED 1
1486 #define __Pyx_CYFUNCTION_STATICMETHOD  0x01
1487 #define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
1488 #define __Pyx_CYFUNCTION_CCLASS        0x04
1489 #define __Pyx_CyFunction_GetClosure(f)\
1490     (((__pyx_CyFunctionObject *) (f))->func_closure)
1491 #define __Pyx_CyFunction_GetClassObj(f)\
1492     (((__pyx_CyFunctionObject *) (f))->func_classobj)
1493 #define __Pyx_CyFunction_Defaults(type, f)\
1494     ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1495 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1496     ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1497 typedef struct {
1498     PyCFunctionObject func;
1499 #if PY_VERSION_HEX < 0x030500A0
1500     PyObject *func_weakreflist;
1501 #endif
1502     PyObject *func_dict;
1503     PyObject *func_name;
1504     PyObject *func_qualname;
1505     PyObject *func_doc;
1506     PyObject *func_globals;
1507     PyObject *func_code;
1508     PyObject *func_closure;
1509     PyObject *func_classobj;
1510     void *defaults;
1511     int defaults_pyobjects;
1512     size_t defaults_size;  // used by FusedFunction for copying defaults
1513     int flags;
1514     PyObject *defaults_tuple;
1515     PyObject *defaults_kwdict;
1516     PyObject *(*defaults_getter)(PyObject *);
1517     PyObject *func_annotations;
1518 } __pyx_CyFunctionObject;
1519 static PyTypeObject *__pyx_CyFunctionType = 0;
1520 #define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1521 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
1522                                       int flags, PyObject* qualname,
1523                                       PyObject *self,
1524                                       PyObject *module, PyObject *globals,
1525                                       PyObject* code);
1526 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1527                                                          size_t size,
1528                                                          int pyobjects);
1529 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1530                                                             PyObject *tuple);
1531 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1532                                                              PyObject *dict);
1533 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1534                                                               PyObject *dict);
1535 static int __pyx_CyFunction_init(void);
1536
1537 /* CythonFunction.proto */
1538 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1539                                       int flags, PyObject* qualname,
1540                                       PyObject *closure,
1541                                       PyObject *module, PyObject *globals,
1542                                       PyObject* code);
1543
1544 /* CalculateMetaclass.proto */
1545 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
1546
1547 /* Py3ClassCreate.proto */
1548 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
1549                                            PyObject *mkw, PyObject *modname, PyObject *doc);
1550 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
1551                                       PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
1552
1553 /* SetNameInClass.proto */
1554 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
1555 #define __Pyx_SetNameInClass(ns, name, value)\
1556     (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
1557 #elif CYTHON_COMPILING_IN_CPYTHON
1558 #define __Pyx_SetNameInClass(ns, name, value)\
1559     (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
1560 #else
1561 #define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
1562 #endif
1563
1564 /* RegisterModuleCleanup.proto */
1565 static void __pyx_module_cleanup(PyObject *self);
1566 #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
1567 static int __Pyx_RegisterCleanup(void);
1568 #else
1569 #define __Pyx_RegisterCleanup() (0)
1570 #endif
1571
1572 /* CLineInTraceback.proto */
1573 #ifdef CYTHON_CLINE_IN_TRACEBACK
1574 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1575 #else
1576 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1577 #endif
1578
1579 /* CodeObjectCache.proto */
1580 typedef struct {
1581     PyCodeObject* code_object;
1582     int code_line;
1583 } __Pyx_CodeObjectCacheEntry;
1584 struct __Pyx_CodeObjectCache {
1585     int count;
1586     int max_count;
1587     __Pyx_CodeObjectCacheEntry* entries;
1588 };
1589 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1590 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1591 static PyCodeObject *__pyx_find_code_object(int code_line);
1592 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1593
1594 /* AddTraceback.proto */
1595 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1596                                int py_line, const char *filename);
1597
1598 /* CIntToPy.proto */
1599 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1600
1601 /* CIntFromPy.proto */
1602 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1603
1604 /* CIntFromPy.proto */
1605 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1606
1607 /* SwapException.proto */
1608 #if CYTHON_FAST_THREAD_STATE
1609 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1610 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1611 #else
1612 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1613 #endif
1614
1615 /* CoroutineBase.proto */
1616 typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
1617 #if CYTHON_USE_EXC_INFO_STACK
1618 #define __Pyx_ExcInfoStruct  _PyErr_StackItem
1619 #else
1620 typedef struct {
1621     PyObject *exc_type;
1622     PyObject *exc_value;
1623     PyObject *exc_traceback;
1624 } __Pyx_ExcInfoStruct;
1625 #endif
1626 typedef struct {
1627     PyObject_HEAD
1628     __pyx_coroutine_body_t body;
1629     PyObject *closure;
1630     __Pyx_ExcInfoStruct gi_exc_state;
1631     PyObject *gi_weakreflist;
1632     PyObject *classobj;
1633     PyObject *yieldfrom;
1634     PyObject *gi_name;
1635     PyObject *gi_qualname;
1636     PyObject *gi_modulename;
1637     PyObject *gi_code;
1638     int resume_label;
1639     char is_running;
1640 } __pyx_CoroutineObject;
1641 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
1642     PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1643     PyObject *name, PyObject *qualname, PyObject *module_name);
1644 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
1645             __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1646             PyObject *name, PyObject *qualname, PyObject *module_name);
1647 static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
1648 static int __Pyx_Coroutine_clear(PyObject *self);
1649 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
1650 static PyObject *__Pyx_Coroutine_Close(PyObject *self);
1651 static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
1652 #if CYTHON_USE_EXC_INFO_STACK
1653 #define __Pyx_Coroutine_SwapException(self)
1654 #define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
1655 #else
1656 #define __Pyx_Coroutine_SwapException(self) {\
1657     __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
1658     __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
1659     }
1660 #define __Pyx_Coroutine_ResetAndClearException(self) {\
1661     __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
1662     (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
1663     }
1664 #endif
1665 #if CYTHON_FAST_THREAD_STATE
1666 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1667     __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
1668 #else
1669 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1670     __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
1671 #endif
1672 static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
1673 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
1674
1675 /* PatchModuleWithCoroutine.proto */
1676 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
1677
1678 /* PatchGeneratorABC.proto */
1679 static int __Pyx_patch_abc(void);
1680
1681 /* Generator.proto */
1682 #define __Pyx_Generator_USED
1683 static PyTypeObject *__pyx_GeneratorType = 0;
1684 #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
1685 #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
1686     __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
1687 static PyObject *__Pyx_Generator_Next(PyObject *self);
1688 static int __pyx_Generator_init(void);
1689
1690 /* CheckBinaryVersion.proto */
1691 static int __Pyx_check_binary_version(void);
1692
1693 /* InitStrings.proto */
1694 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1695
1696
1697 /* Module declarations from 'lxml.html.diff' */
1698 static PyTypeObject *__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens = 0;
1699 static PyTypeObject *__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens = 0;
1700 static PyTypeObject *__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el = 0;
1701 #define __Pyx_MODULE_NAME "lxml.html.diff"
1702 extern int __pyx_module_is_main_lxml__html__diff;
1703 int __pyx_module_is_main_lxml__html__diff = 0;
1704
1705 /* Implementation of 'lxml.html.diff' */
1706 static PyObject *__pyx_builtin_ImportError;
1707 static PyObject *__pyx_builtin_NameError;
1708 static PyObject *__pyx_builtin_zip;
1709 static PyObject *__pyx_builtin_ValueError;
1710 static const char __pyx_k_[] = "\">";
1711 static const char __pyx_k_I[] = "I";
1712 static const char __pyx_k_S[] = "S";
1713 static const char __pyx_k_U[] = "U";
1714 static const char __pyx_k_a[] = "a";
1715 static const char __pyx_k_b[] = "b";
1716 static const char __pyx_k_p[] = "p";
1717 static const char __pyx_k_s[] = "s";
1718 static const char __pyx_k__2[] = "";
1719 static const char __pyx_k__6[] = " ";
1720 static const char __pyx_k__8[] = "<";
1721 static const char __pyx_k__9[] = "/";
1722 static const char __pyx_k_br[] = "br";
1723 static const char __pyx_k_dd[] = "dd";
1724 static const char __pyx_k_dl[] = "dl";
1725 static const char __pyx_k_dt[] = "dt";
1726 static const char __pyx_k_el[] = "el";
1727 static const char __pyx_k_h1[] = "h1";
1728 static const char __pyx_k_h2[] = "h2";
1729 static const char __pyx_k_h3[] = "h3";
1730 static const char __pyx_k_h4[] = "h4";
1731 static const char __pyx_k_h5[] = "h5";
1732 static const char __pyx_k_h6[] = "h6";
1733 static const char __pyx_k_hr[] = "hr";
1734 static const char __pyx_k_i1[] = "i1";
1735 static const char __pyx_k_i2[] = "i2";
1736 static const char __pyx_k_j1[] = "j1";
1737 static const char __pyx_k_j2[] = "j2";
1738 static const char __pyx_k_li[] = "li";
1739 static const char __pyx_k_of[] = " of ";
1740 static const char __pyx_k_ol[] = "ol";
1741 static const char __pyx_k_re[] = "re";
1742 static const char __pyx_k_td[] = "td";
1743 static const char __pyx_k_th[] = "th";
1744 static const char __pyx_k_tr[] = "tr";
1745 static const char __pyx_k_ul[] = "ul";
1746 static const char __pyx_k_S_s[] = "\\S+(?:\\s+|$)";
1747 static const char __pyx_k__10[] = "<>/";
1748 static const char __pyx_k__11[] = "<>";
1749 static const char __pyx_k__12[] = "</";
1750 static const char __pyx_k__13[] = ", ";
1751 static const char __pyx_k__14[] = ")";
1752 static const char __pyx_k__15[] = ": ";
1753 static const char __pyx_k__18[] = "=\"";
1754 static const char __pyx_k__19[] = "\"";
1755 static const char __pyx_k__20[] = ">";
1756 static const char __pyx_k_all[] = "__all__";
1757 static const char __pyx_k_cgi[] = "cgi";
1758 static const char __pyx_k_cls[] = "cls";
1759 static const char __pyx_k_col[] = "col";
1760 static const char __pyx_k_del[] = "<del>";
1761 static const char __pyx_k_dir[] = "dir";
1762 static const char __pyx_k_div[] = "div";
1763 static const char __pyx_k_doc[] = "doc";
1764 static const char __pyx_k_end[] = "end";
1765 static const char __pyx_k_get[] = "get";
1766 static const char __pyx_k_img[] = "img";
1767 static const char __pyx_k_ins[] = "<ins>";
1768 static const char __pyx_k_new[] = "__new__";
1769 static const char __pyx_k_obj[] = "obj";
1770 static const char __pyx_k_pop[] = "pop";
1771 static const char __pyx_k_pos[] = "pos";
1772 static const char __pyx_k_pre[] = "pre";
1773 static const char __pyx_k_src[] = "src";
1774 static const char __pyx_k_sub[] = "sub";
1775 static const char __pyx_k_tag[] = "tag";
1776 static const char __pyx_k_tok[] = "tok";
1777 static const char __pyx_k_zip[] = "zip";
1778 static const char __pyx_k_area[] = "area";
1779 static const char __pyx_k_args[] = "args";
1780 static const char __pyx_k_base[] = "base";
1781 static const char __pyx_k_body[] = "<body.*?>";
1782 static const char __pyx_k_data[] = "data";
1783 static const char __pyx_k_dest[] = "dest";
1784 static const char __pyx_k_find[] = "find";
1785 static const char __pyx_k_form[] = "form";
1786 static const char __pyx_k_href[] = "href";
1787 static const char __pyx_k_html[] = "html";
1788 static const char __pyx_k_item[] = "item";
1789 static const char __pyx_k_last[] = "last";
1790 static const char __pyx_k_link[] = "link";
1791 static const char __pyx_k_lxml[] = "lxml";
1792 static const char __pyx_k_main[] = "__main__";
1793 static const char __pyx_k_menu[] = "menu";
1794 static const char __pyx_k_meta[] = "meta";
1795 static const char __pyx_k_name[] = "__name__";
1796 static const char __pyx_k_next[] = "next";
1797 static const char __pyx_k_pos2[] = "pos2";
1798 static const char __pyx_k_post[] = "post";
1799 static const char __pyx_k_repr[] = "__repr__";
1800 static const char __pyx_k_self[] = "self";
1801 static const char __pyx_k_send[] = "send";
1802 static const char __pyx_k_size[] = "size";
1803 static const char __pyx_k_span[] = "</span>";
1804 static const char __pyx_k_tail[] = "tail";
1805 static const char __pyx_k_test[] = "__test__";
1806 static const char __pyx_k_text[] = "text";
1807 static const char __pyx_k_word[] = "word";
1808 static const char __pyx_k_child[] = "child";
1809 static const char __pyx_k_chunk[] = "chunk";
1810 static const char __pyx_k_close[] = "close";
1811 static const char __pyx_k_del_2[] = "</del> ";
1812 static const char __pyx_k_del_3[] = "del";
1813 static const char __pyx_k_doc_2[] = "__doc__";
1814 static const char __pyx_k_equal[] = "equal";
1815 static const char __pyx_k_etree[] = "etree";
1816 static const char __pyx_k_extra[] = "extra";
1817 static const char __pyx_k_index[] = "index";
1818 static const char __pyx_k_input[] = "input";
1819 static const char __pyx_k_ins_2[] = "</ins> ";
1820 static const char __pyx_k_ins_3[] = "ins";
1821 static const char __pyx_k_items[] = "items";
1822 static const char __pyx_k_match[] = "match";
1823 static const char __pyx_k_param[] = "param";
1824 static const char __pyx_k_rfind[] = "rfind";
1825 static const char __pyx_k_split[] = "split";
1826 static const char __pyx_k_start[] = "start";
1827 static const char __pyx_k_strip[] = "strip";
1828 static const char __pyx_k_t_n_r[] = "[ \\t\\n\\r]$";
1829 static const char __pyx_k_table[] = "table";
1830 static const char __pyx_k_tbody[] = "tbody";
1831 static const char __pyx_k_tfoot[] = "tfoot";
1832 static const char __pyx_k_thead[] = "thead";
1833 static const char __pyx_k_throw[] = "throw";
1834 static const char __pyx_k_token[] = "token";
1835 static const char __pyx_k_value[] = "value";
1836 static const char __pyx_k_words[] = "words";
1837 static const char __pyx_k_xpath[] = "xpath";
1838 static const char __pyx_k_Link_s[] = " Link: %s";
1839 static const char __pyx_k_actual[] = "actual";
1840 static const char __pyx_k_append[] = "append";
1841 static const char __pyx_k_attrib[] = "attrib";
1842 static const char __pyx_k_body_2[] = "</body.*?>";
1843 static const char __pyx_k_center[] = "center";
1844 static const char __pyx_k_chunks[] = ", chunks=";
1845 static const char __pyx_k_delete[] = "delete";
1846 static const char __pyx_k_endtag[] = "endtag";
1847 static const char __pyx_k_eq_new[] = "eq_new";
1848 static const char __pyx_k_eq_old[] = "eq_old";
1849 static const char __pyx_k_escape[] = "escape";
1850 static const char __pyx_k_extend[] = "extend";
1851 static const char __pyx_k_import[] = "__import__";
1852 static const char __pyx_k_insert[] = "insert";
1853 static const char __pyx_k_main_2[] = "main";
1854 static const char __pyx_k_markup[] = "markup";
1855 static const char __pyx_k_merged[] = "merged";
1856 static const char __pyx_k_method[] = "method";
1857 static const char __pyx_k_module[] = "__module__";
1858 static const char __pyx_k_name_2[] = "name";
1859 static const char __pyx_k_parent[] = "parent";
1860 static const char __pyx_k_result[] = ", result=";
1861 static const char __pyx_k_rstrip[] = "rstrip";
1862 static const char __pyx_k_search[] = "search";
1863 static const char __pyx_k_tokens[] = "tokens";
1864 static const char __pyx_k_DEL_END[] = "DEL_END";
1865 static const char __pyx_k_Element[] = "Element";
1866 static const char __pyx_k_address[] = "address";
1867 static const char __pyx_k_body_el[] = "body_el";
1868 static const char __pyx_k_body_re[] = "_body_re";
1869 static const char __pyx_k_cleanup[] = "cleanup";
1870 static const char __pyx_k_command[] = "command";
1871 static const char __pyx_k_compile[] = "compile";
1872 static const char __pyx_k_difflib[] = "difflib";
1873 static const char __pyx_k_doclist[] = "doclist";
1874 static const char __pyx_k_end_tag[] = "end_tag";
1875 static const char __pyx_k_findall[] = "findall";
1876 static const char __pyx_k_finding[] = "finding";
1877 static const char __pyx_k_ins_del[] = "</?(ins|del).*?>";
1878 static const char __pyx_k_is_word[] = "is_word";
1879 static const char __pyx_k_isindex[] = "isindex";
1880 static const char __pyx_k_prepare[] = "__prepare__";
1881 static const char __pyx_k_replace[] = "replace";
1882 static const char __pyx_k_src_tok[] = "src_tok";
1883 static const char __pyx_k_t_n_r_2[] = "^[ \\t\\n\\r]";
1884 static const char __pyx_k_token_2[] = "token(";
1885 static const char __pyx_k_unicode[] = "_unicode";
1886 static const char __pyx_k_version[] = "version";
1887 static const char __pyx_k_balanced[] = "balanced";
1888 static const char __pyx_k_basefont[] = "basefont";
1889 static const char __pyx_k_chunks_2[] = "chunks";
1890 static const char __pyx_k_commands[] = "commands";
1891 static const char __pyx_k_cur_word[] = "cur_word";
1892 static const char __pyx_k_dest_tok[] = "dest_tok";
1893 static const char __pyx_k_drop_tag[] = "drop_tag";
1894 static const char __pyx_k_encoding[] = "encoding";
1895 static const char __pyx_k_endswith[] = "endswith";
1896 static const char __pyx_k_fieldset[] = "fieldset";
1897 static const char __pyx_k_frameset[] = "frameset";
1898 static const char __pyx_k_htmldiff[] = "htmldiff";
1899 static const char __pyx_k_new_html[] = "new_html";
1900 static const char __pyx_k_noframes[] = "noframes";
1901 static const char __pyx_k_noscript[] = "noscript";
1902 static const char __pyx_k_old_html[] = "old_html";
1903 static const char __pyx_k_pre_tags[] = "pre_tags";
1904 static const char __pyx_k_previous[] = "previous";
1905 static const char __pyx_k_qualname[] = "__qualname__";
1906 static const char __pyx_k_result_2[] = "result";
1907 static const char __pyx_k_skip_tag[] = "skip_tag";
1908 static const char __pyx_k_tail_tag[] = "tail_tag";
1909 static const char __pyx_k_text_tag[] = "text_tag";
1910 static const char __pyx_k_tokenize[] = "tokenize";
1911 static const char __pyx_k_tostring[] = "tostring";
1912 static const char __pyx_k_DEL_START[] = "DEL_START";
1913 static const char __pyx_k_NameError[] = "NameError";
1914 static const char __pyx_k_NoDeletes[] = "NoDeletes";
1915 static const char __pyx_k_child_tag[] = "child_tag";
1916 static const char __pyx_k_end_words[] = "end_words";
1917 static const char __pyx_k_getparent[] = "getparent";
1918 static const char __pyx_k_html_repr[] = "html_repr";
1919 static const char __pyx_k_iselement[] = "iselement";
1920 static const char __pyx_k_lxml_html[] = "lxml.html";
1921 static const char __pyx_k_metaclass[] = "__metaclass__";
1922 static const char __pyx_k_post_tags[] = "post_tags";
1923 static const char __pyx_k_start_tag[] = "start_tag";
1924 static const char __pyx_k_tag_accum[] = "tag_accum";
1925 static const char __pyx_k_tag_stack[] = "tag_stack";
1926 static const char __pyx_k_tag_token[] = "tag_token(";
1927 static const char __pyx_k_threshold[] = "threshold";
1928 static const char __pyx_k_tokenlist[] = "tokenlist";
1929 static const char __pyx_k_ValueError[] = "ValueError";
1930 static const char __pyx_k_annotation[] = "annotation";
1931 static const char __pyx_k_basestring[] = "basestring";
1932 static const char __pyx_k_blockquote[] = "blockquote";
1933 static const char __pyx_k_cur_tokens[] = "cur_tokens";
1934 static const char __pyx_k_del_chunks[] = "del_chunks";
1935 static const char __pyx_k_del_tokens[] = "del_tokens";
1936 static const char __pyx_k_empty_tags[] = "empty_tags";
1937 static const char __pyx_k_flatten_el[] = "flatten_el";
1938 static const char __pyx_k_href_token[] = "href_token";
1939 static const char __pyx_k_ins_chunks[] = "ins_chunks";
1940 static const char __pyx_k_ins_del_re[] = "_ins_del_re";
1941 static const char __pyx_k_ins_tokens[] = "ins_tokens";
1942 static const char __pyx_k_is_end_tag[] = "is_end_tag";
1943 static const char __pyx_k_parse_html[] = "parse_html";
1944 static const char __pyx_k_pre_delete[] = "pre_delete";
1945 static const char __pyx_k_pre_tags_2[] = ", pre_tags=";
1946 static const char __pyx_k_skip_outer[] = "skip_outer";
1947 static const char __pyx_k_span_title[] = "<span title=\"";
1948 static const char __pyx_k_startswith[] = "startswith";
1949 static const char __pyx_k_token_html[] = "token.html";
1950 static const char __pyx_k_tokens_new[] = "tokens_new";
1951 static const char __pyx_k_tokens_old[] = "tokens_old";
1952 static const char __pyx_k_ImportError[] = "ImportError";
1953 static const char __pyx_k_diffcommand[] = "_diffcommand";
1954 static const char __pyx_k_end_body_re[] = "_end_body_re";
1955 static const char __pyx_k_get_opcodes[] = "get_opcodes";
1956 static const char __pyx_k_getchildren[] = "getchildren";
1957 static const char __pyx_k_html_escape[] = "html_escape";
1958 static const char __pyx_k_html_repr_2[] = ", html_repr=";
1959 static const char __pyx_k_markup_func[] = "markup_func";
1960 static const char __pyx_k_post_delete[] = "post_delete";
1961 static const char __pyx_k_post_tags_2[] = ", post_tags=";
1962 static const char __pyx_k_split_words[] = "split_words";
1963 static const char __pyx_k_start_words[] = "start_words";
1964 static const char __pyx_k_tag_token_2[] = "tag_token";
1965 static const char __pyx_k_token___new[] = "token.__new__";
1966 static const char __pyx_k_children_tag[] = "children_tag";
1967 static const char __pyx_k_cleanup_html[] = "cleanup_html";
1968 static const char __pyx_k_finding_name[] = "finding_name";
1969 static const char __pyx_k_fixup_chunks[] = "fixup_chunks";
1970 static const char __pyx_k_html1_tokens[] = "html1_tokens";
1971 static const char __pyx_k_html2_tokens[] = "html2_tokens";
1972 static const char __pyx_k_is_start_tag[] = "is_start_tag";
1973 static const char __pyx_k_merge_delete[] = "merge_delete";
1974 static const char __pyx_k_merge_insert[] = "merge_insert";
1975 static const char __pyx_k_split_delete[] = "split_delete";
1976 static const char __pyx_k_token___repr[] = "token.__repr__";
1977 static const char __pyx_k_create_parent[] = "create_parent";
1978 static const char __pyx_k_expand_tokens[] = "expand_tokens";
1979 static const char __pyx_k_html_annotate[] = "html_annotate";
1980 static const char __pyx_k_include_hrefs[] = "include_hrefs";
1981 static const char __pyx_k_cleanup_delete[] = "cleanup_delete";
1982 static const char __pyx_k_default_markup[] = "default_markup";
1983 static const char __pyx_k_lxml_html_diff[] = "lxml.html.diff";
1984 static const char __pyx_k_split_words_re[] = "split_words_re";
1985 static const char __pyx_k_tag_token_html[] = "tag_token.html";
1986 static const char __pyx_k_unbalanced_end[] = "unbalanced_end";
1987 static const char __pyx_k_SequenceMatcher[] = "SequenceMatcher";
1988 static const char __pyx_k_compress_tokens[] = "compress_tokens";
1989 static const char __pyx_k_hide_when_equal[] = "hide_when_equal";
1990 static const char __pyx_k_href_token_html[] = "href_token.html";
1991 static const char __pyx_k_htmldiff_tokens[] = "htmldiff_tokens";
1992 static const char __pyx_k_new_html_tokens[] = "new_html_tokens";
1993 static const char __pyx_k_old_html_tokens[] = "old_html_tokens";
1994 static const char __pyx_k_stripped_length[] = "stripped_length";
1995 static const char __pyx_k_tag_token___new[] = "tag_token.__new__";
1996 static const char __pyx_k_block_level_tags[] = "block_level_tags";
1997 static const char __pyx_k_copy_annotations[] = "copy_annotations";
1998 static const char __pyx_k_split_unbalanced[] = "split_unbalanced";
1999 static const char __pyx_k_tag_token___repr[] = "tag_token.__repr__";
2000 static const char __pyx_k_unbalanced_start[] = "unbalanced_start";
2001 static const char __pyx_k_end_whitespace_re[] = "end_whitespace_re";
2002 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2003 static const char __pyx_k_fixup_ins_del_tags[] = "fixup_ins_del_tags";
2004 static const char __pyx_k_tokenize_annotated[] = "tokenize_annotated";
2005 static const char __pyx_k_compress_merge_back[] = "compress_merge_back";
2006 static const char __pyx_k_fragment_fromstring[] = "fragment_fromstring";
2007 static const char __pyx_k_get_matching_blocks[] = "get_matching_blocks";
2008 static const char __pyx_k_start_whitespace_re[] = "start_whitespace_re";
2009 static const char __pyx_k_trailing_whitespace[] = "trailing_whitespace";
2010 static const char __pyx_k_Weird_state_cur_word[] = "Weird state, cur_word=";
2011 static const char __pyx_k_descendant_or_self_s[] = "descendant-or-self::%s";
2012 static const char __pyx_k_fixup_ins_del_tags_2[] = "_fixup_ins_del_tags";
2013 static const char __pyx_k_move_el_inside_block[] = "_move_el_inside_block";
2014 static const char __pyx_k_html_annotate_line_35[] = "html_annotate (line 35)";
2015 static const char __pyx_k_locate_unbalanced_end[] = "locate_unbalanced_end";
2016 static const char __pyx_k_src_lxml_html_diff_py[] = "src/lxml/html/diff.py";
2017 static const char __pyx_k_trailing_whitespace_2[] = ", trailing_whitespace=";
2018 static const char __pyx_k_merge_element_contents[] = "_merge_element_contents";
2019 static const char __pyx_k_Unexpected_delete_tag_r[] = "Unexpected delete tag: %r";
2020 static const char __pyx_k_locate_unbalanced_start[] = "locate_unbalanced_start";
2021 static const char __pyx_k_markup_serialize_tokens[] = "markup_serialize_tokens";
2022 static const char __pyx_k_serialize_html_fragment[] = "serialize_html_fragment";
2023 static const char __pyx_k_contains_block_level_tag[] = "_contains_block_level_tag";
2024 static const char __pyx_k_split_trailing_whitespace[] = "split_trailing_whitespace";
2025 static const char __pyx_k_InsensitiveSequenceMatcher[] = "InsensitiveSequenceMatcher";
2026 static const char __pyx_k_block_level_container_tags[] = "block_level_container_tags";
2027 static const char __pyx_k_doclist_should_be_ordered_from[] = "\n    doclist should be ordered from oldest to newest, like::\n\n        >>> version1 = 'Hello World'\n        >>> version2 = 'Goodbye World'\n        >>> print(html_annotate([(version1, 'version 1'),\n        ...                      (version2, 'version 2')]))\n        <span title=\"version 2\">Goodbye</span> <span title=\"version 1\">World</span>\n\n    The documents must be *fragments* (str/UTF8 or unicode), not\n    complete documents\n\n    The markup argument is a function to markup the spans of words.\n    This function is called like markup('Hello', 'version 2'), and\n    returns HTML.  The first argument is text and never includes any\n    markup.  The default uses a span with a title:\n\n        >>> print(default_markup('Some Text', 'by Joe'))\n        <span title=\"by Joe\">Some Text</span>\n    ";
2028 static const char __pyx_k_Acts_like_SequenceMatcher_but_t[] = "\n    Acts like SequenceMatcher, but tries not to find very small equal\n    blocks amidst large spans of changes\n    ";
2029 static const char __pyx_k_Raised_when_the_document_no_lon[] = " Raised when the document no longer contains any pending deletes\n    (DEL_START/DEL_END) ";
2030 static const char __pyx_k_Represents_a_diffable_token_gen[] = " Represents a diffable token, generally a word that is displayed to\n    the user.  Opening tags are attached to this token when they are\n    adjacent (pre_tags) and closing tags that follow the word\n    (post_tags).  Some exceptions occur when there are empty tags\n    adjacent to a word, so there may be close tags in pre_tags, or\n    open tags in post_tags.\n\n    We also keep track of whether the word was originally followed by\n    whitespace, even though we do not want to treat the word as\n    equivalent to a similar word that does not have a trailing\n    space.";
2031 static const char __pyx_k_Represents_a_token_that_is_actu[] = " Represents a token that is actually a tag.  Currently this is just\n    the <img> tag, which takes up visible space just like a word but\n    is only represented in a document by a tag.  ";
2032 static const char __pyx_k_Represents_the_href_in_an_ancho[] = " Represents the href in an anchor tag.  Unlike other words, we only\n    show the href when it changes.  ";
2033 static const char __pyx_k_html_annotate_merge_annotations[] = "html_annotate_merge_annotations";
2034 static const char __pyx_k_pre_delete_and_post_delete_impl[] = " pre_delete and post_delete implicitly point to a place in the\n    document (where the two were split).  This moves that point (by\n    popping items from one and pushing them onto the other).  It moves\n    the point to try to find a place where unbalanced_start applies.\n\n    As an example::\n\n        >>> unbalanced_start = ['<div>']\n        >>> doc = ['<p>', 'Text', '</p>', '<div>', 'More Text', '</div>']\n        >>> pre, post = doc[:3], doc[3:]\n        >>> pre, post\n        (['<p>', 'Text', '</p>'], ['<div>', 'More Text', '</div>'])\n        >>> locate_unbalanced_start(unbalanced_start, pre, post)\n        >>> pre, post\n        (['<p>', 'Text', '</p>', '<div>'], ['More Text', '</div>'])\n\n    As you can see, we moved the point so that the dangling <div> that\n    we found will be effectively replaced by the div in the original\n    document.  If this doesn't work out, we just throw away\n    unbalanced_start without doing anything.\n    ";
2035 static const char __pyx_k_InsensitiveSequenceMatcher_get_m[] = "InsensitiveSequenceMatcher.get_matching_blocks";
2036 static const char __pyx_k_You_should_pass_in_an_element_no[] = "You should pass in an element, not a string like %r";
2037 static const char __pyx_k_locate_unbalanced_start_line_365[] = "locate_unbalanced_start (line 365)";
2038 static PyObject *__pyx_kp_u_;
2039 static PyObject *__pyx_kp_s_Acts_like_SequenceMatcher_but_t;
2040 static PyObject *__pyx_n_s_DEL_END;
2041 static PyObject *__pyx_n_s_DEL_START;
2042 static PyObject *__pyx_n_s_Element;
2043 static PyObject *__pyx_n_s_I;
2044 static PyObject *__pyx_n_s_ImportError;
2045 static PyObject *__pyx_n_s_InsensitiveSequenceMatcher;
2046 static PyObject *__pyx_n_s_InsensitiveSequenceMatcher_get_m;
2047 static PyObject *__pyx_kp_u_Link_s;
2048 static PyObject *__pyx_n_s_NameError;
2049 static PyObject *__pyx_n_s_NoDeletes;
2050 static PyObject *__pyx_kp_s_Raised_when_the_document_no_lon;
2051 static PyObject *__pyx_kp_s_Represents_a_diffable_token_gen;
2052 static PyObject *__pyx_kp_s_Represents_a_token_that_is_actu;
2053 static PyObject *__pyx_kp_s_Represents_the_href_in_an_ancho;
2054 static PyObject *__pyx_n_s_S;
2055 static PyObject *__pyx_kp_u_S_s;
2056 static PyObject *__pyx_n_s_SequenceMatcher;
2057 static PyObject *__pyx_n_s_U;
2058 static PyObject *__pyx_kp_u_Unexpected_delete_tag_r;
2059 static PyObject *__pyx_n_s_ValueError;
2060 static PyObject *__pyx_kp_u_Weird_state_cur_word;
2061 static PyObject *__pyx_kp_u_You_should_pass_in_an_element_no;
2062 static PyObject *__pyx_kp_u__10;
2063 static PyObject *__pyx_kp_u__11;
2064 static PyObject *__pyx_kp_u__12;
2065 static PyObject *__pyx_kp_u__13;
2066 static PyObject *__pyx_kp_u__14;
2067 static PyObject *__pyx_kp_u__15;
2068 static PyObject *__pyx_kp_u__18;
2069 static PyObject *__pyx_kp_u__19;
2070 static PyObject *__pyx_kp_u__2;
2071 static PyObject *__pyx_kp_u__20;
2072 static PyObject *__pyx_kp_u__6;
2073 static PyObject *__pyx_kp_u__8;
2074 static PyObject *__pyx_kp_u__9;
2075 static PyObject *__pyx_n_s_a;
2076 static PyObject *__pyx_n_u_a;
2077 static PyObject *__pyx_n_s_actual;
2078 static PyObject *__pyx_n_u_address;
2079 static PyObject *__pyx_n_s_all;
2080 static PyObject *__pyx_n_s_annotation;
2081 static PyObject *__pyx_n_s_append;
2082 static PyObject *__pyx_n_u_area;
2083 static PyObject *__pyx_n_s_args;
2084 static PyObject *__pyx_n_s_attrib;
2085 static PyObject *__pyx_n_s_b;
2086 static PyObject *__pyx_n_s_balanced;
2087 static PyObject *__pyx_n_u_base;
2088 static PyObject *__pyx_n_u_basefont;
2089 static PyObject *__pyx_n_s_basestring;
2090 static PyObject *__pyx_n_s_block_level_container_tags;
2091 static PyObject *__pyx_n_s_block_level_tags;
2092 static PyObject *__pyx_n_u_blockquote;
2093 static PyObject *__pyx_kp_u_body;
2094 static PyObject *__pyx_kp_u_body_2;
2095 static PyObject *__pyx_n_s_body_el;
2096 static PyObject *__pyx_n_s_body_re;
2097 static PyObject *__pyx_n_u_br;
2098 static PyObject *__pyx_n_u_center;
2099 static PyObject *__pyx_n_s_cgi;
2100 static PyObject *__pyx_n_s_child;
2101 static PyObject *__pyx_n_s_child_tag;
2102 static PyObject *__pyx_n_s_children_tag;
2103 static PyObject *__pyx_n_s_chunk;
2104 static PyObject *__pyx_kp_u_chunks;
2105 static PyObject *__pyx_n_s_chunks_2;
2106 static PyObject *__pyx_n_s_cleanup;
2107 static PyObject *__pyx_n_s_cleanup_delete;
2108 static PyObject *__pyx_n_s_cleanup_html;
2109 static PyObject *__pyx_n_s_cline_in_traceback;
2110 static PyObject *__pyx_n_s_close;
2111 static PyObject *__pyx_n_s_cls;
2112 static PyObject *__pyx_n_u_col;
2113 static PyObject *__pyx_n_s_command;
2114 static PyObject *__pyx_n_s_commands;
2115 static PyObject *__pyx_n_s_compile;
2116 static PyObject *__pyx_n_s_compress_merge_back;
2117 static PyObject *__pyx_n_s_compress_tokens;
2118 static PyObject *__pyx_n_s_contains_block_level_tag;
2119 static PyObject *__pyx_n_s_copy_annotations;
2120 static PyObject *__pyx_n_s_create_parent;
2121 static PyObject *__pyx_n_s_cur_tokens;
2122 static PyObject *__pyx_n_s_cur_word;
2123 static PyObject *__pyx_n_s_data;
2124 static PyObject *__pyx_n_u_dd;
2125 static PyObject *__pyx_n_s_default_markup;
2126 static PyObject *__pyx_kp_u_del;
2127 static PyObject *__pyx_kp_u_del_2;
2128 static PyObject *__pyx_n_u_del_3;
2129 static PyObject *__pyx_n_s_del_chunks;
2130 static PyObject *__pyx_n_s_del_tokens;
2131 static PyObject *__pyx_n_s_delete;
2132 static PyObject *__pyx_n_u_delete;
2133 static PyObject *__pyx_kp_u_descendant_or_self_s;
2134 static PyObject *__pyx_n_s_dest;
2135 static PyObject *__pyx_n_s_dest_tok;
2136 static PyObject *__pyx_n_s_diffcommand;
2137 static PyObject *__pyx_n_s_difflib;
2138 static PyObject *__pyx_n_u_dir;
2139 static PyObject *__pyx_n_u_div;
2140 static PyObject *__pyx_n_u_dl;
2141 static PyObject *__pyx_n_s_doc;
2142 static PyObject *__pyx_n_s_doc_2;
2143 static PyObject *__pyx_n_s_doclist;
2144 static PyObject *__pyx_kp_u_doclist_should_be_ordered_from;
2145 static PyObject *__pyx_n_s_drop_tag;
2146 static PyObject *__pyx_n_u_dt;
2147 static PyObject *__pyx_n_s_el;
2148 static PyObject *__pyx_n_s_empty_tags;
2149 static PyObject *__pyx_n_s_encoding;
2150 static PyObject *__pyx_n_s_end;
2151 static PyObject *__pyx_n_s_end_body_re;
2152 static PyObject *__pyx_n_s_end_tag;
2153 static PyObject *__pyx_n_s_end_whitespace_re;
2154 static PyObject *__pyx_n_s_end_words;
2155 static PyObject *__pyx_n_s_endswith;
2156 static PyObject *__pyx_n_s_endtag;
2157 static PyObject *__pyx_n_s_eq_new;
2158 static PyObject *__pyx_n_s_eq_old;
2159 static PyObject *__pyx_n_s_equal;
2160 static PyObject *__pyx_n_u_equal;
2161 static PyObject *__pyx_n_s_escape;
2162 static PyObject *__pyx_n_s_etree;
2163 static PyObject *__pyx_n_s_expand_tokens;
2164 static PyObject *__pyx_n_s_extend;
2165 static PyObject *__pyx_n_s_extra;
2166 static PyObject *__pyx_n_u_fieldset;
2167 static PyObject *__pyx_n_s_find;
2168 static PyObject *__pyx_n_s_findall;
2169 static PyObject *__pyx_n_s_finding;
2170 static PyObject *__pyx_n_s_finding_name;
2171 static PyObject *__pyx_n_s_fixup_chunks;
2172 static PyObject *__pyx_n_s_fixup_ins_del_tags;
2173 static PyObject *__pyx_n_s_fixup_ins_del_tags_2;
2174 static PyObject *__pyx_n_s_flatten_el;
2175 static PyObject *__pyx_n_u_form;
2176 static PyObject *__pyx_n_s_fragment_fromstring;
2177 static PyObject *__pyx_n_u_frameset;
2178 static PyObject *__pyx_n_s_get;
2179 static PyObject *__pyx_n_s_get_matching_blocks;
2180 static PyObject *__pyx_n_s_get_opcodes;
2181 static PyObject *__pyx_n_s_getchildren;
2182 static PyObject *__pyx_n_s_getparent;
2183 static PyObject *__pyx_n_u_h1;
2184 static PyObject *__pyx_n_u_h2;
2185 static PyObject *__pyx_n_u_h3;
2186 static PyObject *__pyx_n_u_h4;
2187 static PyObject *__pyx_n_u_h5;
2188 static PyObject *__pyx_n_u_h6;
2189 static PyObject *__pyx_n_s_hide_when_equal;
2190 static PyObject *__pyx_n_u_hr;
2191 static PyObject *__pyx_n_s_href;
2192 static PyObject *__pyx_n_u_href;
2193 static PyObject *__pyx_n_s_href_token;
2194 static PyObject *__pyx_n_s_href_token_html;
2195 static PyObject *__pyx_n_s_html;
2196 static PyObject *__pyx_n_u_html;
2197 static PyObject *__pyx_n_s_html1_tokens;
2198 static PyObject *__pyx_n_s_html2_tokens;
2199 static PyObject *__pyx_n_s_html_annotate;
2200 static PyObject *__pyx_n_u_html_annotate;
2201 static PyObject *__pyx_kp_u_html_annotate_line_35;
2202 static PyObject *__pyx_n_s_html_annotate_merge_annotations;
2203 static PyObject *__pyx_n_s_html_escape;
2204 static PyObject *__pyx_n_s_html_repr;
2205 static PyObject *__pyx_kp_u_html_repr_2;
2206 static PyObject *__pyx_n_s_htmldiff;
2207 static PyObject *__pyx_n_u_htmldiff;
2208 static PyObject *__pyx_n_s_htmldiff_tokens;
2209 static PyObject *__pyx_n_s_i1;
2210 static PyObject *__pyx_n_s_i2;
2211 static PyObject *__pyx_n_u_img;
2212 static PyObject *__pyx_n_s_import;
2213 static PyObject *__pyx_n_s_include_hrefs;
2214 static PyObject *__pyx_n_s_index;
2215 static PyObject *__pyx_n_u_input;
2216 static PyObject *__pyx_kp_u_ins;
2217 static PyObject *__pyx_kp_u_ins_2;
2218 static PyObject *__pyx_n_u_ins_3;
2219 static PyObject *__pyx_n_s_ins_chunks;
2220 static PyObject *__pyx_kp_u_ins_del;
2221 static PyObject *__pyx_n_s_ins_del_re;
2222 static PyObject *__pyx_n_s_ins_tokens;
2223 static PyObject *__pyx_n_s_insert;
2224 static PyObject *__pyx_n_u_insert;
2225 static PyObject *__pyx_n_s_is_end_tag;
2226 static PyObject *__pyx_n_s_is_start_tag;
2227 static PyObject *__pyx_n_s_is_word;
2228 static PyObject *__pyx_n_s_iselement;
2229 static PyObject *__pyx_n_u_isindex;
2230 static PyObject *__pyx_n_s_item;
2231 static PyObject *__pyx_n_s_items;
2232 static PyObject *__pyx_n_s_j1;
2233 static PyObject *__pyx_n_s_j2;
2234 static PyObject *__pyx_n_s_last;
2235 static PyObject *__pyx_n_u_li;
2236 static PyObject *__pyx_n_u_link;
2237 static PyObject *__pyx_n_s_locate_unbalanced_end;
2238 static PyObject *__pyx_n_s_locate_unbalanced_start;
2239 static PyObject *__pyx_kp_u_locate_unbalanced_start_line_365;
2240 static PyObject *__pyx_n_s_lxml;
2241 static PyObject *__pyx_n_s_lxml_html;
2242 static PyObject *__pyx_n_s_lxml_html_diff;
2243 static PyObject *__pyx_n_s_main;
2244 static PyObject *__pyx_n_u_main;
2245 static PyObject *__pyx_n_s_main_2;
2246 static PyObject *__pyx_n_s_markup;
2247 static PyObject *__pyx_n_s_markup_func;
2248 static PyObject *__pyx_n_s_markup_serialize_tokens;
2249 static PyObject *__pyx_n_s_match;
2250 static PyObject *__pyx_n_u_menu;
2251 static PyObject *__pyx_n_s_merge_delete;
2252 static PyObject *__pyx_n_s_merge_element_contents;
2253 static PyObject *__pyx_n_s_merge_insert;
2254 static PyObject *__pyx_n_s_merged;
2255 static PyObject *__pyx_n_u_meta;
2256 static PyObject *__pyx_n_s_metaclass;
2257 static PyObject *__pyx_n_s_method;
2258 static PyObject *__pyx_n_s_module;
2259 static PyObject *__pyx_n_s_move_el_inside_block;
2260 static PyObject *__pyx_n_s_name;
2261 static PyObject *__pyx_n_s_name_2;
2262 static PyObject *__pyx_n_s_new;
2263 static PyObject *__pyx_n_s_new_html;
2264 static PyObject *__pyx_n_s_new_html_tokens;
2265 static PyObject *__pyx_n_s_next;
2266 static PyObject *__pyx_n_u_noframes;
2267 static PyObject *__pyx_n_u_noscript;
2268 static PyObject *__pyx_n_s_obj;
2269 static PyObject *__pyx_kp_u_of;
2270 static PyObject *__pyx_n_u_ol;
2271 static PyObject *__pyx_n_s_old_html;
2272 static PyObject *__pyx_n_s_old_html_tokens;
2273 static PyObject *__pyx_n_u_p;
2274 static PyObject *__pyx_n_u_param;
2275 static PyObject *__pyx_n_s_parent;
2276 static PyObject *__pyx_n_s_parse_html;
2277 static PyObject *__pyx_n_s_pop;
2278 static PyObject *__pyx_n_s_pos;
2279 static PyObject *__pyx_n_s_pos2;
2280 static PyObject *__pyx_n_s_post;
2281 static PyObject *__pyx_n_s_post_delete;
2282 static PyObject *__pyx_n_s_post_tags;
2283 static PyObject *__pyx_kp_u_post_tags_2;
2284 static PyObject *__pyx_n_s_pre;
2285 static PyObject *__pyx_n_u_pre;
2286 static PyObject *__pyx_n_s_pre_delete;
2287 static PyObject *__pyx_kp_u_pre_delete_and_post_delete_impl;
2288 static PyObject *__pyx_n_s_pre_tags;
2289 static PyObject *__pyx_kp_u_pre_tags_2;
2290 static PyObject *__pyx_n_s_prepare;
2291 static PyObject *__pyx_n_s_previous;
2292 static PyObject *__pyx_n_s_qualname;
2293 static PyObject *__pyx_n_s_re;
2294 static PyObject *__pyx_n_s_replace;
2295 static PyObject *__pyx_n_u_replace;
2296 static PyObject *__pyx_n_s_repr;
2297 static PyObject *__pyx_kp_u_result;
2298 static PyObject *__pyx_n_s_result_2;
2299 static PyObject *__pyx_n_s_rfind;
2300 static PyObject *__pyx_n_s_rstrip;
2301 static PyObject *__pyx_n_s_s;
2302 static PyObject *__pyx_n_s_search;
2303 static PyObject *__pyx_n_s_self;
2304 static PyObject *__pyx_n_s_send;
2305 static PyObject *__pyx_n_s_serialize_html_fragment;
2306 static PyObject *__pyx_n_s_size;
2307 static PyObject *__pyx_n_s_skip_outer;
2308 static PyObject *__pyx_n_s_skip_tag;
2309 static PyObject *__pyx_kp_u_span;
2310 static PyObject *__pyx_kp_u_span_title;
2311 static PyObject *__pyx_n_s_split;
2312 static PyObject *__pyx_n_s_split_delete;
2313 static PyObject *__pyx_n_s_split_trailing_whitespace;
2314 static PyObject *__pyx_n_s_split_unbalanced;
2315 static PyObject *__pyx_n_s_split_words;
2316 static PyObject *__pyx_n_s_split_words_re;
2317 static PyObject *__pyx_n_s_src;
2318 static PyObject *__pyx_n_u_src;
2319 static PyObject *__pyx_kp_s_src_lxml_html_diff_py;
2320 static PyObject *__pyx_n_s_src_tok;
2321 static PyObject *__pyx_n_s_start;
2322 static PyObject *__pyx_n_s_start_tag;
2323 static PyObject *__pyx_n_s_start_whitespace_re;
2324 static PyObject *__pyx_n_s_start_words;
2325 static PyObject *__pyx_n_s_startswith;
2326 static PyObject *__pyx_n_s_strip;
2327 static PyObject *__pyx_n_s_stripped_length;
2328 static PyObject *__pyx_n_s_sub;
2329 static PyObject *__pyx_kp_u_t_n_r;
2330 static PyObject *__pyx_kp_u_t_n_r_2;
2331 static PyObject *__pyx_n_u_table;
2332 static PyObject *__pyx_n_s_tag;
2333 static PyObject *__pyx_n_s_tag_accum;
2334 static PyObject *__pyx_n_s_tag_stack;
2335 static PyObject *__pyx_kp_u_tag_token;
2336 static PyObject *__pyx_n_s_tag_token_2;
2337 static PyObject *__pyx_n_s_tag_token___new;
2338 static PyObject *__pyx_n_s_tag_token___repr;
2339 static PyObject *__pyx_n_s_tag_token_html;
2340 static PyObject *__pyx_n_s_tail;
2341 static PyObject *__pyx_n_s_tail_tag;
2342 static PyObject *__pyx_n_u_tbody;
2343 static PyObject *__pyx_n_u_td;
2344 static PyObject *__pyx_n_s_test;
2345 static PyObject *__pyx_n_s_text;
2346 static PyObject *__pyx_n_s_text_tag;
2347 static PyObject *__pyx_n_u_tfoot;
2348 static PyObject *__pyx_n_u_th;
2349 static PyObject *__pyx_n_u_thead;
2350 static PyObject *__pyx_n_s_threshold;
2351 static PyObject *__pyx_n_s_throw;
2352 static PyObject *__pyx_n_s_tok;
2353 static PyObject *__pyx_n_s_token;
2354 static PyObject *__pyx_kp_u_token_2;
2355 static PyObject *__pyx_n_s_token___new;
2356 static PyObject *__pyx_n_s_token___repr;
2357 static PyObject *__pyx_n_s_token_html;
2358 static PyObject *__pyx_n_s_tokenize;
2359 static PyObject *__pyx_n_s_tokenize_annotated;
2360 static PyObject *__pyx_n_s_tokenlist;
2361 static PyObject *__pyx_n_s_tokens;
2362 static PyObject *__pyx_n_s_tokens_new;
2363 static PyObject *__pyx_n_s_tokens_old;
2364 static PyObject *__pyx_n_s_tostring;
2365 static PyObject *__pyx_n_u_tr;
2366 static PyObject *__pyx_n_s_trailing_whitespace;
2367 static PyObject *__pyx_kp_u_trailing_whitespace_2;
2368 static PyObject *__pyx_n_u_ul;
2369 static PyObject *__pyx_n_s_unbalanced_end;
2370 static PyObject *__pyx_n_s_unbalanced_start;
2371 static PyObject *__pyx_n_s_unicode;
2372 static PyObject *__pyx_n_s_value;
2373 static PyObject *__pyx_n_s_version;
2374 static PyObject *__pyx_n_s_word;
2375 static PyObject *__pyx_n_s_words;
2376 static PyObject *__pyx_n_s_xpath;
2377 static PyObject *__pyx_n_s_zip;
2378 static PyObject *__pyx_pf_4lxml_4html_4diff_default_markup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text, PyObject *__pyx_v_version); /* proto */
2379 static PyObject *__pyx_pf_4lxml_4html_4diff_75__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
2380 static PyObject *__pyx_pf_4lxml_4html_4diff_2html_annotate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doclist, PyObject *__pyx_v_markup); /* proto */
2381 static PyObject *__pyx_pf_4lxml_4html_4diff_4tokenize_annotated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doc, PyObject *__pyx_v_annotation); /* proto */
2382 static PyObject *__pyx_pf_4lxml_4html_4diff_6html_annotate_merge_annotations(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens_old, PyObject *__pyx_v_tokens_new); /* proto */
2383 static PyObject *__pyx_pf_4lxml_4html_4diff_8copy_annotations(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src, PyObject *__pyx_v_dest); /* proto */
2384 static PyObject *__pyx_pf_4lxml_4html_4diff_10compress_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens); /* proto */
2385 static PyObject *__pyx_pf_4lxml_4html_4diff_12compress_merge_back(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_tok); /* proto */
2386 static PyObject *__pyx_pf_4lxml_4html_4diff_14markup_serialize_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_markup_func); /* proto */
2387 static PyObject *__pyx_pf_4lxml_4html_4diff_17htmldiff(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_old_html, PyObject *__pyx_v_new_html); /* proto */
2388 static PyObject *__pyx_pf_4lxml_4html_4diff_19htmldiff_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html1_tokens, PyObject *__pyx_v_html2_tokens); /* proto */
2389 static PyObject *__pyx_pf_4lxml_4html_4diff_21expand_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_equal); /* proto */
2390 static PyObject *__pyx_pf_4lxml_4html_4diff_24merge_insert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ins_chunks, PyObject *__pyx_v_doc); /* proto */
2391 static PyObject *__pyx_pf_4lxml_4html_4diff_26merge_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_del_chunks, PyObject *__pyx_v_doc); /* proto */
2392 static PyObject *__pyx_pf_4lxml_4html_4diff_28cleanup_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks); /* proto */
2393 static PyObject *__pyx_pf_4lxml_4html_4diff_30split_unbalanced(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks); /* proto */
2394 static PyObject *__pyx_pf_4lxml_4html_4diff_32split_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks); /* proto */
2395 static PyObject *__pyx_pf_4lxml_4html_4diff_34locate_unbalanced_start(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_unbalanced_start, PyObject *__pyx_v_pre_delete, PyObject *__pyx_v_post_delete); /* proto */
2396 static PyObject *__pyx_pf_4lxml_4html_4diff_36locate_unbalanced_end(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_unbalanced_end, PyObject *__pyx_v_pre_delete, PyObject *__pyx_v_post_delete); /* proto */
2397 static PyObject *__pyx_pf_4lxml_4html_4diff_5token___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_text, PyObject *__pyx_v_pre_tags, PyObject *__pyx_v_post_tags, PyObject *__pyx_v_trailing_whitespace); /* proto */
2398 static PyObject *__pyx_pf_4lxml_4html_4diff_5token_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2399 static PyObject *__pyx_pf_4lxml_4html_4diff_5token_4html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2400 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_tag, PyObject *__pyx_v_data, PyObject *__pyx_v_html_repr, PyObject *__pyx_v_pre_tags, PyObject *__pyx_v_post_tags, PyObject *__pyx_v_trailing_whitespace); /* proto */
2401 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2402 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token_4html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2403 static PyObject *__pyx_pf_4lxml_4html_4diff_10href_token_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2404 static PyObject *__pyx_pf_4lxml_4html_4diff_38tokenize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html, PyObject *__pyx_v_include_hrefs); /* proto */
2405 static PyObject *__pyx_pf_4lxml_4html_4diff_40parse_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html, PyObject *__pyx_v_cleanup); /* proto */
2406 static PyObject *__pyx_pf_4lxml_4html_4diff_42cleanup_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html); /* proto */
2407 static PyObject *__pyx_pf_4lxml_4html_4diff_44split_trailing_whitespace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word); /* proto */
2408 static PyObject *__pyx_pf_4lxml_4html_4diff_46fixup_chunks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks); /* proto */
2409 static PyObject *__pyx_pf_4lxml_4html_4diff_48flatten_el(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_include_hrefs, PyObject *__pyx_v_skip_tag); /* proto */
2410 static PyObject *__pyx_pf_4lxml_4html_4diff_51split_words(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text); /* proto */
2411 static PyObject *__pyx_pf_4lxml_4html_4diff_53start_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el); /* proto */
2412 static PyObject *__pyx_pf_4lxml_4html_4diff_55end_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el); /* proto */
2413 static PyObject *__pyx_pf_4lxml_4html_4diff_57is_word(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok); /* proto */
2414 static PyObject *__pyx_pf_4lxml_4html_4diff_59is_end_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok); /* proto */
2415 static PyObject *__pyx_pf_4lxml_4html_4diff_61is_start_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok); /* proto */
2416 static PyObject *__pyx_pf_4lxml_4html_4diff_63fixup_ins_del_tags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html); /* proto */
2417 static PyObject *__pyx_pf_4lxml_4html_4diff_65serialize_html_fragment(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_skip_outer); /* proto */
2418 static PyObject *__pyx_pf_4lxml_4html_4diff_67_fixup_ins_del_tags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doc); /* proto */
2419 static PyObject *__pyx_pf_4lxml_4html_4diff_69_contains_block_level_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el); /* proto */
2420 static PyObject *__pyx_pf_4lxml_4html_4diff_71_move_el_inside_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_tag); /* proto */
2421 static PyObject *__pyx_pf_4lxml_4html_4diff_73_merge_element_contents(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el); /* proto */
2422 static PyObject *__pyx_pf_4lxml_4html_4diff_26InsensitiveSequenceMatcher_get_matching_blocks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
2423 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2424 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2425 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2426 static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
2427 static PyObject *__pyx_int_0;
2428 static PyObject *__pyx_int_1;
2429 static PyObject *__pyx_int_2;
2430 static PyObject *__pyx_int_4;
2431 static PyObject *__pyx_int_neg_1;
2432 static PyObject *__pyx_slice__3;
2433 static PyObject *__pyx_slice__7;
2434 static PyObject *__pyx_slice__22;
2435 static PyObject *__pyx_tuple__16;
2436 static PyObject *__pyx_tuple__21;
2437 static PyObject *__pyx_tuple__23;
2438 static PyObject *__pyx_tuple__25;
2439 static PyObject *__pyx_tuple__27;
2440 static PyObject *__pyx_tuple__29;
2441 static PyObject *__pyx_tuple__31;
2442 static PyObject *__pyx_tuple__33;
2443 static PyObject *__pyx_tuple__35;
2444 static PyObject *__pyx_tuple__37;
2445 static PyObject *__pyx_tuple__38;
2446 static PyObject *__pyx_tuple__40;
2447 static PyObject *__pyx_tuple__42;
2448 static PyObject *__pyx_tuple__43;
2449 static PyObject *__pyx_tuple__44;
2450 static PyObject *__pyx_tuple__46;
2451 static PyObject *__pyx_tuple__48;
2452 static PyObject *__pyx_tuple__50;
2453 static PyObject *__pyx_tuple__52;
2454 static PyObject *__pyx_tuple__54;
2455 static PyObject *__pyx_tuple__56;
2456 static PyObject *__pyx_tuple__58;
2457 static PyObject *__pyx_tuple__60;
2458 static PyObject *__pyx_tuple__61;
2459 static PyObject *__pyx_tuple__63;
2460 static PyObject *__pyx_tuple__65;
2461 static PyObject *__pyx_tuple__67;
2462 static PyObject *__pyx_tuple__68;
2463 static PyObject *__pyx_tuple__70;
2464 static PyObject *__pyx_tuple__72;
2465 static PyObject *__pyx_tuple__74;
2466 static PyObject *__pyx_tuple__76;
2467 static PyObject *__pyx_tuple__77;
2468 static PyObject *__pyx_tuple__79;
2469 static PyObject *__pyx_tuple__80;
2470 static PyObject *__pyx_tuple__82;
2471 static PyObject *__pyx_tuple__83;
2472 static PyObject *__pyx_tuple__85;
2473 static PyObject *__pyx_tuple__87;
2474 static PyObject *__pyx_tuple__88;
2475 static PyObject *__pyx_tuple__89;
2476 static PyObject *__pyx_tuple__90;
2477 static PyObject *__pyx_tuple__91;
2478 static PyObject *__pyx_tuple__92;
2479 static PyObject *__pyx_tuple__94;
2480 static PyObject *__pyx_tuple__95;
2481 static PyObject *__pyx_tuple__97;
2482 static PyObject *__pyx_tuple__99;
2483 static PyObject *__pyx_codeobj__4;
2484 static PyObject *__pyx_codeobj__5;
2485 static PyObject *__pyx_tuple__101;
2486 static PyObject *__pyx_tuple__103;
2487 static PyObject *__pyx_tuple__105;
2488 static PyObject *__pyx_tuple__107;
2489 static PyObject *__pyx_tuple__109;
2490 static PyObject *__pyx_tuple__110;
2491 static PyObject *__pyx_tuple__112;
2492 static PyObject *__pyx_tuple__114;
2493 static PyObject *__pyx_tuple__116;
2494 static PyObject *__pyx_tuple__118;
2495 static PyObject *__pyx_codeobj__17;
2496 static PyObject *__pyx_codeobj__24;
2497 static PyObject *__pyx_codeobj__26;
2498 static PyObject *__pyx_codeobj__28;
2499 static PyObject *__pyx_codeobj__30;
2500 static PyObject *__pyx_codeobj__32;
2501 static PyObject *__pyx_codeobj__34;
2502 static PyObject *__pyx_codeobj__36;
2503 static PyObject *__pyx_codeobj__39;
2504 static PyObject *__pyx_codeobj__41;
2505 static PyObject *__pyx_codeobj__45;
2506 static PyObject *__pyx_codeobj__47;
2507 static PyObject *__pyx_codeobj__49;
2508 static PyObject *__pyx_codeobj__51;
2509 static PyObject *__pyx_codeobj__53;
2510 static PyObject *__pyx_codeobj__55;
2511 static PyObject *__pyx_codeobj__57;
2512 static PyObject *__pyx_codeobj__59;
2513 static PyObject *__pyx_codeobj__62;
2514 static PyObject *__pyx_codeobj__64;
2515 static PyObject *__pyx_codeobj__66;
2516 static PyObject *__pyx_codeobj__69;
2517 static PyObject *__pyx_codeobj__71;
2518 static PyObject *__pyx_codeobj__73;
2519 static PyObject *__pyx_codeobj__75;
2520 static PyObject *__pyx_codeobj__78;
2521 static PyObject *__pyx_codeobj__81;
2522 static PyObject *__pyx_codeobj__84;
2523 static PyObject *__pyx_codeobj__86;
2524 static PyObject *__pyx_codeobj__93;
2525 static PyObject *__pyx_codeobj__96;
2526 static PyObject *__pyx_codeobj__98;
2527 static PyObject *__pyx_codeobj__100;
2528 static PyObject *__pyx_codeobj__102;
2529 static PyObject *__pyx_codeobj__104;
2530 static PyObject *__pyx_codeobj__106;
2531 static PyObject *__pyx_codeobj__108;
2532 static PyObject *__pyx_codeobj__111;
2533 static PyObject *__pyx_codeobj__113;
2534 static PyObject *__pyx_codeobj__115;
2535 static PyObject *__pyx_codeobj__117;
2536 static PyObject *__pyx_codeobj__119;
2537 /* Late includes */
2538
2539 /* "lxml/html/diff.py":31
2540  * ############################################################
2541  * 
2542  * def default_markup(text, version):             # <<<<<<<<<<<<<<
2543  *     return '<span title="%s">%s</span>' % (
2544  *         html_escape(_unicode(version), 1), text)
2545  */
2546
2547 /* Python wrapper */
2548 static PyObject *__pyx_pw_4lxml_4html_4diff_1default_markup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2549 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_1default_markup = {"default_markup", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_1default_markup, METH_VARARGS|METH_KEYWORDS, 0};
2550 static PyObject *__pyx_pw_4lxml_4html_4diff_1default_markup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2551   PyObject *__pyx_v_text = 0;
2552   PyObject *__pyx_v_version = 0;
2553   int __pyx_lineno = 0;
2554   const char *__pyx_filename = NULL;
2555   int __pyx_clineno = 0;
2556   PyObject *__pyx_r = 0;
2557   __Pyx_RefNannyDeclarations
2558   __Pyx_RefNannySetupContext("default_markup (wrapper)", 0);
2559   {
2560     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_text,&__pyx_n_s_version,0};
2561     PyObject* values[2] = {0,0};
2562     if (unlikely(__pyx_kwds)) {
2563       Py_ssize_t kw_args;
2564       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2565       switch (pos_args) {
2566         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2567         CYTHON_FALLTHROUGH;
2568         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2569         CYTHON_FALLTHROUGH;
2570         case  0: break;
2571         default: goto __pyx_L5_argtuple_error;
2572       }
2573       kw_args = PyDict_Size(__pyx_kwds);
2574       switch (pos_args) {
2575         case  0:
2576         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
2577         else goto __pyx_L5_argtuple_error;
2578         CYTHON_FALLTHROUGH;
2579         case  1:
2580         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_version)) != 0)) kw_args--;
2581         else {
2582           __Pyx_RaiseArgtupleInvalid("default_markup", 1, 2, 2, 1); __PYX_ERR(0, 31, __pyx_L3_error)
2583         }
2584       }
2585       if (unlikely(kw_args > 0)) {
2586         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "default_markup") < 0)) __PYX_ERR(0, 31, __pyx_L3_error)
2587       }
2588     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2589       goto __pyx_L5_argtuple_error;
2590     } else {
2591       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2592       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2593     }
2594     __pyx_v_text = values[0];
2595     __pyx_v_version = values[1];
2596   }
2597   goto __pyx_L4_argument_unpacking_done;
2598   __pyx_L5_argtuple_error:;
2599   __Pyx_RaiseArgtupleInvalid("default_markup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 31, __pyx_L3_error)
2600   __pyx_L3_error:;
2601   __Pyx_AddTraceback("lxml.html.diff.default_markup", __pyx_clineno, __pyx_lineno, __pyx_filename);
2602   __Pyx_RefNannyFinishContext();
2603   return NULL;
2604   __pyx_L4_argument_unpacking_done:;
2605   __pyx_r = __pyx_pf_4lxml_4html_4diff_default_markup(__pyx_self, __pyx_v_text, __pyx_v_version);
2606
2607   /* function exit code */
2608   __Pyx_RefNannyFinishContext();
2609   return __pyx_r;
2610 }
2611
2612 static PyObject *__pyx_pf_4lxml_4html_4diff_default_markup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text, PyObject *__pyx_v_version) {
2613   PyObject *__pyx_r = NULL;
2614   __Pyx_RefNannyDeclarations
2615   PyObject *__pyx_t_1 = NULL;
2616   Py_ssize_t __pyx_t_2;
2617   Py_UCS4 __pyx_t_3;
2618   PyObject *__pyx_t_4 = NULL;
2619   PyObject *__pyx_t_5 = NULL;
2620   PyObject *__pyx_t_6 = NULL;
2621   PyObject *__pyx_t_7 = NULL;
2622   PyObject *__pyx_t_8 = NULL;
2623   int __pyx_t_9;
2624   int __pyx_lineno = 0;
2625   const char *__pyx_filename = NULL;
2626   int __pyx_clineno = 0;
2627   __Pyx_RefNannySetupContext("default_markup", 0);
2628
2629   /* "lxml/html/diff.py":32
2630  * 
2631  * def default_markup(text, version):
2632  *     return '<span title="%s">%s</span>' % (             # <<<<<<<<<<<<<<
2633  *         html_escape(_unicode(version), 1), text)
2634  * 
2635  */
2636   __Pyx_XDECREF(__pyx_r);
2637   __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
2638   __Pyx_GOTREF(__pyx_t_1);
2639   __pyx_t_2 = 0;
2640   __pyx_t_3 = 127;
2641   __Pyx_INCREF(__pyx_kp_u_span_title);
2642   __pyx_t_2 += 13;
2643   __Pyx_GIVEREF(__pyx_kp_u_span_title);
2644   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_span_title);
2645
2646   /* "lxml/html/diff.py":33
2647  * def default_markup(text, version):
2648  *     return '<span title="%s">%s</span>' % (
2649  *         html_escape(_unicode(version), 1), text)             # <<<<<<<<<<<<<<
2650  * 
2651  * def html_annotate(doclist, markup=default_markup):
2652  */
2653   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_html_escape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
2654   __Pyx_GOTREF(__pyx_t_5);
2655   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
2656   __Pyx_GOTREF(__pyx_t_7);
2657   __pyx_t_8 = NULL;
2658   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
2659     __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
2660     if (likely(__pyx_t_8)) {
2661       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2662       __Pyx_INCREF(__pyx_t_8);
2663       __Pyx_INCREF(function);
2664       __Pyx_DECREF_SET(__pyx_t_7, function);
2665     }
2666   }
2667   __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_version) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_version);
2668   __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2669   if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 33, __pyx_L1_error)
2670   __Pyx_GOTREF(__pyx_t_6);
2671   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2672   __pyx_t_7 = NULL;
2673   __pyx_t_9 = 0;
2674   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2675     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
2676     if (likely(__pyx_t_7)) {
2677       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2678       __Pyx_INCREF(__pyx_t_7);
2679       __Pyx_INCREF(function);
2680       __Pyx_DECREF_SET(__pyx_t_5, function);
2681       __pyx_t_9 = 1;
2682     }
2683   }
2684   #if CYTHON_FAST_PYCALL
2685   if (PyFunction_Check(__pyx_t_5)) {
2686     PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_int_1};
2687     __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
2688     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2689     __Pyx_GOTREF(__pyx_t_4);
2690     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2691   } else
2692   #endif
2693   #if CYTHON_FAST_PYCCALL
2694   if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
2695     PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_int_1};
2696     __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
2697     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2698     __Pyx_GOTREF(__pyx_t_4);
2699     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2700   } else
2701   #endif
2702   {
2703     __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 33, __pyx_L1_error)
2704     __Pyx_GOTREF(__pyx_t_8);
2705     if (__pyx_t_7) {
2706       __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
2707     }
2708     __Pyx_GIVEREF(__pyx_t_6);
2709     PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_6);
2710     __Pyx_INCREF(__pyx_int_1);
2711     __Pyx_GIVEREF(__pyx_int_1);
2712     PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_int_1);
2713     __pyx_t_6 = 0;
2714     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
2715     __Pyx_GOTREF(__pyx_t_4);
2716     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2717   }
2718   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2719   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
2720   __Pyx_GOTREF(__pyx_t_5);
2721   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2722   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
2723   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
2724   __Pyx_GIVEREF(__pyx_t_5);
2725   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
2726   __pyx_t_5 = 0;
2727   __Pyx_INCREF(__pyx_kp_u_);
2728   __pyx_t_2 += 2;
2729   __Pyx_GIVEREF(__pyx_kp_u_);
2730   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_);
2731   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_text), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
2732   __Pyx_GOTREF(__pyx_t_5);
2733   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
2734   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
2735   __Pyx_GIVEREF(__pyx_t_5);
2736   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_5);
2737   __pyx_t_5 = 0;
2738   __Pyx_INCREF(__pyx_kp_u_span);
2739   __pyx_t_2 += 7;
2740   __Pyx_GIVEREF(__pyx_kp_u_span);
2741   PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_span);
2742
2743   /* "lxml/html/diff.py":32
2744  * 
2745  * def default_markup(text, version):
2746  *     return '<span title="%s">%s</span>' % (             # <<<<<<<<<<<<<<
2747  *         html_escape(_unicode(version), 1), text)
2748  * 
2749  */
2750   __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error)
2751   __Pyx_GOTREF(__pyx_t_5);
2752   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2753   __pyx_r = __pyx_t_5;
2754   __pyx_t_5 = 0;
2755   goto __pyx_L0;
2756
2757   /* "lxml/html/diff.py":31
2758  * ############################################################
2759  * 
2760  * def default_markup(text, version):             # <<<<<<<<<<<<<<
2761  *     return '<span title="%s">%s</span>' % (
2762  *         html_escape(_unicode(version), 1), text)
2763  */
2764
2765   /* function exit code */
2766   __pyx_L1_error:;
2767   __Pyx_XDECREF(__pyx_t_1);
2768   __Pyx_XDECREF(__pyx_t_4);
2769   __Pyx_XDECREF(__pyx_t_5);
2770   __Pyx_XDECREF(__pyx_t_6);
2771   __Pyx_XDECREF(__pyx_t_7);
2772   __Pyx_XDECREF(__pyx_t_8);
2773   __Pyx_AddTraceback("lxml.html.diff.default_markup", __pyx_clineno, __pyx_lineno, __pyx_filename);
2774   __pyx_r = NULL;
2775   __pyx_L0:;
2776   __Pyx_XGIVEREF(__pyx_r);
2777   __Pyx_RefNannyFinishContext();
2778   return __pyx_r;
2779 }
2780
2781 /* "lxml/html/diff.py":35
2782  *         html_escape(_unicode(version), 1), text)
2783  * 
2784  * def html_annotate(doclist, markup=default_markup):             # <<<<<<<<<<<<<<
2785  *     """
2786  *     doclist should be ordered from oldest to newest, like::
2787  */
2788
2789 static PyObject *__pyx_pf_4lxml_4html_4diff_75__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
2790   PyObject *__pyx_r = NULL;
2791   __Pyx_RefNannyDeclarations
2792   PyObject *__pyx_t_1 = NULL;
2793   PyObject *__pyx_t_2 = NULL;
2794   int __pyx_lineno = 0;
2795   const char *__pyx_filename = NULL;
2796   int __pyx_clineno = 0;
2797   __Pyx_RefNannySetupContext("__defaults__", 0);
2798   __Pyx_XDECREF(__pyx_r);
2799   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
2800   __Pyx_GOTREF(__pyx_t_1);
2801   __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_markup);
2802   __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_markup);
2803   PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_markup);
2804   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
2805   __Pyx_GOTREF(__pyx_t_2);
2806   __Pyx_GIVEREF(__pyx_t_1);
2807   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2808   __Pyx_INCREF(Py_None);
2809   __Pyx_GIVEREF(Py_None);
2810   PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
2811   __pyx_t_1 = 0;
2812   __pyx_r = __pyx_t_2;
2813   __pyx_t_2 = 0;
2814   goto __pyx_L0;
2815
2816   /* function exit code */
2817   __pyx_L1_error:;
2818   __Pyx_XDECREF(__pyx_t_1);
2819   __Pyx_XDECREF(__pyx_t_2);
2820   __Pyx_AddTraceback("lxml.html.diff.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2821   __pyx_r = NULL;
2822   __pyx_L0:;
2823   __Pyx_XGIVEREF(__pyx_r);
2824   __Pyx_RefNannyFinishContext();
2825   return __pyx_r;
2826 }
2827
2828 /* Python wrapper */
2829 static PyObject *__pyx_pw_4lxml_4html_4diff_3html_annotate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2830 static char __pyx_doc_4lxml_4html_4diff_2html_annotate[] = "\n    doclist should be ordered from oldest to newest, like::\n\n        >>> version1 = 'Hello World'\n        >>> version2 = 'Goodbye World'\n        >>> print(html_annotate([(version1, 'version 1'),\n        ...                      (version2, 'version 2')]))\n        <span title=\"version 2\">Goodbye</span> <span title=\"version 1\">World</span>\n\n    The documents must be *fragments* (str/UTF8 or unicode), not\n    complete documents\n\n    The markup argument is a function to markup the spans of words.\n    This function is called like markup('Hello', 'version 2'), and\n    returns HTML.  The first argument is text and never includes any\n    markup.  The default uses a span with a title:\n\n        >>> print(default_markup('Some Text', 'by Joe'))\n        <span title=\"by Joe\">Some Text</span>\n    ";
2831 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_3html_annotate = {"html_annotate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_3html_annotate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_2html_annotate};
2832 static PyObject *__pyx_pw_4lxml_4html_4diff_3html_annotate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2833   PyObject *__pyx_v_doclist = 0;
2834   PyObject *__pyx_v_markup = 0;
2835   int __pyx_lineno = 0;
2836   const char *__pyx_filename = NULL;
2837   int __pyx_clineno = 0;
2838   PyObject *__pyx_r = 0;
2839   __Pyx_RefNannyDeclarations
2840   __Pyx_RefNannySetupContext("html_annotate (wrapper)", 0);
2841   {
2842     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_doclist,&__pyx_n_s_markup,0};
2843     PyObject* values[2] = {0,0};
2844     __pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
2845     values[1] = __pyx_dynamic_args->__pyx_arg_markup;
2846     if (unlikely(__pyx_kwds)) {
2847       Py_ssize_t kw_args;
2848       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2849       switch (pos_args) {
2850         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2851         CYTHON_FALLTHROUGH;
2852         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2853         CYTHON_FALLTHROUGH;
2854         case  0: break;
2855         default: goto __pyx_L5_argtuple_error;
2856       }
2857       kw_args = PyDict_Size(__pyx_kwds);
2858       switch (pos_args) {
2859         case  0:
2860         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doclist)) != 0)) kw_args--;
2861         else goto __pyx_L5_argtuple_error;
2862         CYTHON_FALLTHROUGH;
2863         case  1:
2864         if (kw_args > 0) {
2865           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_markup);
2866           if (value) { values[1] = value; kw_args--; }
2867         }
2868       }
2869       if (unlikely(kw_args > 0)) {
2870         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "html_annotate") < 0)) __PYX_ERR(0, 35, __pyx_L3_error)
2871       }
2872     } else {
2873       switch (PyTuple_GET_SIZE(__pyx_args)) {
2874         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2875         CYTHON_FALLTHROUGH;
2876         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2877         break;
2878         default: goto __pyx_L5_argtuple_error;
2879       }
2880     }
2881     __pyx_v_doclist = values[0];
2882     __pyx_v_markup = values[1];
2883   }
2884   goto __pyx_L4_argument_unpacking_done;
2885   __pyx_L5_argtuple_error:;
2886   __Pyx_RaiseArgtupleInvalid("html_annotate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 35, __pyx_L3_error)
2887   __pyx_L3_error:;
2888   __Pyx_AddTraceback("lxml.html.diff.html_annotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
2889   __Pyx_RefNannyFinishContext();
2890   return NULL;
2891   __pyx_L4_argument_unpacking_done:;
2892   __pyx_r = __pyx_pf_4lxml_4html_4diff_2html_annotate(__pyx_self, __pyx_v_doclist, __pyx_v_markup);
2893
2894   /* function exit code */
2895   __Pyx_RefNannyFinishContext();
2896   return __pyx_r;
2897 }
2898
2899 static PyObject *__pyx_pf_4lxml_4html_4diff_2html_annotate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doclist, PyObject *__pyx_v_markup) {
2900   PyObject *__pyx_v_tokenlist = NULL;
2901   PyObject *__pyx_v_cur_tokens = NULL;
2902   PyObject *__pyx_v_tokens = NULL;
2903   PyObject *__pyx_v_result = NULL;
2904   PyObject *__pyx_7genexpr__pyx_v_doc = NULL;
2905   PyObject *__pyx_7genexpr__pyx_v_version = NULL;
2906   PyObject *__pyx_r = NULL;
2907   __Pyx_RefNannyDeclarations
2908   PyObject *__pyx_t_1 = NULL;
2909   PyObject *__pyx_t_2 = NULL;
2910   Py_ssize_t __pyx_t_3;
2911   PyObject *(*__pyx_t_4)(PyObject *);
2912   PyObject *__pyx_t_5 = NULL;
2913   PyObject *__pyx_t_6 = NULL;
2914   PyObject *__pyx_t_7 = NULL;
2915   PyObject *__pyx_t_8 = NULL;
2916   PyObject *(*__pyx_t_9)(PyObject *);
2917   int __pyx_t_10;
2918   int __pyx_lineno = 0;
2919   const char *__pyx_filename = NULL;
2920   int __pyx_clineno = 0;
2921   __Pyx_RefNannySetupContext("html_annotate", 0);
2922
2923   /* "lxml/html/diff.py":61
2924  *     # appeared in the document; the annotation attached to the token
2925  *     # is the version where it first appeared.
2926  *     tokenlist = [tokenize_annotated(doc, version)             # <<<<<<<<<<<<<<
2927  *                  for doc, version in doclist]
2928  *     cur_tokens = tokenlist[0]
2929  */
2930   { /* enter inner scope */
2931     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L5_error)
2932     __Pyx_GOTREF(__pyx_t_1);
2933
2934     /* "lxml/html/diff.py":62
2935  *     # is the version where it first appeared.
2936  *     tokenlist = [tokenize_annotated(doc, version)
2937  *                  for doc, version in doclist]             # <<<<<<<<<<<<<<
2938  *     cur_tokens = tokenlist[0]
2939  *     for tokens in tokenlist[1:]:
2940  */
2941     if (likely(PyList_CheckExact(__pyx_v_doclist)) || PyTuple_CheckExact(__pyx_v_doclist)) {
2942       __pyx_t_2 = __pyx_v_doclist; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
2943       __pyx_t_4 = NULL;
2944     } else {
2945       __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_doclist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L5_error)
2946       __Pyx_GOTREF(__pyx_t_2);
2947       __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 62, __pyx_L5_error)
2948     }
2949     for (;;) {
2950       if (likely(!__pyx_t_4)) {
2951         if (likely(PyList_CheckExact(__pyx_t_2))) {
2952           if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
2953           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2954           __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 62, __pyx_L5_error)
2955           #else
2956           __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L5_error)
2957           __Pyx_GOTREF(__pyx_t_5);
2958           #endif
2959         } else {
2960           if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
2961           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2962           __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 62, __pyx_L5_error)
2963           #else
2964           __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L5_error)
2965           __Pyx_GOTREF(__pyx_t_5);
2966           #endif
2967         }
2968       } else {
2969         __pyx_t_5 = __pyx_t_4(__pyx_t_2);
2970         if (unlikely(!__pyx_t_5)) {
2971           PyObject* exc_type = PyErr_Occurred();
2972           if (exc_type) {
2973             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2974             else __PYX_ERR(0, 62, __pyx_L5_error)
2975           }
2976           break;
2977         }
2978         __Pyx_GOTREF(__pyx_t_5);
2979       }
2980       if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
2981         PyObject* sequence = __pyx_t_5;
2982         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
2983         if (unlikely(size != 2)) {
2984           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
2985           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
2986           __PYX_ERR(0, 62, __pyx_L5_error)
2987         }
2988         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2989         if (likely(PyTuple_CheckExact(sequence))) {
2990           __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
2991           __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
2992         } else {
2993           __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
2994           __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
2995         }
2996         __Pyx_INCREF(__pyx_t_6);
2997         __Pyx_INCREF(__pyx_t_7);
2998         #else
2999         __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 62, __pyx_L5_error)
3000         __Pyx_GOTREF(__pyx_t_6);
3001         __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L5_error)
3002         __Pyx_GOTREF(__pyx_t_7);
3003         #endif
3004         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3005       } else {
3006         Py_ssize_t index = -1;
3007         __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 62, __pyx_L5_error)
3008         __Pyx_GOTREF(__pyx_t_8);
3009         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3010         __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
3011         index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed;
3012         __Pyx_GOTREF(__pyx_t_6);
3013         index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L8_unpacking_failed;
3014         __Pyx_GOTREF(__pyx_t_7);
3015         if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 62, __pyx_L5_error)
3016         __pyx_t_9 = NULL;
3017         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3018         goto __pyx_L9_unpacking_done;
3019         __pyx_L8_unpacking_failed:;
3020         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3021         __pyx_t_9 = NULL;
3022         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
3023         __PYX_ERR(0, 62, __pyx_L5_error)
3024         __pyx_L9_unpacking_done:;
3025       }
3026       __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_doc, __pyx_t_6);
3027       __pyx_t_6 = 0;
3028       __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_version, __pyx_t_7);
3029       __pyx_t_7 = 0;
3030
3031       /* "lxml/html/diff.py":61
3032  *     # appeared in the document; the annotation attached to the token
3033  *     # is the version where it first appeared.
3034  *     tokenlist = [tokenize_annotated(doc, version)             # <<<<<<<<<<<<<<
3035  *                  for doc, version in doclist]
3036  *     cur_tokens = tokenlist[0]
3037  */
3038       __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_tokenize_annotated); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 61, __pyx_L5_error)
3039       __Pyx_GOTREF(__pyx_t_7);
3040       __pyx_t_6 = NULL;
3041       __pyx_t_10 = 0;
3042       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
3043         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
3044         if (likely(__pyx_t_6)) {
3045           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
3046           __Pyx_INCREF(__pyx_t_6);
3047           __Pyx_INCREF(function);
3048           __Pyx_DECREF_SET(__pyx_t_7, function);
3049           __pyx_t_10 = 1;
3050         }
3051       }
3052       #if CYTHON_FAST_PYCALL
3053       if (PyFunction_Check(__pyx_t_7)) {
3054         PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_7genexpr__pyx_v_doc, __pyx_7genexpr__pyx_v_version};
3055         __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L5_error)
3056         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3057         __Pyx_GOTREF(__pyx_t_5);
3058       } else
3059       #endif
3060       #if CYTHON_FAST_PYCCALL
3061       if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
3062         PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_7genexpr__pyx_v_doc, __pyx_7genexpr__pyx_v_version};
3063         __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L5_error)
3064         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3065         __Pyx_GOTREF(__pyx_t_5);
3066       } else
3067       #endif
3068       {
3069         __pyx_t_8 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 61, __pyx_L5_error)
3070         __Pyx_GOTREF(__pyx_t_8);
3071         if (__pyx_t_6) {
3072           __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
3073         }
3074         __Pyx_INCREF(__pyx_7genexpr__pyx_v_doc);
3075         __Pyx_GIVEREF(__pyx_7genexpr__pyx_v_doc);
3076         PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_7genexpr__pyx_v_doc);
3077         __Pyx_INCREF(__pyx_7genexpr__pyx_v_version);
3078         __Pyx_GIVEREF(__pyx_7genexpr__pyx_v_version);
3079         PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_7genexpr__pyx_v_version);
3080         __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L5_error)
3081         __Pyx_GOTREF(__pyx_t_5);
3082         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3083       }
3084       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3085       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 61, __pyx_L5_error)
3086       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3087
3088       /* "lxml/html/diff.py":62
3089  *     # is the version where it first appeared.
3090  *     tokenlist = [tokenize_annotated(doc, version)
3091  *                  for doc, version in doclist]             # <<<<<<<<<<<<<<
3092  *     cur_tokens = tokenlist[0]
3093  *     for tokens in tokenlist[1:]:
3094  */
3095     }
3096     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3097     __Pyx_XDECREF(__pyx_7genexpr__pyx_v_doc); __pyx_7genexpr__pyx_v_doc = 0;
3098     __Pyx_XDECREF(__pyx_7genexpr__pyx_v_version); __pyx_7genexpr__pyx_v_version = 0;
3099     goto __pyx_L10_exit_scope;
3100     __pyx_L5_error:;
3101     __Pyx_XDECREF(__pyx_7genexpr__pyx_v_doc); __pyx_7genexpr__pyx_v_doc = 0;
3102     __Pyx_XDECREF(__pyx_7genexpr__pyx_v_version); __pyx_7genexpr__pyx_v_version = 0;
3103     goto __pyx_L1_error;
3104     __pyx_L10_exit_scope:;
3105   } /* exit inner scope */
3106   __pyx_v_tokenlist = ((PyObject*)__pyx_t_1);
3107   __pyx_t_1 = 0;
3108
3109   /* "lxml/html/diff.py":63
3110  *     tokenlist = [tokenize_annotated(doc, version)
3111  *                  for doc, version in doclist]
3112  *     cur_tokens = tokenlist[0]             # <<<<<<<<<<<<<<
3113  *     for tokens in tokenlist[1:]:
3114  *         html_annotate_merge_annotations(cur_tokens, tokens)
3115  */
3116   __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_tokenlist, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
3117   __Pyx_GOTREF(__pyx_t_1);
3118   __pyx_v_cur_tokens = __pyx_t_1;
3119   __pyx_t_1 = 0;
3120
3121   /* "lxml/html/diff.py":64
3122  *                  for doc, version in doclist]
3123  *     cur_tokens = tokenlist[0]
3124  *     for tokens in tokenlist[1:]:             # <<<<<<<<<<<<<<
3125  *         html_annotate_merge_annotations(cur_tokens, tokens)
3126  *         cur_tokens = tokens
3127  */
3128   __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_tokenlist, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
3129   __Pyx_GOTREF(__pyx_t_1);
3130   __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
3131   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3132   for (;;) {
3133     if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
3134     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3135     __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error)
3136     #else
3137     __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
3138     __Pyx_GOTREF(__pyx_t_1);
3139     #endif
3140     __Pyx_XDECREF_SET(__pyx_v_tokens, __pyx_t_1);
3141     __pyx_t_1 = 0;
3142
3143     /* "lxml/html/diff.py":65
3144  *     cur_tokens = tokenlist[0]
3145  *     for tokens in tokenlist[1:]:
3146  *         html_annotate_merge_annotations(cur_tokens, tokens)             # <<<<<<<<<<<<<<
3147  *         cur_tokens = tokens
3148  * 
3149  */
3150     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_html_annotate_merge_annotations); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
3151     __Pyx_GOTREF(__pyx_t_5);
3152     __pyx_t_7 = NULL;
3153     __pyx_t_10 = 0;
3154     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
3155       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
3156       if (likely(__pyx_t_7)) {
3157         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
3158         __Pyx_INCREF(__pyx_t_7);
3159         __Pyx_INCREF(function);
3160         __Pyx_DECREF_SET(__pyx_t_5, function);
3161         __pyx_t_10 = 1;
3162       }
3163     }
3164     #if CYTHON_FAST_PYCALL
3165     if (PyFunction_Check(__pyx_t_5)) {
3166       PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_cur_tokens, __pyx_v_tokens};
3167       __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
3168       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3169       __Pyx_GOTREF(__pyx_t_1);
3170     } else
3171     #endif
3172     #if CYTHON_FAST_PYCCALL
3173     if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
3174       PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_cur_tokens, __pyx_v_tokens};
3175       __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
3176       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3177       __Pyx_GOTREF(__pyx_t_1);
3178     } else
3179     #endif
3180     {
3181       __pyx_t_8 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
3182       __Pyx_GOTREF(__pyx_t_8);
3183       if (__pyx_t_7) {
3184         __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
3185       }
3186       __Pyx_INCREF(__pyx_v_cur_tokens);
3187       __Pyx_GIVEREF(__pyx_v_cur_tokens);
3188       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_v_cur_tokens);
3189       __Pyx_INCREF(__pyx_v_tokens);
3190       __Pyx_GIVEREF(__pyx_v_tokens);
3191       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_v_tokens);
3192       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
3193       __Pyx_GOTREF(__pyx_t_1);
3194       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3195     }
3196     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3197     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3198
3199     /* "lxml/html/diff.py":66
3200  *     for tokens in tokenlist[1:]:
3201  *         html_annotate_merge_annotations(cur_tokens, tokens)
3202  *         cur_tokens = tokens             # <<<<<<<<<<<<<<
3203  * 
3204  *     # After we've tracked all the tokens, we can combine spans of text
3205  */
3206     __Pyx_INCREF(__pyx_v_tokens);
3207     __Pyx_DECREF_SET(__pyx_v_cur_tokens, __pyx_v_tokens);
3208
3209     /* "lxml/html/diff.py":64
3210  *                  for doc, version in doclist]
3211  *     cur_tokens = tokenlist[0]
3212  *     for tokens in tokenlist[1:]:             # <<<<<<<<<<<<<<
3213  *         html_annotate_merge_annotations(cur_tokens, tokens)
3214  *         cur_tokens = tokens
3215  */
3216   }
3217   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3218
3219   /* "lxml/html/diff.py":70
3220  *     # After we've tracked all the tokens, we can combine spans of text
3221  *     # that are adjacent and have the same annotation
3222  *     cur_tokens = compress_tokens(cur_tokens)             # <<<<<<<<<<<<<<
3223  *     # And finally add markup
3224  *     result = markup_serialize_tokens(cur_tokens, markup)
3225  */
3226   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_compress_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
3227   __Pyx_GOTREF(__pyx_t_1);
3228   __pyx_t_5 = NULL;
3229   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3230     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
3231     if (likely(__pyx_t_5)) {
3232       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3233       __Pyx_INCREF(__pyx_t_5);
3234       __Pyx_INCREF(function);
3235       __Pyx_DECREF_SET(__pyx_t_1, function);
3236     }
3237   }
3238   __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v_cur_tokens) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_cur_tokens);
3239   __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3240   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
3241   __Pyx_GOTREF(__pyx_t_2);
3242   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3243   __Pyx_DECREF_SET(__pyx_v_cur_tokens, __pyx_t_2);
3244   __pyx_t_2 = 0;
3245
3246   /* "lxml/html/diff.py":72
3247  *     cur_tokens = compress_tokens(cur_tokens)
3248  *     # And finally add markup
3249  *     result = markup_serialize_tokens(cur_tokens, markup)             # <<<<<<<<<<<<<<
3250  *     return ''.join(result).strip()
3251  * 
3252  */
3253   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_markup_serialize_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
3254   __Pyx_GOTREF(__pyx_t_1);
3255   __pyx_t_5 = NULL;
3256   __pyx_t_10 = 0;
3257   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3258     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
3259     if (likely(__pyx_t_5)) {
3260       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3261       __Pyx_INCREF(__pyx_t_5);
3262       __Pyx_INCREF(function);
3263       __Pyx_DECREF_SET(__pyx_t_1, function);
3264       __pyx_t_10 = 1;
3265     }
3266   }
3267   #if CYTHON_FAST_PYCALL
3268   if (PyFunction_Check(__pyx_t_1)) {
3269     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_cur_tokens, __pyx_v_markup};
3270     __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
3271     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3272     __Pyx_GOTREF(__pyx_t_2);
3273   } else
3274   #endif
3275   #if CYTHON_FAST_PYCCALL
3276   if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
3277     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_cur_tokens, __pyx_v_markup};
3278     __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
3279     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3280     __Pyx_GOTREF(__pyx_t_2);
3281   } else
3282   #endif
3283   {
3284     __pyx_t_8 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 72, __pyx_L1_error)
3285     __Pyx_GOTREF(__pyx_t_8);
3286     if (__pyx_t_5) {
3287       __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
3288     }
3289     __Pyx_INCREF(__pyx_v_cur_tokens);
3290     __Pyx_GIVEREF(__pyx_v_cur_tokens);
3291     PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_v_cur_tokens);
3292     __Pyx_INCREF(__pyx_v_markup);
3293     __Pyx_GIVEREF(__pyx_v_markup);
3294     PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_v_markup);
3295     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
3296     __Pyx_GOTREF(__pyx_t_2);
3297     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3298   }
3299   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3300   __pyx_v_result = __pyx_t_2;
3301   __pyx_t_2 = 0;
3302
3303   /* "lxml/html/diff.py":73
3304  *     # And finally add markup
3305  *     result = markup_serialize_tokens(cur_tokens, markup)
3306  *     return ''.join(result).strip()             # <<<<<<<<<<<<<<
3307  * 
3308  * def tokenize_annotated(doc, annotation):
3309  */
3310   __Pyx_XDECREF(__pyx_r);
3311   __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__2, __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
3312   __Pyx_GOTREF(__pyx_t_1);
3313   __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_strip); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 73, __pyx_L1_error)
3314   __Pyx_GOTREF(__pyx_t_8);
3315   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3316   __pyx_t_1 = NULL;
3317   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
3318     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
3319     if (likely(__pyx_t_1)) {
3320       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
3321       __Pyx_INCREF(__pyx_t_1);
3322       __Pyx_INCREF(function);
3323       __Pyx_DECREF_SET(__pyx_t_8, function);
3324     }
3325   }
3326   __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
3327   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3328   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
3329   __Pyx_GOTREF(__pyx_t_2);
3330   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3331   __pyx_r = __pyx_t_2;
3332   __pyx_t_2 = 0;
3333   goto __pyx_L0;
3334
3335   /* "lxml/html/diff.py":35
3336  *         html_escape(_unicode(version), 1), text)
3337  * 
3338  * def html_annotate(doclist, markup=default_markup):             # <<<<<<<<<<<<<<
3339  *     """
3340  *     doclist should be ordered from oldest to newest, like::
3341  */
3342
3343   /* function exit code */
3344   __pyx_L1_error:;
3345   __Pyx_XDECREF(__pyx_t_1);
3346   __Pyx_XDECREF(__pyx_t_2);
3347   __Pyx_XDECREF(__pyx_t_5);
3348   __Pyx_XDECREF(__pyx_t_6);
3349   __Pyx_XDECREF(__pyx_t_7);
3350   __Pyx_XDECREF(__pyx_t_8);
3351   __Pyx_AddTraceback("lxml.html.diff.html_annotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
3352   __pyx_r = NULL;
3353   __pyx_L0:;
3354   __Pyx_XDECREF(__pyx_v_tokenlist);
3355   __Pyx_XDECREF(__pyx_v_cur_tokens);
3356   __Pyx_XDECREF(__pyx_v_tokens);
3357   __Pyx_XDECREF(__pyx_v_result);
3358   __Pyx_XDECREF(__pyx_7genexpr__pyx_v_doc);
3359   __Pyx_XDECREF(__pyx_7genexpr__pyx_v_version);
3360   __Pyx_XGIVEREF(__pyx_r);
3361   __Pyx_RefNannyFinishContext();
3362   return __pyx_r;
3363 }
3364
3365 /* "lxml/html/diff.py":75
3366  *     return ''.join(result).strip()
3367  * 
3368  * def tokenize_annotated(doc, annotation):             # <<<<<<<<<<<<<<
3369  *     """Tokenize a document and add an annotation attribute to each token
3370  *     """
3371  */
3372
3373 /* Python wrapper */
3374 static PyObject *__pyx_pw_4lxml_4html_4diff_5tokenize_annotated(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3375 static char __pyx_doc_4lxml_4html_4diff_4tokenize_annotated[] = "Tokenize a document and add an annotation attribute to each token\n    ";
3376 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_5tokenize_annotated = {"tokenize_annotated", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_5tokenize_annotated, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_4tokenize_annotated};
3377 static PyObject *__pyx_pw_4lxml_4html_4diff_5tokenize_annotated(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3378   PyObject *__pyx_v_doc = 0;
3379   PyObject *__pyx_v_annotation = 0;
3380   int __pyx_lineno = 0;
3381   const char *__pyx_filename = NULL;
3382   int __pyx_clineno = 0;
3383   PyObject *__pyx_r = 0;
3384   __Pyx_RefNannyDeclarations
3385   __Pyx_RefNannySetupContext("tokenize_annotated (wrapper)", 0);
3386   {
3387     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_doc,&__pyx_n_s_annotation,0};
3388     PyObject* values[2] = {0,0};
3389     if (unlikely(__pyx_kwds)) {
3390       Py_ssize_t kw_args;
3391       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3392       switch (pos_args) {
3393         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3394         CYTHON_FALLTHROUGH;
3395         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3396         CYTHON_FALLTHROUGH;
3397         case  0: break;
3398         default: goto __pyx_L5_argtuple_error;
3399       }
3400       kw_args = PyDict_Size(__pyx_kwds);
3401       switch (pos_args) {
3402         case  0:
3403         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc)) != 0)) kw_args--;
3404         else goto __pyx_L5_argtuple_error;
3405         CYTHON_FALLTHROUGH;
3406         case  1:
3407         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_annotation)) != 0)) kw_args--;
3408         else {
3409           __Pyx_RaiseArgtupleInvalid("tokenize_annotated", 1, 2, 2, 1); __PYX_ERR(0, 75, __pyx_L3_error)
3410         }
3411       }
3412       if (unlikely(kw_args > 0)) {
3413         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tokenize_annotated") < 0)) __PYX_ERR(0, 75, __pyx_L3_error)
3414       }
3415     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3416       goto __pyx_L5_argtuple_error;
3417     } else {
3418       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3419       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3420     }
3421     __pyx_v_doc = values[0];
3422     __pyx_v_annotation = values[1];
3423   }
3424   goto __pyx_L4_argument_unpacking_done;
3425   __pyx_L5_argtuple_error:;
3426   __Pyx_RaiseArgtupleInvalid("tokenize_annotated", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 75, __pyx_L3_error)
3427   __pyx_L3_error:;
3428   __Pyx_AddTraceback("lxml.html.diff.tokenize_annotated", __pyx_clineno, __pyx_lineno, __pyx_filename);
3429   __Pyx_RefNannyFinishContext();
3430   return NULL;
3431   __pyx_L4_argument_unpacking_done:;
3432   __pyx_r = __pyx_pf_4lxml_4html_4diff_4tokenize_annotated(__pyx_self, __pyx_v_doc, __pyx_v_annotation);
3433
3434   /* function exit code */
3435   __Pyx_RefNannyFinishContext();
3436   return __pyx_r;
3437 }
3438
3439 static PyObject *__pyx_pf_4lxml_4html_4diff_4tokenize_annotated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doc, PyObject *__pyx_v_annotation) {
3440   PyObject *__pyx_v_tokens = NULL;
3441   PyObject *__pyx_v_tok = NULL;
3442   PyObject *__pyx_r = NULL;
3443   __Pyx_RefNannyDeclarations
3444   PyObject *__pyx_t_1 = NULL;
3445   PyObject *__pyx_t_2 = NULL;
3446   PyObject *__pyx_t_3 = NULL;
3447   PyObject *__pyx_t_4 = NULL;
3448   Py_ssize_t __pyx_t_5;
3449   PyObject *(*__pyx_t_6)(PyObject *);
3450   int __pyx_lineno = 0;
3451   const char *__pyx_filename = NULL;
3452   int __pyx_clineno = 0;
3453   __Pyx_RefNannySetupContext("tokenize_annotated", 0);
3454
3455   /* "lxml/html/diff.py":78
3456  *     """Tokenize a document and add an annotation attribute to each token
3457  *     """
3458  *     tokens = tokenize(doc, include_hrefs=False)             # <<<<<<<<<<<<<<
3459  *     for tok in tokens:
3460  *         tok.annotation = annotation
3461  */
3462   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tokenize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
3463   __Pyx_GOTREF(__pyx_t_1);
3464   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
3465   __Pyx_GOTREF(__pyx_t_2);
3466   __Pyx_INCREF(__pyx_v_doc);
3467   __Pyx_GIVEREF(__pyx_v_doc);
3468   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_doc);
3469   __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
3470   __Pyx_GOTREF(__pyx_t_3);
3471   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_include_hrefs, Py_False) < 0) __PYX_ERR(0, 78, __pyx_L1_error)
3472   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error)
3473   __Pyx_GOTREF(__pyx_t_4);
3474   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3475   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3476   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3477   __pyx_v_tokens = __pyx_t_4;
3478   __pyx_t_4 = 0;
3479
3480   /* "lxml/html/diff.py":79
3481  *     """
3482  *     tokens = tokenize(doc, include_hrefs=False)
3483  *     for tok in tokens:             # <<<<<<<<<<<<<<
3484  *         tok.annotation = annotation
3485  *     return tokens
3486  */
3487   if (likely(PyList_CheckExact(__pyx_v_tokens)) || PyTuple_CheckExact(__pyx_v_tokens)) {
3488     __pyx_t_4 = __pyx_v_tokens; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
3489     __pyx_t_6 = NULL;
3490   } else {
3491     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tokens); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
3492     __Pyx_GOTREF(__pyx_t_4);
3493     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error)
3494   }
3495   for (;;) {
3496     if (likely(!__pyx_t_6)) {
3497       if (likely(PyList_CheckExact(__pyx_t_4))) {
3498         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
3499         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3500         __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
3501         #else
3502         __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
3503         __Pyx_GOTREF(__pyx_t_3);
3504         #endif
3505       } else {
3506         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
3507         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3508         __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
3509         #else
3510         __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
3511         __Pyx_GOTREF(__pyx_t_3);
3512         #endif
3513       }
3514     } else {
3515       __pyx_t_3 = __pyx_t_6(__pyx_t_4);
3516       if (unlikely(!__pyx_t_3)) {
3517         PyObject* exc_type = PyErr_Occurred();
3518         if (exc_type) {
3519           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3520           else __PYX_ERR(0, 79, __pyx_L1_error)
3521         }
3522         break;
3523       }
3524       __Pyx_GOTREF(__pyx_t_3);
3525     }
3526     __Pyx_XDECREF_SET(__pyx_v_tok, __pyx_t_3);
3527     __pyx_t_3 = 0;
3528
3529     /* "lxml/html/diff.py":80
3530  *     tokens = tokenize(doc, include_hrefs=False)
3531  *     for tok in tokens:
3532  *         tok.annotation = annotation             # <<<<<<<<<<<<<<
3533  *     return tokens
3534  * 
3535  */
3536     if (__Pyx_PyObject_SetAttrStr(__pyx_v_tok, __pyx_n_s_annotation, __pyx_v_annotation) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
3537
3538     /* "lxml/html/diff.py":79
3539  *     """
3540  *     tokens = tokenize(doc, include_hrefs=False)
3541  *     for tok in tokens:             # <<<<<<<<<<<<<<
3542  *         tok.annotation = annotation
3543  *     return tokens
3544  */
3545   }
3546   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3547
3548   /* "lxml/html/diff.py":81
3549  *     for tok in tokens:
3550  *         tok.annotation = annotation
3551  *     return tokens             # <<<<<<<<<<<<<<
3552  * 
3553  * def html_annotate_merge_annotations(tokens_old, tokens_new):
3554  */
3555   __Pyx_XDECREF(__pyx_r);
3556   __Pyx_INCREF(__pyx_v_tokens);
3557   __pyx_r = __pyx_v_tokens;
3558   goto __pyx_L0;
3559
3560   /* "lxml/html/diff.py":75
3561  *     return ''.join(result).strip()
3562  * 
3563  * def tokenize_annotated(doc, annotation):             # <<<<<<<<<<<<<<
3564  *     """Tokenize a document and add an annotation attribute to each token
3565  *     """
3566  */
3567
3568   /* function exit code */
3569   __pyx_L1_error:;
3570   __Pyx_XDECREF(__pyx_t_1);
3571   __Pyx_XDECREF(__pyx_t_2);
3572   __Pyx_XDECREF(__pyx_t_3);
3573   __Pyx_XDECREF(__pyx_t_4);
3574   __Pyx_AddTraceback("lxml.html.diff.tokenize_annotated", __pyx_clineno, __pyx_lineno, __pyx_filename);
3575   __pyx_r = NULL;
3576   __pyx_L0:;
3577   __Pyx_XDECREF(__pyx_v_tokens);
3578   __Pyx_XDECREF(__pyx_v_tok);
3579   __Pyx_XGIVEREF(__pyx_r);
3580   __Pyx_RefNannyFinishContext();
3581   return __pyx_r;
3582 }
3583
3584 /* "lxml/html/diff.py":83
3585  *     return tokens
3586  * 
3587  * def html_annotate_merge_annotations(tokens_old, tokens_new):             # <<<<<<<<<<<<<<
3588  *     """Merge the annotations from tokens_old into tokens_new, when the
3589  *     tokens in the new document already existed in the old document.
3590  */
3591
3592 /* Python wrapper */
3593 static PyObject *__pyx_pw_4lxml_4html_4diff_7html_annotate_merge_annotations(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3594 static char __pyx_doc_4lxml_4html_4diff_6html_annotate_merge_annotations[] = "Merge the annotations from tokens_old into tokens_new, when the\n    tokens in the new document already existed in the old document.\n    ";
3595 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_7html_annotate_merge_annotations = {"html_annotate_merge_annotations", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_7html_annotate_merge_annotations, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_6html_annotate_merge_annotations};
3596 static PyObject *__pyx_pw_4lxml_4html_4diff_7html_annotate_merge_annotations(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3597   PyObject *__pyx_v_tokens_old = 0;
3598   PyObject *__pyx_v_tokens_new = 0;
3599   int __pyx_lineno = 0;
3600   const char *__pyx_filename = NULL;
3601   int __pyx_clineno = 0;
3602   PyObject *__pyx_r = 0;
3603   __Pyx_RefNannyDeclarations
3604   __Pyx_RefNannySetupContext("html_annotate_merge_annotations (wrapper)", 0);
3605   {
3606     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tokens_old,&__pyx_n_s_tokens_new,0};
3607     PyObject* values[2] = {0,0};
3608     if (unlikely(__pyx_kwds)) {
3609       Py_ssize_t kw_args;
3610       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3611       switch (pos_args) {
3612         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3613         CYTHON_FALLTHROUGH;
3614         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3615         CYTHON_FALLTHROUGH;
3616         case  0: break;
3617         default: goto __pyx_L5_argtuple_error;
3618       }
3619       kw_args = PyDict_Size(__pyx_kwds);
3620       switch (pos_args) {
3621         case  0:
3622         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tokens_old)) != 0)) kw_args--;
3623         else goto __pyx_L5_argtuple_error;
3624         CYTHON_FALLTHROUGH;
3625         case  1:
3626         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tokens_new)) != 0)) kw_args--;
3627         else {
3628           __Pyx_RaiseArgtupleInvalid("html_annotate_merge_annotations", 1, 2, 2, 1); __PYX_ERR(0, 83, __pyx_L3_error)
3629         }
3630       }
3631       if (unlikely(kw_args > 0)) {
3632         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "html_annotate_merge_annotations") < 0)) __PYX_ERR(0, 83, __pyx_L3_error)
3633       }
3634     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3635       goto __pyx_L5_argtuple_error;
3636     } else {
3637       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3638       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3639     }
3640     __pyx_v_tokens_old = values[0];
3641     __pyx_v_tokens_new = values[1];
3642   }
3643   goto __pyx_L4_argument_unpacking_done;
3644   __pyx_L5_argtuple_error:;
3645   __Pyx_RaiseArgtupleInvalid("html_annotate_merge_annotations", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 83, __pyx_L3_error)
3646   __pyx_L3_error:;
3647   __Pyx_AddTraceback("lxml.html.diff.html_annotate_merge_annotations", __pyx_clineno, __pyx_lineno, __pyx_filename);
3648   __Pyx_RefNannyFinishContext();
3649   return NULL;
3650   __pyx_L4_argument_unpacking_done:;
3651   __pyx_r = __pyx_pf_4lxml_4html_4diff_6html_annotate_merge_annotations(__pyx_self, __pyx_v_tokens_old, __pyx_v_tokens_new);
3652
3653   /* function exit code */
3654   __Pyx_RefNannyFinishContext();
3655   return __pyx_r;
3656 }
3657
3658 static PyObject *__pyx_pf_4lxml_4html_4diff_6html_annotate_merge_annotations(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens_old, PyObject *__pyx_v_tokens_new) {
3659   PyObject *__pyx_v_s = NULL;
3660   PyObject *__pyx_v_commands = NULL;
3661   PyObject *__pyx_v_command = NULL;
3662   PyObject *__pyx_v_i1 = NULL;
3663   PyObject *__pyx_v_i2 = NULL;
3664   PyObject *__pyx_v_j1 = NULL;
3665   PyObject *__pyx_v_j2 = NULL;
3666   PyObject *__pyx_v_eq_old = NULL;
3667   PyObject *__pyx_v_eq_new = NULL;
3668   PyObject *__pyx_r = NULL;
3669   __Pyx_RefNannyDeclarations
3670   PyObject *__pyx_t_1 = NULL;
3671   PyObject *__pyx_t_2 = NULL;
3672   PyObject *__pyx_t_3 = NULL;
3673   Py_ssize_t __pyx_t_4;
3674   PyObject *(*__pyx_t_5)(PyObject *);
3675   PyObject *__pyx_t_6 = NULL;
3676   PyObject *__pyx_t_7 = NULL;
3677   PyObject *__pyx_t_8 = NULL;
3678   PyObject *__pyx_t_9 = NULL;
3679   PyObject *__pyx_t_10 = NULL;
3680   PyObject *(*__pyx_t_11)(PyObject *);
3681   int __pyx_t_12;
3682   int __pyx_t_13;
3683   int __pyx_lineno = 0;
3684   const char *__pyx_filename = NULL;
3685   int __pyx_clineno = 0;
3686   __Pyx_RefNannySetupContext("html_annotate_merge_annotations", 0);
3687
3688   /* "lxml/html/diff.py":87
3689  *     tokens in the new document already existed in the old document.
3690  *     """
3691  *     s = InsensitiveSequenceMatcher(a=tokens_old, b=tokens_new)             # <<<<<<<<<<<<<<
3692  *     commands = s.get_opcodes()
3693  * 
3694  */
3695   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_InsensitiveSequenceMatcher); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
3696   __Pyx_GOTREF(__pyx_t_1);
3697   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
3698   __Pyx_GOTREF(__pyx_t_2);
3699   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_a, __pyx_v_tokens_old) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
3700   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_b, __pyx_v_tokens_new) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
3701   __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
3702   __Pyx_GOTREF(__pyx_t_3);
3703   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3704   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3705   __pyx_v_s = __pyx_t_3;
3706   __pyx_t_3 = 0;
3707
3708   /* "lxml/html/diff.py":88
3709  *     """
3710  *     s = InsensitiveSequenceMatcher(a=tokens_old, b=tokens_new)
3711  *     commands = s.get_opcodes()             # <<<<<<<<<<<<<<
3712  * 
3713  *     for command, i1, i2, j1, j2 in commands:
3714  */
3715   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_get_opcodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
3716   __Pyx_GOTREF(__pyx_t_2);
3717   __pyx_t_1 = NULL;
3718   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3719     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
3720     if (likely(__pyx_t_1)) {
3721       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3722       __Pyx_INCREF(__pyx_t_1);
3723       __Pyx_INCREF(function);
3724       __Pyx_DECREF_SET(__pyx_t_2, function);
3725     }
3726   }
3727   __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
3728   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3729   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
3730   __Pyx_GOTREF(__pyx_t_3);
3731   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3732   __pyx_v_commands = __pyx_t_3;
3733   __pyx_t_3 = 0;
3734
3735   /* "lxml/html/diff.py":90
3736  *     commands = s.get_opcodes()
3737  * 
3738  *     for command, i1, i2, j1, j2 in commands:             # <<<<<<<<<<<<<<
3739  *         if command == 'equal':
3740  *             eq_old = tokens_old[i1:i2]
3741  */
3742   if (likely(PyList_CheckExact(__pyx_v_commands)) || PyTuple_CheckExact(__pyx_v_commands)) {
3743     __pyx_t_3 = __pyx_v_commands; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
3744     __pyx_t_5 = NULL;
3745   } else {
3746     __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_commands); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
3747     __Pyx_GOTREF(__pyx_t_3);
3748     __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error)
3749   }
3750   for (;;) {
3751     if (likely(!__pyx_t_5)) {
3752       if (likely(PyList_CheckExact(__pyx_t_3))) {
3753         if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
3754         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3755         __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 90, __pyx_L1_error)
3756         #else
3757         __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
3758         __Pyx_GOTREF(__pyx_t_2);
3759         #endif
3760       } else {
3761         if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
3762         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3763         __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 90, __pyx_L1_error)
3764         #else
3765         __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
3766         __Pyx_GOTREF(__pyx_t_2);
3767         #endif
3768       }
3769     } else {
3770       __pyx_t_2 = __pyx_t_5(__pyx_t_3);
3771       if (unlikely(!__pyx_t_2)) {
3772         PyObject* exc_type = PyErr_Occurred();
3773         if (exc_type) {
3774           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3775           else __PYX_ERR(0, 90, __pyx_L1_error)
3776         }
3777         break;
3778       }
3779       __Pyx_GOTREF(__pyx_t_2);
3780     }
3781     if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
3782       PyObject* sequence = __pyx_t_2;
3783       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
3784       if (unlikely(size != 5)) {
3785         if (size > 5) __Pyx_RaiseTooManyValuesError(5);
3786         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
3787         __PYX_ERR(0, 90, __pyx_L1_error)
3788       }
3789       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3790       if (likely(PyTuple_CheckExact(sequence))) {
3791         __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
3792         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
3793         __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
3794         __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
3795         __pyx_t_9 = PyTuple_GET_ITEM(sequence, 4); 
3796       } else {
3797         __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
3798         __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
3799         __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
3800         __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
3801         __pyx_t_9 = PyList_GET_ITEM(sequence, 4); 
3802       }
3803       __Pyx_INCREF(__pyx_t_1);
3804       __Pyx_INCREF(__pyx_t_6);
3805       __Pyx_INCREF(__pyx_t_7);
3806       __Pyx_INCREF(__pyx_t_8);
3807       __Pyx_INCREF(__pyx_t_9);
3808       #else
3809       {
3810         Py_ssize_t i;
3811         PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9};
3812         for (i=0; i < 5; i++) {
3813           PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 90, __pyx_L1_error)
3814           __Pyx_GOTREF(item);
3815           *(temps[i]) = item;
3816         }
3817       }
3818       #endif
3819       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3820     } else {
3821       Py_ssize_t index = -1;
3822       PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9};
3823       __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 90, __pyx_L1_error)
3824       __Pyx_GOTREF(__pyx_t_10);
3825       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3826       __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
3827       for (index=0; index < 5; index++) {
3828         PyObject* item = __pyx_t_11(__pyx_t_10); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
3829         __Pyx_GOTREF(item);
3830         *(temps[index]) = item;
3831       }
3832       if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 5) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
3833       __pyx_t_11 = NULL;
3834       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
3835       goto __pyx_L6_unpacking_done;
3836       __pyx_L5_unpacking_failed:;
3837       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
3838       __pyx_t_11 = NULL;
3839       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
3840       __PYX_ERR(0, 90, __pyx_L1_error)
3841       __pyx_L6_unpacking_done:;
3842     }
3843     __Pyx_XDECREF_SET(__pyx_v_command, __pyx_t_1);
3844     __pyx_t_1 = 0;
3845     __Pyx_XDECREF_SET(__pyx_v_i1, __pyx_t_6);
3846     __pyx_t_6 = 0;
3847     __Pyx_XDECREF_SET(__pyx_v_i2, __pyx_t_7);
3848     __pyx_t_7 = 0;
3849     __Pyx_XDECREF_SET(__pyx_v_j1, __pyx_t_8);
3850     __pyx_t_8 = 0;
3851     __Pyx_XDECREF_SET(__pyx_v_j2, __pyx_t_9);
3852     __pyx_t_9 = 0;
3853
3854     /* "lxml/html/diff.py":91
3855  * 
3856  *     for command, i1, i2, j1, j2 in commands:
3857  *         if command == 'equal':             # <<<<<<<<<<<<<<
3858  *             eq_old = tokens_old[i1:i2]
3859  *             eq_new = tokens_new[j1:j2]
3860  */
3861     __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_equal, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 91, __pyx_L1_error)
3862     if (__pyx_t_12) {
3863
3864       /* "lxml/html/diff.py":92
3865  *     for command, i1, i2, j1, j2 in commands:
3866  *         if command == 'equal':
3867  *             eq_old = tokens_old[i1:i2]             # <<<<<<<<<<<<<<
3868  *             eq_new = tokens_new[j1:j2]
3869  *             copy_annotations(eq_old, eq_new)
3870  */
3871       __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_tokens_old, 0, 0, &__pyx_v_i1, &__pyx_v_i2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
3872       __Pyx_GOTREF(__pyx_t_2);
3873       __Pyx_XDECREF_SET(__pyx_v_eq_old, __pyx_t_2);
3874       __pyx_t_2 = 0;
3875
3876       /* "lxml/html/diff.py":93
3877  *         if command == 'equal':
3878  *             eq_old = tokens_old[i1:i2]
3879  *             eq_new = tokens_new[j1:j2]             # <<<<<<<<<<<<<<
3880  *             copy_annotations(eq_old, eq_new)
3881  * 
3882  */
3883       __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_tokens_new, 0, 0, &__pyx_v_j1, &__pyx_v_j2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
3884       __Pyx_GOTREF(__pyx_t_2);
3885       __Pyx_XDECREF_SET(__pyx_v_eq_new, __pyx_t_2);
3886       __pyx_t_2 = 0;
3887
3888       /* "lxml/html/diff.py":94
3889  *             eq_old = tokens_old[i1:i2]
3890  *             eq_new = tokens_new[j1:j2]
3891  *             copy_annotations(eq_old, eq_new)             # <<<<<<<<<<<<<<
3892  * 
3893  * def copy_annotations(src, dest):
3894  */
3895       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_copy_annotations); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 94, __pyx_L1_error)
3896       __Pyx_GOTREF(__pyx_t_9);
3897       __pyx_t_8 = NULL;
3898       __pyx_t_13 = 0;
3899       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
3900         __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
3901         if (likely(__pyx_t_8)) {
3902           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
3903           __Pyx_INCREF(__pyx_t_8);
3904           __Pyx_INCREF(function);
3905           __Pyx_DECREF_SET(__pyx_t_9, function);
3906           __pyx_t_13 = 1;
3907         }
3908       }
3909       #if CYTHON_FAST_PYCALL
3910       if (PyFunction_Check(__pyx_t_9)) {
3911         PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_eq_old, __pyx_v_eq_new};
3912         __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
3913         __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
3914         __Pyx_GOTREF(__pyx_t_2);
3915       } else
3916       #endif
3917       #if CYTHON_FAST_PYCCALL
3918       if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
3919         PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_eq_old, __pyx_v_eq_new};
3920         __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
3921         __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
3922         __Pyx_GOTREF(__pyx_t_2);
3923       } else
3924       #endif
3925       {
3926         __pyx_t_7 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error)
3927         __Pyx_GOTREF(__pyx_t_7);
3928         if (__pyx_t_8) {
3929           __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
3930         }
3931         __Pyx_INCREF(__pyx_v_eq_old);
3932         __Pyx_GIVEREF(__pyx_v_eq_old);
3933         PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_13, __pyx_v_eq_old);
3934         __Pyx_INCREF(__pyx_v_eq_new);
3935         __Pyx_GIVEREF(__pyx_v_eq_new);
3936         PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_13, __pyx_v_eq_new);
3937         __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
3938         __Pyx_GOTREF(__pyx_t_2);
3939         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3940       }
3941       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3942       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3943
3944       /* "lxml/html/diff.py":91
3945  * 
3946  *     for command, i1, i2, j1, j2 in commands:
3947  *         if command == 'equal':             # <<<<<<<<<<<<<<
3948  *             eq_old = tokens_old[i1:i2]
3949  *             eq_new = tokens_new[j1:j2]
3950  */
3951     }
3952
3953     /* "lxml/html/diff.py":90
3954  *     commands = s.get_opcodes()
3955  * 
3956  *     for command, i1, i2, j1, j2 in commands:             # <<<<<<<<<<<<<<
3957  *         if command == 'equal':
3958  *             eq_old = tokens_old[i1:i2]
3959  */
3960   }
3961   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3962
3963   /* "lxml/html/diff.py":83
3964  *     return tokens
3965  * 
3966  * def html_annotate_merge_annotations(tokens_old, tokens_new):             # <<<<<<<<<<<<<<
3967  *     """Merge the annotations from tokens_old into tokens_new, when the
3968  *     tokens in the new document already existed in the old document.
3969  */
3970
3971   /* function exit code */
3972   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3973   goto __pyx_L0;
3974   __pyx_L1_error:;
3975   __Pyx_XDECREF(__pyx_t_1);
3976   __Pyx_XDECREF(__pyx_t_2);
3977   __Pyx_XDECREF(__pyx_t_3);
3978   __Pyx_XDECREF(__pyx_t_6);
3979   __Pyx_XDECREF(__pyx_t_7);
3980   __Pyx_XDECREF(__pyx_t_8);
3981   __Pyx_XDECREF(__pyx_t_9);
3982   __Pyx_XDECREF(__pyx_t_10);
3983   __Pyx_AddTraceback("lxml.html.diff.html_annotate_merge_annotations", __pyx_clineno, __pyx_lineno, __pyx_filename);
3984   __pyx_r = NULL;
3985   __pyx_L0:;
3986   __Pyx_XDECREF(__pyx_v_s);
3987   __Pyx_XDECREF(__pyx_v_commands);
3988   __Pyx_XDECREF(__pyx_v_command);
3989   __Pyx_XDECREF(__pyx_v_i1);
3990   __Pyx_XDECREF(__pyx_v_i2);
3991   __Pyx_XDECREF(__pyx_v_j1);
3992   __Pyx_XDECREF(__pyx_v_j2);
3993   __Pyx_XDECREF(__pyx_v_eq_old);
3994   __Pyx_XDECREF(__pyx_v_eq_new);
3995   __Pyx_XGIVEREF(__pyx_r);
3996   __Pyx_RefNannyFinishContext();
3997   return __pyx_r;
3998 }
3999
4000 /* "lxml/html/diff.py":96
4001  *             copy_annotations(eq_old, eq_new)
4002  * 
4003  * def copy_annotations(src, dest):             # <<<<<<<<<<<<<<
4004  *     """
4005  *     Copy annotations from the tokens listed in src to the tokens in dest
4006  */
4007
4008 /* Python wrapper */
4009 static PyObject *__pyx_pw_4lxml_4html_4diff_9copy_annotations(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4010 static char __pyx_doc_4lxml_4html_4diff_8copy_annotations[] = "\n    Copy annotations from the tokens listed in src to the tokens in dest\n    ";
4011 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_9copy_annotations = {"copy_annotations", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_9copy_annotations, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_8copy_annotations};
4012 static PyObject *__pyx_pw_4lxml_4html_4diff_9copy_annotations(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4013   PyObject *__pyx_v_src = 0;
4014   PyObject *__pyx_v_dest = 0;
4015   int __pyx_lineno = 0;
4016   const char *__pyx_filename = NULL;
4017   int __pyx_clineno = 0;
4018   PyObject *__pyx_r = 0;
4019   __Pyx_RefNannyDeclarations
4020   __Pyx_RefNannySetupContext("copy_annotations (wrapper)", 0);
4021   {
4022     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src,&__pyx_n_s_dest,0};
4023     PyObject* values[2] = {0,0};
4024     if (unlikely(__pyx_kwds)) {
4025       Py_ssize_t kw_args;
4026       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4027       switch (pos_args) {
4028         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4029         CYTHON_FALLTHROUGH;
4030         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4031         CYTHON_FALLTHROUGH;
4032         case  0: break;
4033         default: goto __pyx_L5_argtuple_error;
4034       }
4035       kw_args = PyDict_Size(__pyx_kwds);
4036       switch (pos_args) {
4037         case  0:
4038         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_src)) != 0)) kw_args--;
4039         else goto __pyx_L5_argtuple_error;
4040         CYTHON_FALLTHROUGH;
4041         case  1:
4042         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest)) != 0)) kw_args--;
4043         else {
4044           __Pyx_RaiseArgtupleInvalid("copy_annotations", 1, 2, 2, 1); __PYX_ERR(0, 96, __pyx_L3_error)
4045         }
4046       }
4047       if (unlikely(kw_args > 0)) {
4048         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "copy_annotations") < 0)) __PYX_ERR(0, 96, __pyx_L3_error)
4049       }
4050     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4051       goto __pyx_L5_argtuple_error;
4052     } else {
4053       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4054       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4055     }
4056     __pyx_v_src = values[0];
4057     __pyx_v_dest = values[1];
4058   }
4059   goto __pyx_L4_argument_unpacking_done;
4060   __pyx_L5_argtuple_error:;
4061   __Pyx_RaiseArgtupleInvalid("copy_annotations", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 96, __pyx_L3_error)
4062   __pyx_L3_error:;
4063   __Pyx_AddTraceback("lxml.html.diff.copy_annotations", __pyx_clineno, __pyx_lineno, __pyx_filename);
4064   __Pyx_RefNannyFinishContext();
4065   return NULL;
4066   __pyx_L4_argument_unpacking_done:;
4067   __pyx_r = __pyx_pf_4lxml_4html_4diff_8copy_annotations(__pyx_self, __pyx_v_src, __pyx_v_dest);
4068
4069   /* function exit code */
4070   __Pyx_RefNannyFinishContext();
4071   return __pyx_r;
4072 }
4073
4074 static PyObject *__pyx_pf_4lxml_4html_4diff_8copy_annotations(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src, PyObject *__pyx_v_dest) {
4075   PyObject *__pyx_v_src_tok = NULL;
4076   PyObject *__pyx_v_dest_tok = NULL;
4077   PyObject *__pyx_r = NULL;
4078   __Pyx_RefNannyDeclarations
4079   Py_ssize_t __pyx_t_1;
4080   Py_ssize_t __pyx_t_2;
4081   PyObject *__pyx_t_3 = NULL;
4082   PyObject *__pyx_t_4 = NULL;
4083   PyObject *(*__pyx_t_5)(PyObject *);
4084   PyObject *__pyx_t_6 = NULL;
4085   PyObject *__pyx_t_7 = NULL;
4086   PyObject *__pyx_t_8 = NULL;
4087   PyObject *(*__pyx_t_9)(PyObject *);
4088   int __pyx_lineno = 0;
4089   const char *__pyx_filename = NULL;
4090   int __pyx_clineno = 0;
4091   __Pyx_RefNannySetupContext("copy_annotations", 0);
4092
4093   /* "lxml/html/diff.py":100
4094  *     Copy annotations from the tokens listed in src to the tokens in dest
4095  *     """
4096  *     assert len(src) == len(dest)             # <<<<<<<<<<<<<<
4097  *     for src_tok, dest_tok in zip(src, dest):
4098  *         dest_tok.annotation = src_tok.annotation
4099  */
4100   #ifndef CYTHON_WITHOUT_ASSERTIONS
4101   if (unlikely(!Py_OptimizeFlag)) {
4102     __pyx_t_1 = PyObject_Length(__pyx_v_src); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 100, __pyx_L1_error)
4103     __pyx_t_2 = PyObject_Length(__pyx_v_dest); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 100, __pyx_L1_error)
4104     if (unlikely(!((__pyx_t_1 == __pyx_t_2) != 0))) {
4105       PyErr_SetNone(PyExc_AssertionError);
4106       __PYX_ERR(0, 100, __pyx_L1_error)
4107     }
4108   }
4109   #endif
4110
4111   /* "lxml/html/diff.py":101
4112  *     """
4113  *     assert len(src) == len(dest)
4114  *     for src_tok, dest_tok in zip(src, dest):             # <<<<<<<<<<<<<<
4115  *         dest_tok.annotation = src_tok.annotation
4116  * 
4117  */
4118   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
4119   __Pyx_GOTREF(__pyx_t_3);
4120   __Pyx_INCREF(__pyx_v_src);
4121   __Pyx_GIVEREF(__pyx_v_src);
4122   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_src);
4123   __Pyx_INCREF(__pyx_v_dest);
4124   __Pyx_GIVEREF(__pyx_v_dest);
4125   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dest);
4126   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
4127   __Pyx_GOTREF(__pyx_t_4);
4128   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4129   if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
4130     __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
4131     __pyx_t_5 = NULL;
4132   } else {
4133     __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
4134     __Pyx_GOTREF(__pyx_t_3);
4135     __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 101, __pyx_L1_error)
4136   }
4137   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4138   for (;;) {
4139     if (likely(!__pyx_t_5)) {
4140       if (likely(PyList_CheckExact(__pyx_t_3))) {
4141         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
4142         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4143         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 101, __pyx_L1_error)
4144         #else
4145         __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
4146         __Pyx_GOTREF(__pyx_t_4);
4147         #endif
4148       } else {
4149         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
4150         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4151         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 101, __pyx_L1_error)
4152         #else
4153         __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
4154         __Pyx_GOTREF(__pyx_t_4);
4155         #endif
4156       }
4157     } else {
4158       __pyx_t_4 = __pyx_t_5(__pyx_t_3);
4159       if (unlikely(!__pyx_t_4)) {
4160         PyObject* exc_type = PyErr_Occurred();
4161         if (exc_type) {
4162           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4163           else __PYX_ERR(0, 101, __pyx_L1_error)
4164         }
4165         break;
4166       }
4167       __Pyx_GOTREF(__pyx_t_4);
4168     }
4169     if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
4170       PyObject* sequence = __pyx_t_4;
4171       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
4172       if (unlikely(size != 2)) {
4173         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
4174         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
4175         __PYX_ERR(0, 101, __pyx_L1_error)
4176       }
4177       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4178       if (likely(PyTuple_CheckExact(sequence))) {
4179         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
4180         __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
4181       } else {
4182         __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
4183         __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
4184       }
4185       __Pyx_INCREF(__pyx_t_6);
4186       __Pyx_INCREF(__pyx_t_7);
4187       #else
4188       __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 101, __pyx_L1_error)
4189       __Pyx_GOTREF(__pyx_t_6);
4190       __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error)
4191       __Pyx_GOTREF(__pyx_t_7);
4192       #endif
4193       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4194     } else {
4195       Py_ssize_t index = -1;
4196       __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 101, __pyx_L1_error)
4197       __Pyx_GOTREF(__pyx_t_8);
4198       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4199       __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
4200       index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
4201       __Pyx_GOTREF(__pyx_t_6);
4202       index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
4203       __Pyx_GOTREF(__pyx_t_7);
4204       if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
4205       __pyx_t_9 = NULL;
4206       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4207       goto __pyx_L6_unpacking_done;
4208       __pyx_L5_unpacking_failed:;
4209       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4210       __pyx_t_9 = NULL;
4211       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
4212       __PYX_ERR(0, 101, __pyx_L1_error)
4213       __pyx_L6_unpacking_done:;
4214     }
4215     __Pyx_XDECREF_SET(__pyx_v_src_tok, __pyx_t_6);
4216     __pyx_t_6 = 0;
4217     __Pyx_XDECREF_SET(__pyx_v_dest_tok, __pyx_t_7);
4218     __pyx_t_7 = 0;
4219
4220     /* "lxml/html/diff.py":102
4221  *     assert len(src) == len(dest)
4222  *     for src_tok, dest_tok in zip(src, dest):
4223  *         dest_tok.annotation = src_tok.annotation             # <<<<<<<<<<<<<<
4224  * 
4225  * def compress_tokens(tokens):
4226  */
4227     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_src_tok, __pyx_n_s_annotation); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error)
4228     __Pyx_GOTREF(__pyx_t_4);
4229     if (__Pyx_PyObject_SetAttrStr(__pyx_v_dest_tok, __pyx_n_s_annotation, __pyx_t_4) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
4230     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4231
4232     /* "lxml/html/diff.py":101
4233  *     """
4234  *     assert len(src) == len(dest)
4235  *     for src_tok, dest_tok in zip(src, dest):             # <<<<<<<<<<<<<<
4236  *         dest_tok.annotation = src_tok.annotation
4237  * 
4238  */
4239   }
4240   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4241
4242   /* "lxml/html/diff.py":96
4243  *             copy_annotations(eq_old, eq_new)
4244  * 
4245  * def copy_annotations(src, dest):             # <<<<<<<<<<<<<<
4246  *     """
4247  *     Copy annotations from the tokens listed in src to the tokens in dest
4248  */
4249
4250   /* function exit code */
4251   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4252   goto __pyx_L0;
4253   __pyx_L1_error:;
4254   __Pyx_XDECREF(__pyx_t_3);
4255   __Pyx_XDECREF(__pyx_t_4);
4256   __Pyx_XDECREF(__pyx_t_6);
4257   __Pyx_XDECREF(__pyx_t_7);
4258   __Pyx_XDECREF(__pyx_t_8);
4259   __Pyx_AddTraceback("lxml.html.diff.copy_annotations", __pyx_clineno, __pyx_lineno, __pyx_filename);
4260   __pyx_r = NULL;
4261   __pyx_L0:;
4262   __Pyx_XDECREF(__pyx_v_src_tok);
4263   __Pyx_XDECREF(__pyx_v_dest_tok);
4264   __Pyx_XGIVEREF(__pyx_r);
4265   __Pyx_RefNannyFinishContext();
4266   return __pyx_r;
4267 }
4268
4269 /* "lxml/html/diff.py":104
4270  *         dest_tok.annotation = src_tok.annotation
4271  * 
4272  * def compress_tokens(tokens):             # <<<<<<<<<<<<<<
4273  *     """
4274  *     Combine adjacent tokens when there is no HTML between the tokens,
4275  */
4276
4277 /* Python wrapper */
4278 static PyObject *__pyx_pw_4lxml_4html_4diff_11compress_tokens(PyObject *__pyx_self, PyObject *__pyx_v_tokens); /*proto*/
4279 static char __pyx_doc_4lxml_4html_4diff_10compress_tokens[] = "\n    Combine adjacent tokens when there is no HTML between the tokens, \n    and they share an annotation\n    ";
4280 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_11compress_tokens = {"compress_tokens", (PyCFunction)__pyx_pw_4lxml_4html_4diff_11compress_tokens, METH_O, __pyx_doc_4lxml_4html_4diff_10compress_tokens};
4281 static PyObject *__pyx_pw_4lxml_4html_4diff_11compress_tokens(PyObject *__pyx_self, PyObject *__pyx_v_tokens) {
4282   PyObject *__pyx_r = 0;
4283   __Pyx_RefNannyDeclarations
4284   __Pyx_RefNannySetupContext("compress_tokens (wrapper)", 0);
4285   __pyx_r = __pyx_pf_4lxml_4html_4diff_10compress_tokens(__pyx_self, ((PyObject *)__pyx_v_tokens));
4286
4287   /* function exit code */
4288   __Pyx_RefNannyFinishContext();
4289   return __pyx_r;
4290 }
4291
4292 static PyObject *__pyx_pf_4lxml_4html_4diff_10compress_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens) {
4293   PyObject *__pyx_v_result = NULL;
4294   PyObject *__pyx_v_tok = NULL;
4295   PyObject *__pyx_r = NULL;
4296   __Pyx_RefNannyDeclarations
4297   PyObject *__pyx_t_1 = NULL;
4298   PyObject *__pyx_t_2 = NULL;
4299   Py_ssize_t __pyx_t_3;
4300   PyObject *(*__pyx_t_4)(PyObject *);
4301   int __pyx_t_5;
4302   PyObject *__pyx_t_6 = NULL;
4303   int __pyx_t_7;
4304   int __pyx_t_8;
4305   PyObject *__pyx_t_9 = NULL;
4306   int __pyx_t_10;
4307   PyObject *__pyx_t_11 = NULL;
4308   int __pyx_t_12;
4309   int __pyx_lineno = 0;
4310   const char *__pyx_filename = NULL;
4311   int __pyx_clineno = 0;
4312   __Pyx_RefNannySetupContext("compress_tokens", 0);
4313
4314   /* "lxml/html/diff.py":109
4315  *     and they share an annotation
4316  *     """
4317  *     result = [tokens[0]]             # <<<<<<<<<<<<<<
4318  *     for tok in tokens[1:]:
4319  *         if (not result[-1].post_tags and
4320  */
4321   __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_tokens, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
4322   __Pyx_GOTREF(__pyx_t_1);
4323   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
4324   __Pyx_GOTREF(__pyx_t_2);
4325   __Pyx_GIVEREF(__pyx_t_1);
4326   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4327   __pyx_t_1 = 0;
4328   __pyx_v_result = ((PyObject*)__pyx_t_2);
4329   __pyx_t_2 = 0;
4330
4331   /* "lxml/html/diff.py":110
4332  *     """
4333  *     result = [tokens[0]]
4334  *     for tok in tokens[1:]:             # <<<<<<<<<<<<<<
4335  *         if (not result[-1].post_tags and
4336  *             not tok.pre_tags and
4337  */
4338   __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_tokens, 1, 0, NULL, NULL, &__pyx_slice__3, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
4339   __Pyx_GOTREF(__pyx_t_2);
4340   if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
4341     __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
4342     __pyx_t_4 = NULL;
4343   } else {
4344     __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
4345     __Pyx_GOTREF(__pyx_t_1);
4346     __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error)
4347   }
4348   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4349   for (;;) {
4350     if (likely(!__pyx_t_4)) {
4351       if (likely(PyList_CheckExact(__pyx_t_1))) {
4352         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
4353         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4354         __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 110, __pyx_L1_error)
4355         #else
4356         __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
4357         __Pyx_GOTREF(__pyx_t_2);
4358         #endif
4359       } else {
4360         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
4361         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4362         __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 110, __pyx_L1_error)
4363         #else
4364         __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
4365         __Pyx_GOTREF(__pyx_t_2);
4366         #endif
4367       }
4368     } else {
4369       __pyx_t_2 = __pyx_t_4(__pyx_t_1);
4370       if (unlikely(!__pyx_t_2)) {
4371         PyObject* exc_type = PyErr_Occurred();
4372         if (exc_type) {
4373           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4374           else __PYX_ERR(0, 110, __pyx_L1_error)
4375         }
4376         break;
4377       }
4378       __Pyx_GOTREF(__pyx_t_2);
4379     }
4380     __Pyx_XDECREF_SET(__pyx_v_tok, __pyx_t_2);
4381     __pyx_t_2 = 0;
4382
4383     /* "lxml/html/diff.py":111
4384  *     result = [tokens[0]]
4385  *     for tok in tokens[1:]:
4386  *         if (not result[-1].post_tags and             # <<<<<<<<<<<<<<
4387  *             not tok.pre_tags and
4388  *             result[-1].annotation == tok.annotation):
4389  */
4390     __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_result, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
4391     __Pyx_GOTREF(__pyx_t_2);
4392     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error)
4393     __Pyx_GOTREF(__pyx_t_6);
4394     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4395     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 111, __pyx_L1_error)
4396     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4397     __pyx_t_8 = ((!__pyx_t_7) != 0);
4398     if (__pyx_t_8) {
4399     } else {
4400       __pyx_t_5 = __pyx_t_8;
4401       goto __pyx_L6_bool_binop_done;
4402     }
4403
4404     /* "lxml/html/diff.py":112
4405  *     for tok in tokens[1:]:
4406  *         if (not result[-1].post_tags and
4407  *             not tok.pre_tags and             # <<<<<<<<<<<<<<
4408  *             result[-1].annotation == tok.annotation):
4409  *             compress_merge_back(result, tok)
4410  */
4411     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error)
4412     __Pyx_GOTREF(__pyx_t_6);
4413     __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 112, __pyx_L1_error)
4414     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4415     __pyx_t_7 = ((!__pyx_t_8) != 0);
4416     if (__pyx_t_7) {
4417     } else {
4418       __pyx_t_5 = __pyx_t_7;
4419       goto __pyx_L6_bool_binop_done;
4420     }
4421
4422     /* "lxml/html/diff.py":113
4423  *         if (not result[-1].post_tags and
4424  *             not tok.pre_tags and
4425  *             result[-1].annotation == tok.annotation):             # <<<<<<<<<<<<<<
4426  *             compress_merge_back(result, tok)
4427  *         else:
4428  */
4429     __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_result, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 113, __pyx_L1_error)
4430     __Pyx_GOTREF(__pyx_t_6);
4431     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_annotation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
4432     __Pyx_GOTREF(__pyx_t_2);
4433     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4434     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_annotation); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 113, __pyx_L1_error)
4435     __Pyx_GOTREF(__pyx_t_6);
4436     __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 113, __pyx_L1_error)
4437     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4438     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4439     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 113, __pyx_L1_error)
4440     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4441     __pyx_t_5 = __pyx_t_7;
4442     __pyx_L6_bool_binop_done:;
4443
4444     /* "lxml/html/diff.py":111
4445  *     result = [tokens[0]]
4446  *     for tok in tokens[1:]:
4447  *         if (not result[-1].post_tags and             # <<<<<<<<<<<<<<
4448  *             not tok.pre_tags and
4449  *             result[-1].annotation == tok.annotation):
4450  */
4451     if (__pyx_t_5) {
4452
4453       /* "lxml/html/diff.py":114
4454  *             not tok.pre_tags and
4455  *             result[-1].annotation == tok.annotation):
4456  *             compress_merge_back(result, tok)             # <<<<<<<<<<<<<<
4457  *         else:
4458  *             result.append(tok)
4459  */
4460       __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_compress_merge_back); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 114, __pyx_L1_error)
4461       __Pyx_GOTREF(__pyx_t_6);
4462       __pyx_t_2 = NULL;
4463       __pyx_t_10 = 0;
4464       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
4465         __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
4466         if (likely(__pyx_t_2)) {
4467           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
4468           __Pyx_INCREF(__pyx_t_2);
4469           __Pyx_INCREF(function);
4470           __Pyx_DECREF_SET(__pyx_t_6, function);
4471           __pyx_t_10 = 1;
4472         }
4473       }
4474       #if CYTHON_FAST_PYCALL
4475       if (PyFunction_Check(__pyx_t_6)) {
4476         PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_result, __pyx_v_tok};
4477         __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L1_error)
4478         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4479         __Pyx_GOTREF(__pyx_t_9);
4480       } else
4481       #endif
4482       #if CYTHON_FAST_PYCCALL
4483       if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
4484         PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_result, __pyx_v_tok};
4485         __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L1_error)
4486         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4487         __Pyx_GOTREF(__pyx_t_9);
4488       } else
4489       #endif
4490       {
4491         __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 114, __pyx_L1_error)
4492         __Pyx_GOTREF(__pyx_t_11);
4493         if (__pyx_t_2) {
4494           __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
4495         }
4496         __Pyx_INCREF(__pyx_v_result);
4497         __Pyx_GIVEREF(__pyx_v_result);
4498         PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_result);
4499         __Pyx_INCREF(__pyx_v_tok);
4500         __Pyx_GIVEREF(__pyx_v_tok);
4501         PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_v_tok);
4502         __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L1_error)
4503         __Pyx_GOTREF(__pyx_t_9);
4504         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
4505       }
4506       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4507       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4508
4509       /* "lxml/html/diff.py":111
4510  *     result = [tokens[0]]
4511  *     for tok in tokens[1:]:
4512  *         if (not result[-1].post_tags and             # <<<<<<<<<<<<<<
4513  *             not tok.pre_tags and
4514  *             result[-1].annotation == tok.annotation):
4515  */
4516       goto __pyx_L5;
4517     }
4518
4519     /* "lxml/html/diff.py":116
4520  *             compress_merge_back(result, tok)
4521  *         else:
4522  *             result.append(tok)             # <<<<<<<<<<<<<<
4523  *     return result
4524  * 
4525  */
4526     /*else*/ {
4527       __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_tok); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 116, __pyx_L1_error)
4528     }
4529     __pyx_L5:;
4530
4531     /* "lxml/html/diff.py":110
4532  *     """
4533  *     result = [tokens[0]]
4534  *     for tok in tokens[1:]:             # <<<<<<<<<<<<<<
4535  *         if (not result[-1].post_tags and
4536  *             not tok.pre_tags and
4537  */
4538   }
4539   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4540
4541   /* "lxml/html/diff.py":117
4542  *         else:
4543  *             result.append(tok)
4544  *     return result             # <<<<<<<<<<<<<<
4545  * 
4546  * def compress_merge_back(tokens, tok):
4547  */
4548   __Pyx_XDECREF(__pyx_r);
4549   __Pyx_INCREF(__pyx_v_result);
4550   __pyx_r = __pyx_v_result;
4551   goto __pyx_L0;
4552
4553   /* "lxml/html/diff.py":104
4554  *         dest_tok.annotation = src_tok.annotation
4555  * 
4556  * def compress_tokens(tokens):             # <<<<<<<<<<<<<<
4557  *     """
4558  *     Combine adjacent tokens when there is no HTML between the tokens,
4559  */
4560
4561   /* function exit code */
4562   __pyx_L1_error:;
4563   __Pyx_XDECREF(__pyx_t_1);
4564   __Pyx_XDECREF(__pyx_t_2);
4565   __Pyx_XDECREF(__pyx_t_6);
4566   __Pyx_XDECREF(__pyx_t_9);
4567   __Pyx_XDECREF(__pyx_t_11);
4568   __Pyx_AddTraceback("lxml.html.diff.compress_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
4569   __pyx_r = NULL;
4570   __pyx_L0:;
4571   __Pyx_XDECREF(__pyx_v_result);
4572   __Pyx_XDECREF(__pyx_v_tok);
4573   __Pyx_XGIVEREF(__pyx_r);
4574   __Pyx_RefNannyFinishContext();
4575   return __pyx_r;
4576 }
4577
4578 /* "lxml/html/diff.py":119
4579  *     return result
4580  * 
4581  * def compress_merge_back(tokens, tok):             # <<<<<<<<<<<<<<
4582  *     """ Merge tok into the last element of tokens (modifying the list of
4583  *     tokens in-place).  """
4584  */
4585
4586 /* Python wrapper */
4587 static PyObject *__pyx_pw_4lxml_4html_4diff_13compress_merge_back(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4588 static char __pyx_doc_4lxml_4html_4diff_12compress_merge_back[] = " Merge tok into the last element of tokens (modifying the list of\n    tokens in-place).  ";
4589 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_13compress_merge_back = {"compress_merge_back", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_13compress_merge_back, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_12compress_merge_back};
4590 static PyObject *__pyx_pw_4lxml_4html_4diff_13compress_merge_back(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4591   PyObject *__pyx_v_tokens = 0;
4592   PyObject *__pyx_v_tok = 0;
4593   int __pyx_lineno = 0;
4594   const char *__pyx_filename = NULL;
4595   int __pyx_clineno = 0;
4596   PyObject *__pyx_r = 0;
4597   __Pyx_RefNannyDeclarations
4598   __Pyx_RefNannySetupContext("compress_merge_back (wrapper)", 0);
4599   {
4600     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tokens,&__pyx_n_s_tok,0};
4601     PyObject* values[2] = {0,0};
4602     if (unlikely(__pyx_kwds)) {
4603       Py_ssize_t kw_args;
4604       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4605       switch (pos_args) {
4606         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4607         CYTHON_FALLTHROUGH;
4608         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4609         CYTHON_FALLTHROUGH;
4610         case  0: break;
4611         default: goto __pyx_L5_argtuple_error;
4612       }
4613       kw_args = PyDict_Size(__pyx_kwds);
4614       switch (pos_args) {
4615         case  0:
4616         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tokens)) != 0)) kw_args--;
4617         else goto __pyx_L5_argtuple_error;
4618         CYTHON_FALLTHROUGH;
4619         case  1:
4620         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tok)) != 0)) kw_args--;
4621         else {
4622           __Pyx_RaiseArgtupleInvalid("compress_merge_back", 1, 2, 2, 1); __PYX_ERR(0, 119, __pyx_L3_error)
4623         }
4624       }
4625       if (unlikely(kw_args > 0)) {
4626         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compress_merge_back") < 0)) __PYX_ERR(0, 119, __pyx_L3_error)
4627       }
4628     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4629       goto __pyx_L5_argtuple_error;
4630     } else {
4631       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4632       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4633     }
4634     __pyx_v_tokens = values[0];
4635     __pyx_v_tok = values[1];
4636   }
4637   goto __pyx_L4_argument_unpacking_done;
4638   __pyx_L5_argtuple_error:;
4639   __Pyx_RaiseArgtupleInvalid("compress_merge_back", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 119, __pyx_L3_error)
4640   __pyx_L3_error:;
4641   __Pyx_AddTraceback("lxml.html.diff.compress_merge_back", __pyx_clineno, __pyx_lineno, __pyx_filename);
4642   __Pyx_RefNannyFinishContext();
4643   return NULL;
4644   __pyx_L4_argument_unpacking_done:;
4645   __pyx_r = __pyx_pf_4lxml_4html_4diff_12compress_merge_back(__pyx_self, __pyx_v_tokens, __pyx_v_tok);
4646
4647   /* function exit code */
4648   __Pyx_RefNannyFinishContext();
4649   return __pyx_r;
4650 }
4651
4652 static PyObject *__pyx_pf_4lxml_4html_4diff_12compress_merge_back(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_tok) {
4653   PyObject *__pyx_v_last = NULL;
4654   PyObject *__pyx_v_text = NULL;
4655   PyObject *__pyx_v_merged = NULL;
4656   PyObject *__pyx_r = NULL;
4657   __Pyx_RefNannyDeclarations
4658   PyObject *__pyx_t_1 = NULL;
4659   int __pyx_t_2;
4660   int __pyx_t_3;
4661   int __pyx_t_4;
4662   int __pyx_t_5;
4663   PyObject *__pyx_t_6 = NULL;
4664   PyObject *__pyx_t_7 = NULL;
4665   PyObject *__pyx_t_8 = NULL;
4666   int __pyx_lineno = 0;
4667   const char *__pyx_filename = NULL;
4668   int __pyx_clineno = 0;
4669   __Pyx_RefNannySetupContext("compress_merge_back", 0);
4670
4671   /* "lxml/html/diff.py":122
4672  *     """ Merge tok into the last element of tokens (modifying the list of
4673  *     tokens in-place).  """
4674  *     last = tokens[-1]             # <<<<<<<<<<<<<<
4675  *     if type(last) is not token or type(tok) is not token:
4676  *         tokens.append(tok)
4677  */
4678   __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_tokens, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error)
4679   __Pyx_GOTREF(__pyx_t_1);
4680   __pyx_v_last = __pyx_t_1;
4681   __pyx_t_1 = 0;
4682
4683   /* "lxml/html/diff.py":123
4684  *     tokens in-place).  """
4685  *     last = tokens[-1]
4686  *     if type(last) is not token or type(tok) is not token:             # <<<<<<<<<<<<<<
4687  *         tokens.append(tok)
4688  *     else:
4689  */
4690   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
4691   __Pyx_GOTREF(__pyx_t_1);
4692   __pyx_t_3 = (((PyObject *)Py_TYPE(__pyx_v_last)) != __pyx_t_1);
4693   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4694   __pyx_t_4 = (__pyx_t_3 != 0);
4695   if (!__pyx_t_4) {
4696   } else {
4697     __pyx_t_2 = __pyx_t_4;
4698     goto __pyx_L4_bool_binop_done;
4699   }
4700   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
4701   __Pyx_GOTREF(__pyx_t_1);
4702   __pyx_t_4 = (((PyObject *)Py_TYPE(__pyx_v_tok)) != __pyx_t_1);
4703   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4704   __pyx_t_3 = (__pyx_t_4 != 0);
4705   __pyx_t_2 = __pyx_t_3;
4706   __pyx_L4_bool_binop_done:;
4707   if (__pyx_t_2) {
4708
4709     /* "lxml/html/diff.py":124
4710  *     last = tokens[-1]
4711  *     if type(last) is not token or type(tok) is not token:
4712  *         tokens.append(tok)             # <<<<<<<<<<<<<<
4713  *     else:
4714  *         text = _unicode(last)
4715  */
4716     __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_tokens, __pyx_v_tok); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 124, __pyx_L1_error)
4717
4718     /* "lxml/html/diff.py":123
4719  *     tokens in-place).  """
4720  *     last = tokens[-1]
4721  *     if type(last) is not token or type(tok) is not token:             # <<<<<<<<<<<<<<
4722  *         tokens.append(tok)
4723  *     else:
4724  */
4725     goto __pyx_L3;
4726   }
4727
4728   /* "lxml/html/diff.py":126
4729  *         tokens.append(tok)
4730  *     else:
4731  *         text = _unicode(last)             # <<<<<<<<<<<<<<
4732  *         if last.trailing_whitespace:
4733  *             text += last.trailing_whitespace
4734  */
4735   /*else*/ {
4736     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error)
4737     __Pyx_GOTREF(__pyx_t_6);
4738     __pyx_t_7 = NULL;
4739     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
4740       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
4741       if (likely(__pyx_t_7)) {
4742         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
4743         __Pyx_INCREF(__pyx_t_7);
4744         __Pyx_INCREF(function);
4745         __Pyx_DECREF_SET(__pyx_t_6, function);
4746       }
4747     }
4748     __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_last) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_last);
4749     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
4750     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
4751     __Pyx_GOTREF(__pyx_t_1);
4752     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4753     __pyx_v_text = __pyx_t_1;
4754     __pyx_t_1 = 0;
4755
4756     /* "lxml/html/diff.py":127
4757  *     else:
4758  *         text = _unicode(last)
4759  *         if last.trailing_whitespace:             # <<<<<<<<<<<<<<
4760  *             text += last.trailing_whitespace
4761  *         text += tok
4762  */
4763     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_last, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
4764     __Pyx_GOTREF(__pyx_t_1);
4765     __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 127, __pyx_L1_error)
4766     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4767     if (__pyx_t_2) {
4768
4769       /* "lxml/html/diff.py":128
4770  *         text = _unicode(last)
4771  *         if last.trailing_whitespace:
4772  *             text += last.trailing_whitespace             # <<<<<<<<<<<<<<
4773  *         text += tok
4774  *         merged = token(text,
4775  */
4776       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_last, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
4777       __Pyx_GOTREF(__pyx_t_1);
4778       __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_text, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error)
4779       __Pyx_GOTREF(__pyx_t_6);
4780       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4781       __Pyx_DECREF_SET(__pyx_v_text, __pyx_t_6);
4782       __pyx_t_6 = 0;
4783
4784       /* "lxml/html/diff.py":127
4785  *     else:
4786  *         text = _unicode(last)
4787  *         if last.trailing_whitespace:             # <<<<<<<<<<<<<<
4788  *             text += last.trailing_whitespace
4789  *         text += tok
4790  */
4791     }
4792
4793     /* "lxml/html/diff.py":129
4794  *         if last.trailing_whitespace:
4795  *             text += last.trailing_whitespace
4796  *         text += tok             # <<<<<<<<<<<<<<
4797  *         merged = token(text,
4798  *                        pre_tags=last.pre_tags,
4799  */
4800     __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_text, __pyx_v_tok); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
4801     __Pyx_GOTREF(__pyx_t_6);
4802     __Pyx_DECREF_SET(__pyx_v_text, __pyx_t_6);
4803     __pyx_t_6 = 0;
4804
4805     /* "lxml/html/diff.py":130
4806  *             text += last.trailing_whitespace
4807  *         text += tok
4808  *         merged = token(text,             # <<<<<<<<<<<<<<
4809  *                        pre_tags=last.pre_tags,
4810  *                        post_tags=tok.post_tags,
4811  */
4812     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_token); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error)
4813     __Pyx_GOTREF(__pyx_t_6);
4814     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
4815     __Pyx_GOTREF(__pyx_t_1);
4816     __Pyx_INCREF(__pyx_v_text);
4817     __Pyx_GIVEREF(__pyx_v_text);
4818     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_text);
4819
4820     /* "lxml/html/diff.py":131
4821  *         text += tok
4822  *         merged = token(text,
4823  *                        pre_tags=last.pre_tags,             # <<<<<<<<<<<<<<
4824  *                        post_tags=tok.post_tags,
4825  *                        trailing_whitespace=tok.trailing_whitespace)
4826  */
4827     __pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
4828     __Pyx_GOTREF(__pyx_t_7);
4829     __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_last, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 131, __pyx_L1_error)
4830     __Pyx_GOTREF(__pyx_t_8);
4831     if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_pre_tags, __pyx_t_8) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
4832     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4833
4834     /* "lxml/html/diff.py":132
4835  *         merged = token(text,
4836  *                        pre_tags=last.pre_tags,
4837  *                        post_tags=tok.post_tags,             # <<<<<<<<<<<<<<
4838  *                        trailing_whitespace=tok.trailing_whitespace)
4839  *         merged.annotation = last.annotation
4840  */
4841     __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error)
4842     __Pyx_GOTREF(__pyx_t_8);
4843     if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_post_tags, __pyx_t_8) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
4844     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4845
4846     /* "lxml/html/diff.py":133
4847  *                        pre_tags=last.pre_tags,
4848  *                        post_tags=tok.post_tags,
4849  *                        trailing_whitespace=tok.trailing_whitespace)             # <<<<<<<<<<<<<<
4850  *         merged.annotation = last.annotation
4851  *         tokens[-1] = merged
4852  */
4853     __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 133, __pyx_L1_error)
4854     __Pyx_GOTREF(__pyx_t_8);
4855     if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_trailing_whitespace, __pyx_t_8) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
4856     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4857
4858     /* "lxml/html/diff.py":130
4859  *             text += last.trailing_whitespace
4860  *         text += tok
4861  *         merged = token(text,             # <<<<<<<<<<<<<<
4862  *                        pre_tags=last.pre_tags,
4863  *                        post_tags=tok.post_tags,
4864  */
4865     __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
4866     __Pyx_GOTREF(__pyx_t_8);
4867     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4868     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4869     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4870     __pyx_v_merged = __pyx_t_8;
4871     __pyx_t_8 = 0;
4872
4873     /* "lxml/html/diff.py":134
4874  *                        post_tags=tok.post_tags,
4875  *                        trailing_whitespace=tok.trailing_whitespace)
4876  *         merged.annotation = last.annotation             # <<<<<<<<<<<<<<
4877  *         tokens[-1] = merged
4878  * 
4879  */
4880     __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_last, __pyx_n_s_annotation); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 134, __pyx_L1_error)
4881     __Pyx_GOTREF(__pyx_t_8);
4882     if (__Pyx_PyObject_SetAttrStr(__pyx_v_merged, __pyx_n_s_annotation, __pyx_t_8) < 0) __PYX_ERR(0, 134, __pyx_L1_error)
4883     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4884
4885     /* "lxml/html/diff.py":135
4886  *                        trailing_whitespace=tok.trailing_whitespace)
4887  *         merged.annotation = last.annotation
4888  *         tokens[-1] = merged             # <<<<<<<<<<<<<<
4889  * 
4890  * def markup_serialize_tokens(tokens, markup_func):
4891  */
4892     if (unlikely(__Pyx_SetItemInt(__pyx_v_tokens, -1L, __pyx_v_merged, long, 1, __Pyx_PyInt_From_long, 0, 1, 1) < 0)) __PYX_ERR(0, 135, __pyx_L1_error)
4893   }
4894   __pyx_L3:;
4895
4896   /* "lxml/html/diff.py":119
4897  *     return result
4898  * 
4899  * def compress_merge_back(tokens, tok):             # <<<<<<<<<<<<<<
4900  *     """ Merge tok into the last element of tokens (modifying the list of
4901  *     tokens in-place).  """
4902  */
4903
4904   /* function exit code */
4905   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4906   goto __pyx_L0;
4907   __pyx_L1_error:;
4908   __Pyx_XDECREF(__pyx_t_1);
4909   __Pyx_XDECREF(__pyx_t_6);
4910   __Pyx_XDECREF(__pyx_t_7);
4911   __Pyx_XDECREF(__pyx_t_8);
4912   __Pyx_AddTraceback("lxml.html.diff.compress_merge_back", __pyx_clineno, __pyx_lineno, __pyx_filename);
4913   __pyx_r = NULL;
4914   __pyx_L0:;
4915   __Pyx_XDECREF(__pyx_v_last);
4916   __Pyx_XDECREF(__pyx_v_text);
4917   __Pyx_XDECREF(__pyx_v_merged);
4918   __Pyx_XGIVEREF(__pyx_r);
4919   __Pyx_RefNannyFinishContext();
4920   return __pyx_r;
4921 }
4922 static PyObject *__pyx_gb_4lxml_4html_4diff_16generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
4923
4924 /* "lxml/html/diff.py":137
4925  *         tokens[-1] = merged
4926  * 
4927  * def markup_serialize_tokens(tokens, markup_func):             # <<<<<<<<<<<<<<
4928  *     """
4929  *     Serialize the list of tokens into a list of text chunks, calling
4930  */
4931
4932 /* Python wrapper */
4933 static PyObject *__pyx_pw_4lxml_4html_4diff_15markup_serialize_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4934 static char __pyx_doc_4lxml_4html_4diff_14markup_serialize_tokens[] = "\n    Serialize the list of tokens into a list of text chunks, calling\n    markup_func around text to add annotations.\n    ";
4935 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_15markup_serialize_tokens = {"markup_serialize_tokens", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_15markup_serialize_tokens, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_14markup_serialize_tokens};
4936 static PyObject *__pyx_pw_4lxml_4html_4diff_15markup_serialize_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4937   PyObject *__pyx_v_tokens = 0;
4938   PyObject *__pyx_v_markup_func = 0;
4939   int __pyx_lineno = 0;
4940   const char *__pyx_filename = NULL;
4941   int __pyx_clineno = 0;
4942   PyObject *__pyx_r = 0;
4943   __Pyx_RefNannyDeclarations
4944   __Pyx_RefNannySetupContext("markup_serialize_tokens (wrapper)", 0);
4945   {
4946     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tokens,&__pyx_n_s_markup_func,0};
4947     PyObject* values[2] = {0,0};
4948     if (unlikely(__pyx_kwds)) {
4949       Py_ssize_t kw_args;
4950       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4951       switch (pos_args) {
4952         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4953         CYTHON_FALLTHROUGH;
4954         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4955         CYTHON_FALLTHROUGH;
4956         case  0: break;
4957         default: goto __pyx_L5_argtuple_error;
4958       }
4959       kw_args = PyDict_Size(__pyx_kwds);
4960       switch (pos_args) {
4961         case  0:
4962         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tokens)) != 0)) kw_args--;
4963         else goto __pyx_L5_argtuple_error;
4964         CYTHON_FALLTHROUGH;
4965         case  1:
4966         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_markup_func)) != 0)) kw_args--;
4967         else {
4968           __Pyx_RaiseArgtupleInvalid("markup_serialize_tokens", 1, 2, 2, 1); __PYX_ERR(0, 137, __pyx_L3_error)
4969         }
4970       }
4971       if (unlikely(kw_args > 0)) {
4972         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "markup_serialize_tokens") < 0)) __PYX_ERR(0, 137, __pyx_L3_error)
4973       }
4974     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4975       goto __pyx_L5_argtuple_error;
4976     } else {
4977       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4978       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4979     }
4980     __pyx_v_tokens = values[0];
4981     __pyx_v_markup_func = values[1];
4982   }
4983   goto __pyx_L4_argument_unpacking_done;
4984   __pyx_L5_argtuple_error:;
4985   __Pyx_RaiseArgtupleInvalid("markup_serialize_tokens", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 137, __pyx_L3_error)
4986   __pyx_L3_error:;
4987   __Pyx_AddTraceback("lxml.html.diff.markup_serialize_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
4988   __Pyx_RefNannyFinishContext();
4989   return NULL;
4990   __pyx_L4_argument_unpacking_done:;
4991   __pyx_r = __pyx_pf_4lxml_4html_4diff_14markup_serialize_tokens(__pyx_self, __pyx_v_tokens, __pyx_v_markup_func);
4992
4993   /* function exit code */
4994   __Pyx_RefNannyFinishContext();
4995   return __pyx_r;
4996 }
4997
4998 static PyObject *__pyx_pf_4lxml_4html_4diff_14markup_serialize_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_markup_func) {
4999   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *__pyx_cur_scope;
5000   PyObject *__pyx_r = NULL;
5001   __Pyx_RefNannyDeclarations
5002   int __pyx_lineno = 0;
5003   const char *__pyx_filename = NULL;
5004   int __pyx_clineno = 0;
5005   __Pyx_RefNannySetupContext("markup_serialize_tokens", 0);
5006   __pyx_cur_scope = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens(__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens, __pyx_empty_tuple, NULL);
5007   if (unlikely(!__pyx_cur_scope)) {
5008     __pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)Py_None);
5009     __Pyx_INCREF(Py_None);
5010     __PYX_ERR(0, 137, __pyx_L1_error)
5011   } else {
5012     __Pyx_GOTREF(__pyx_cur_scope);
5013   }
5014   __pyx_cur_scope->__pyx_v_tokens = __pyx_v_tokens;
5015   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_tokens);
5016   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_tokens);
5017   __pyx_cur_scope->__pyx_v_markup_func = __pyx_v_markup_func;
5018   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_markup_func);
5019   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_markup_func);
5020   {
5021     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4lxml_4html_4diff_16generator, __pyx_codeobj__4, (PyObject *) __pyx_cur_scope, __pyx_n_s_markup_serialize_tokens, __pyx_n_s_markup_serialize_tokens, __pyx_n_s_lxml_html_diff); if (unlikely(!gen)) __PYX_ERR(0, 137, __pyx_L1_error)
5022     __Pyx_DECREF(__pyx_cur_scope);
5023     __Pyx_RefNannyFinishContext();
5024     return (PyObject *) gen;
5025   }
5026
5027   /* function exit code */
5028   __pyx_L1_error:;
5029   __Pyx_AddTraceback("lxml.html.diff.markup_serialize_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
5030   __pyx_r = NULL;
5031   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
5032   __Pyx_XGIVEREF(__pyx_r);
5033   __Pyx_RefNannyFinishContext();
5034   return __pyx_r;
5035 }
5036
5037 static PyObject *__pyx_gb_4lxml_4html_4diff_16generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
5038 {
5039   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *__pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)__pyx_generator->closure);
5040   PyObject *__pyx_r = NULL;
5041   PyObject *__pyx_t_1 = NULL;
5042   Py_ssize_t __pyx_t_2;
5043   PyObject *(*__pyx_t_3)(PyObject *);
5044   PyObject *__pyx_t_4 = NULL;
5045   PyObject *__pyx_t_5 = NULL;
5046   Py_ssize_t __pyx_t_6;
5047   PyObject *(*__pyx_t_7)(PyObject *);
5048   PyObject *__pyx_t_8 = NULL;
5049   PyObject *__pyx_t_9 = NULL;
5050   int __pyx_t_10;
5051   PyObject *__pyx_t_11 = NULL;
5052   int __pyx_t_12;
5053   int __pyx_lineno = 0;
5054   const char *__pyx_filename = NULL;
5055   int __pyx_clineno = 0;
5056   __Pyx_RefNannyDeclarations
5057   __Pyx_RefNannySetupContext("markup_serialize_tokens", 0);
5058   switch (__pyx_generator->resume_label) {
5059     case 0: goto __pyx_L3_first_run;
5060     case 1: goto __pyx_L8_resume_from_yield;
5061     case 2: goto __pyx_L10_resume_from_yield;
5062     case 3: goto __pyx_L13_resume_from_yield;
5063     default: /* CPython raises the right error here */
5064     __Pyx_RefNannyFinishContext();
5065     return NULL;
5066   }
5067   __pyx_L3_first_run:;
5068   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 137, __pyx_L1_error)
5069
5070   /* "lxml/html/diff.py":142
5071  *     markup_func around text to add annotations.
5072  *     """
5073  *     for token in tokens:             # <<<<<<<<<<<<<<
5074  *         for pre in token.pre_tags:
5075  *             yield pre
5076  */
5077   if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_tokens)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_tokens)) {
5078     __pyx_t_1 = __pyx_cur_scope->__pyx_v_tokens; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
5079     __pyx_t_3 = NULL;
5080   } else {
5081     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
5082     __Pyx_GOTREF(__pyx_t_1);
5083     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
5084   }
5085   for (;;) {
5086     if (likely(!__pyx_t_3)) {
5087       if (likely(PyList_CheckExact(__pyx_t_1))) {
5088         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
5089         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5090         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
5091         #else
5092         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
5093         __Pyx_GOTREF(__pyx_t_4);
5094         #endif
5095       } else {
5096         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
5097         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5098         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
5099         #else
5100         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
5101         __Pyx_GOTREF(__pyx_t_4);
5102         #endif
5103       }
5104     } else {
5105       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
5106       if (unlikely(!__pyx_t_4)) {
5107         PyObject* exc_type = PyErr_Occurred();
5108         if (exc_type) {
5109           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
5110           else __PYX_ERR(0, 142, __pyx_L1_error)
5111         }
5112         break;
5113       }
5114       __Pyx_GOTREF(__pyx_t_4);
5115     }
5116     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_token);
5117     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_token, __pyx_t_4);
5118     __Pyx_GIVEREF(__pyx_t_4);
5119     __pyx_t_4 = 0;
5120
5121     /* "lxml/html/diff.py":143
5122  *     """
5123  *     for token in tokens:
5124  *         for pre in token.pre_tags:             # <<<<<<<<<<<<<<
5125  *             yield pre
5126  *         html = token.html()
5127  */
5128     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
5129     __Pyx_GOTREF(__pyx_t_4);
5130     if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
5131       __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
5132       __pyx_t_7 = NULL;
5133     } else {
5134       __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
5135       __Pyx_GOTREF(__pyx_t_5);
5136       __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error)
5137     }
5138     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5139     for (;;) {
5140       if (likely(!__pyx_t_7)) {
5141         if (likely(PyList_CheckExact(__pyx_t_5))) {
5142           if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
5143           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5144           __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
5145           #else
5146           __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
5147           __Pyx_GOTREF(__pyx_t_4);
5148           #endif
5149         } else {
5150           if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
5151           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5152           __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
5153           #else
5154           __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
5155           __Pyx_GOTREF(__pyx_t_4);
5156           #endif
5157         }
5158       } else {
5159         __pyx_t_4 = __pyx_t_7(__pyx_t_5);
5160         if (unlikely(!__pyx_t_4)) {
5161           PyObject* exc_type = PyErr_Occurred();
5162           if (exc_type) {
5163             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
5164             else __PYX_ERR(0, 143, __pyx_L1_error)
5165           }
5166           break;
5167         }
5168         __Pyx_GOTREF(__pyx_t_4);
5169       }
5170       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pre);
5171       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pre, __pyx_t_4);
5172       __Pyx_GIVEREF(__pyx_t_4);
5173       __pyx_t_4 = 0;
5174
5175       /* "lxml/html/diff.py":144
5176  *     for token in tokens:
5177  *         for pre in token.pre_tags:
5178  *             yield pre             # <<<<<<<<<<<<<<
5179  *         html = token.html()
5180  *         html = markup_func(html, token.annotation)
5181  */
5182       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pre);
5183       __pyx_r = __pyx_cur_scope->__pyx_v_pre;
5184       __Pyx_XGIVEREF(__pyx_t_1);
5185       __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
5186       __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
5187       __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
5188       __Pyx_XGIVEREF(__pyx_t_5);
5189       __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
5190       __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
5191       __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
5192       __Pyx_XGIVEREF(__pyx_r);
5193       __Pyx_RefNannyFinishContext();
5194       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
5195       /* return from generator, yielding value */
5196       __pyx_generator->resume_label = 1;
5197       return __pyx_r;
5198       __pyx_L8_resume_from_yield:;
5199       __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
5200       __pyx_cur_scope->__pyx_t_0 = 0;
5201       __Pyx_XGOTREF(__pyx_t_1);
5202       __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
5203       __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
5204       __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
5205       __pyx_cur_scope->__pyx_t_3 = 0;
5206       __Pyx_XGOTREF(__pyx_t_5);
5207       __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
5208       __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
5209       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 144, __pyx_L1_error)
5210
5211       /* "lxml/html/diff.py":143
5212  *     """
5213  *     for token in tokens:
5214  *         for pre in token.pre_tags:             # <<<<<<<<<<<<<<
5215  *             yield pre
5216  *         html = token.html()
5217  */
5218     }
5219     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5220
5221     /* "lxml/html/diff.py":145
5222  *         for pre in token.pre_tags:
5223  *             yield pre
5224  *         html = token.html()             # <<<<<<<<<<<<<<
5225  *         html = markup_func(html, token.annotation)
5226  *         if token.trailing_whitespace:
5227  */
5228     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_html); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
5229     __Pyx_GOTREF(__pyx_t_4);
5230     __pyx_t_8 = NULL;
5231     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5232       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
5233       if (likely(__pyx_t_8)) {
5234         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5235         __Pyx_INCREF(__pyx_t_8);
5236         __Pyx_INCREF(function);
5237         __Pyx_DECREF_SET(__pyx_t_4, function);
5238       }
5239     }
5240     __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
5241     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
5242     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L1_error)
5243     __Pyx_GOTREF(__pyx_t_5);
5244     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5245     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_html);
5246     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_html, __pyx_t_5);
5247     __Pyx_GIVEREF(__pyx_t_5);
5248     __pyx_t_5 = 0;
5249
5250     /* "lxml/html/diff.py":146
5251  *             yield pre
5252  *         html = token.html()
5253  *         html = markup_func(html, token.annotation)             # <<<<<<<<<<<<<<
5254  *         if token.trailing_whitespace:
5255  *             html += token.trailing_whitespace
5256  */
5257     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_annotation); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
5258     __Pyx_GOTREF(__pyx_t_4);
5259     __Pyx_INCREF(__pyx_cur_scope->__pyx_v_markup_func);
5260     __pyx_t_8 = __pyx_cur_scope->__pyx_v_markup_func; __pyx_t_9 = NULL;
5261     __pyx_t_10 = 0;
5262     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
5263       __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
5264       if (likely(__pyx_t_9)) {
5265         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
5266         __Pyx_INCREF(__pyx_t_9);
5267         __Pyx_INCREF(function);
5268         __Pyx_DECREF_SET(__pyx_t_8, function);
5269         __pyx_t_10 = 1;
5270       }
5271     }
5272     #if CYTHON_FAST_PYCALL
5273     if (PyFunction_Check(__pyx_t_8)) {
5274       PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_html, __pyx_t_4};
5275       __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error)
5276       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5277       __Pyx_GOTREF(__pyx_t_5);
5278       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5279     } else
5280     #endif
5281     #if CYTHON_FAST_PYCCALL
5282     if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
5283       PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_html, __pyx_t_4};
5284       __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error)
5285       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5286       __Pyx_GOTREF(__pyx_t_5);
5287       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5288     } else
5289     #endif
5290     {
5291       __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error)
5292       __Pyx_GOTREF(__pyx_t_11);
5293       if (__pyx_t_9) {
5294         __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
5295       }
5296       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_html);
5297       __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_html);
5298       PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_cur_scope->__pyx_v_html);
5299       __Pyx_GIVEREF(__pyx_t_4);
5300       PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_4);
5301       __pyx_t_4 = 0;
5302       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error)
5303       __Pyx_GOTREF(__pyx_t_5);
5304       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5305     }
5306     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5307     __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_html);
5308     __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_html, __pyx_t_5);
5309     __Pyx_GIVEREF(__pyx_t_5);
5310     __pyx_t_5 = 0;
5311
5312     /* "lxml/html/diff.py":147
5313  *         html = token.html()
5314  *         html = markup_func(html, token.annotation)
5315  *         if token.trailing_whitespace:             # <<<<<<<<<<<<<<
5316  *             html += token.trailing_whitespace
5317  *         yield html
5318  */
5319     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
5320     __Pyx_GOTREF(__pyx_t_5);
5321     __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 147, __pyx_L1_error)
5322     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5323     if (__pyx_t_12) {
5324
5325       /* "lxml/html/diff.py":148
5326  *         html = markup_func(html, token.annotation)
5327  *         if token.trailing_whitespace:
5328  *             html += token.trailing_whitespace             # <<<<<<<<<<<<<<
5329  *         yield html
5330  *         for post in token.post_tags:
5331  */
5332       __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 148, __pyx_L1_error)
5333       __Pyx_GOTREF(__pyx_t_5);
5334       __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_cur_scope->__pyx_v_html, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error)
5335       __Pyx_GOTREF(__pyx_t_8);
5336       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5337       __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_html);
5338       __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_html, __pyx_t_8);
5339       __Pyx_GIVEREF(__pyx_t_8);
5340       __pyx_t_8 = 0;
5341
5342       /* "lxml/html/diff.py":147
5343  *         html = token.html()
5344  *         html = markup_func(html, token.annotation)
5345  *         if token.trailing_whitespace:             # <<<<<<<<<<<<<<
5346  *             html += token.trailing_whitespace
5347  *         yield html
5348  */
5349     }
5350
5351     /* "lxml/html/diff.py":149
5352  *         if token.trailing_whitespace:
5353  *             html += token.trailing_whitespace
5354  *         yield html             # <<<<<<<<<<<<<<
5355  *         for post in token.post_tags:
5356  *             yield post
5357  */
5358     __Pyx_INCREF(__pyx_cur_scope->__pyx_v_html);
5359     __pyx_r = __pyx_cur_scope->__pyx_v_html;
5360     __Pyx_XGIVEREF(__pyx_t_1);
5361     __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
5362     __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
5363     __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
5364     __Pyx_XGIVEREF(__pyx_r);
5365     __Pyx_RefNannyFinishContext();
5366     __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
5367     /* return from generator, yielding value */
5368     __pyx_generator->resume_label = 2;
5369     return __pyx_r;
5370     __pyx_L10_resume_from_yield:;
5371     __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
5372     __pyx_cur_scope->__pyx_t_0 = 0;
5373     __Pyx_XGOTREF(__pyx_t_1);
5374     __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
5375     __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
5376     if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 149, __pyx_L1_error)
5377
5378     /* "lxml/html/diff.py":150
5379  *             html += token.trailing_whitespace
5380  *         yield html
5381  *         for post in token.post_tags:             # <<<<<<<<<<<<<<
5382  *             yield post
5383  * 
5384  */
5385     __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 150, __pyx_L1_error)
5386     __Pyx_GOTREF(__pyx_t_8);
5387     if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
5388       __pyx_t_5 = __pyx_t_8; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
5389       __pyx_t_7 = NULL;
5390     } else {
5391       __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error)
5392       __Pyx_GOTREF(__pyx_t_5);
5393       __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 150, __pyx_L1_error)
5394     }
5395     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5396     for (;;) {
5397       if (likely(!__pyx_t_7)) {
5398         if (likely(PyList_CheckExact(__pyx_t_5))) {
5399           if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
5400           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5401           __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
5402           #else
5403           __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 150, __pyx_L1_error)
5404           __Pyx_GOTREF(__pyx_t_8);
5405           #endif
5406         } else {
5407           if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
5408           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5409           __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
5410           #else
5411           __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 150, __pyx_L1_error)
5412           __Pyx_GOTREF(__pyx_t_8);
5413           #endif
5414         }
5415       } else {
5416         __pyx_t_8 = __pyx_t_7(__pyx_t_5);
5417         if (unlikely(!__pyx_t_8)) {
5418           PyObject* exc_type = PyErr_Occurred();
5419           if (exc_type) {
5420             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
5421             else __PYX_ERR(0, 150, __pyx_L1_error)
5422           }
5423           break;
5424         }
5425         __Pyx_GOTREF(__pyx_t_8);
5426       }
5427       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_post);
5428       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_post, __pyx_t_8);
5429       __Pyx_GIVEREF(__pyx_t_8);
5430       __pyx_t_8 = 0;
5431
5432       /* "lxml/html/diff.py":151
5433  *         yield html
5434  *         for post in token.post_tags:
5435  *             yield post             # <<<<<<<<<<<<<<
5436  * 
5437  * 
5438  */
5439       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_post);
5440       __pyx_r = __pyx_cur_scope->__pyx_v_post;
5441       __Pyx_XGIVEREF(__pyx_t_1);
5442       __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
5443       __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
5444       __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
5445       __Pyx_XGIVEREF(__pyx_t_5);
5446       __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
5447       __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
5448       __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
5449       __Pyx_XGIVEREF(__pyx_r);
5450       __Pyx_RefNannyFinishContext();
5451       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
5452       /* return from generator, yielding value */
5453       __pyx_generator->resume_label = 3;
5454       return __pyx_r;
5455       __pyx_L13_resume_from_yield:;
5456       __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
5457       __pyx_cur_scope->__pyx_t_0 = 0;
5458       __Pyx_XGOTREF(__pyx_t_1);
5459       __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
5460       __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
5461       __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
5462       __pyx_cur_scope->__pyx_t_3 = 0;
5463       __Pyx_XGOTREF(__pyx_t_5);
5464       __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
5465       __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
5466       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 151, __pyx_L1_error)
5467
5468       /* "lxml/html/diff.py":150
5469  *             html += token.trailing_whitespace
5470  *         yield html
5471  *         for post in token.post_tags:             # <<<<<<<<<<<<<<
5472  *             yield post
5473  * 
5474  */
5475     }
5476     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5477
5478     /* "lxml/html/diff.py":142
5479  *     markup_func around text to add annotations.
5480  *     """
5481  *     for token in tokens:             # <<<<<<<<<<<<<<
5482  *         for pre in token.pre_tags:
5483  *             yield pre
5484  */
5485   }
5486   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5487   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
5488
5489   /* "lxml/html/diff.py":137
5490  *         tokens[-1] = merged
5491  * 
5492  * def markup_serialize_tokens(tokens, markup_func):             # <<<<<<<<<<<<<<
5493  *     """
5494  *     Serialize the list of tokens into a list of text chunks, calling
5495  */
5496
5497   /* function exit code */
5498   PyErr_SetNone(PyExc_StopIteration);
5499   goto __pyx_L0;
5500   __pyx_L1_error:;
5501   __Pyx_XDECREF(__pyx_t_1);
5502   __Pyx_XDECREF(__pyx_t_4);
5503   __Pyx_XDECREF(__pyx_t_5);
5504   __Pyx_XDECREF(__pyx_t_8);
5505   __Pyx_XDECREF(__pyx_t_9);
5506   __Pyx_XDECREF(__pyx_t_11);
5507   __Pyx_AddTraceback("markup_serialize_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
5508   __pyx_L0:;
5509   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
5510   #if !CYTHON_USE_EXC_INFO_STACK
5511   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
5512   #endif
5513   __pyx_generator->resume_label = -1;
5514   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
5515   __Pyx_RefNannyFinishContext();
5516   return __pyx_r;
5517 }
5518
5519 /* "lxml/html/diff.py":158
5520  * ############################################################
5521  * 
5522  * def htmldiff(old_html, new_html):             # <<<<<<<<<<<<<<
5523  *     ## FIXME: this should take parsed documents too, and use their body
5524  *     ## or other content.
5525  */
5526
5527 /* Python wrapper */
5528 static PyObject *__pyx_pw_4lxml_4html_4diff_18htmldiff(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5529 static char __pyx_doc_4lxml_4html_4diff_17htmldiff[] = " Do a diff of the old and new document.  The documents are HTML\n    *fragments* (str/UTF8 or unicode), they are not complete documents\n    (i.e., no <html> tag).\n\n    Returns HTML with <ins> and <del> tags added around the\n    appropriate text.  \n\n    Markup is generally ignored, with the markup from new_html\n    preserved, and possibly some markup from old_html (though it is\n    considered acceptable to lose some of the old markup).  Only the\n    words in the HTML are diffed.  The exception is <img> tags, which\n    are treated like words, and the href attribute of <a> tags, which\n    are noted inside the tag itself when there are changes.\n    ";
5530 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_18htmldiff = {"htmldiff", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_18htmldiff, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_17htmldiff};
5531 static PyObject *__pyx_pw_4lxml_4html_4diff_18htmldiff(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5532   PyObject *__pyx_v_old_html = 0;
5533   PyObject *__pyx_v_new_html = 0;
5534   int __pyx_lineno = 0;
5535   const char *__pyx_filename = NULL;
5536   int __pyx_clineno = 0;
5537   PyObject *__pyx_r = 0;
5538   __Pyx_RefNannyDeclarations
5539   __Pyx_RefNannySetupContext("htmldiff (wrapper)", 0);
5540   {
5541     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_old_html,&__pyx_n_s_new_html,0};
5542     PyObject* values[2] = {0,0};
5543     if (unlikely(__pyx_kwds)) {
5544       Py_ssize_t kw_args;
5545       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5546       switch (pos_args) {
5547         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5548         CYTHON_FALLTHROUGH;
5549         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5550         CYTHON_FALLTHROUGH;
5551         case  0: break;
5552         default: goto __pyx_L5_argtuple_error;
5553       }
5554       kw_args = PyDict_Size(__pyx_kwds);
5555       switch (pos_args) {
5556         case  0:
5557         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_old_html)) != 0)) kw_args--;
5558         else goto __pyx_L5_argtuple_error;
5559         CYTHON_FALLTHROUGH;
5560         case  1:
5561         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_html)) != 0)) kw_args--;
5562         else {
5563           __Pyx_RaiseArgtupleInvalid("htmldiff", 1, 2, 2, 1); __PYX_ERR(0, 158, __pyx_L3_error)
5564         }
5565       }
5566       if (unlikely(kw_args > 0)) {
5567         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "htmldiff") < 0)) __PYX_ERR(0, 158, __pyx_L3_error)
5568       }
5569     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5570       goto __pyx_L5_argtuple_error;
5571     } else {
5572       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5573       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5574     }
5575     __pyx_v_old_html = values[0];
5576     __pyx_v_new_html = values[1];
5577   }
5578   goto __pyx_L4_argument_unpacking_done;
5579   __pyx_L5_argtuple_error:;
5580   __Pyx_RaiseArgtupleInvalid("htmldiff", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 158, __pyx_L3_error)
5581   __pyx_L3_error:;
5582   __Pyx_AddTraceback("lxml.html.diff.htmldiff", __pyx_clineno, __pyx_lineno, __pyx_filename);
5583   __Pyx_RefNannyFinishContext();
5584   return NULL;
5585   __pyx_L4_argument_unpacking_done:;
5586   __pyx_r = __pyx_pf_4lxml_4html_4diff_17htmldiff(__pyx_self, __pyx_v_old_html, __pyx_v_new_html);
5587
5588   /* function exit code */
5589   __Pyx_RefNannyFinishContext();
5590   return __pyx_r;
5591 }
5592
5593 static PyObject *__pyx_pf_4lxml_4html_4diff_17htmldiff(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_old_html, PyObject *__pyx_v_new_html) {
5594   PyObject *__pyx_v_old_html_tokens = NULL;
5595   PyObject *__pyx_v_new_html_tokens = NULL;
5596   PyObject *__pyx_v_result = NULL;
5597   PyObject *__pyx_r = NULL;
5598   __Pyx_RefNannyDeclarations
5599   PyObject *__pyx_t_1 = NULL;
5600   PyObject *__pyx_t_2 = NULL;
5601   PyObject *__pyx_t_3 = NULL;
5602   int __pyx_t_4;
5603   PyObject *__pyx_t_5 = NULL;
5604   int __pyx_lineno = 0;
5605   const char *__pyx_filename = NULL;
5606   int __pyx_clineno = 0;
5607   __Pyx_RefNannySetupContext("htmldiff", 0);
5608
5609   /* "lxml/html/diff.py":175
5610  *     are noted inside the tag itself when there are changes.
5611  *     """
5612  *     old_html_tokens = tokenize(old_html)             # <<<<<<<<<<<<<<
5613  *     new_html_tokens = tokenize(new_html)
5614  *     result = htmldiff_tokens(old_html_tokens, new_html_tokens)
5615  */
5616   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_tokenize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error)
5617   __Pyx_GOTREF(__pyx_t_2);
5618   __pyx_t_3 = NULL;
5619   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5620     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5621     if (likely(__pyx_t_3)) {
5622       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5623       __Pyx_INCREF(__pyx_t_3);
5624       __Pyx_INCREF(function);
5625       __Pyx_DECREF_SET(__pyx_t_2, function);
5626     }
5627   }
5628   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_old_html) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_old_html);
5629   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5630   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
5631   __Pyx_GOTREF(__pyx_t_1);
5632   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5633   __pyx_v_old_html_tokens = __pyx_t_1;
5634   __pyx_t_1 = 0;
5635
5636   /* "lxml/html/diff.py":176
5637  *     """
5638  *     old_html_tokens = tokenize(old_html)
5639  *     new_html_tokens = tokenize(new_html)             # <<<<<<<<<<<<<<
5640  *     result = htmldiff_tokens(old_html_tokens, new_html_tokens)
5641  *     result = ''.join(result).strip()
5642  */
5643   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_tokenize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
5644   __Pyx_GOTREF(__pyx_t_2);
5645   __pyx_t_3 = NULL;
5646   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5647     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5648     if (likely(__pyx_t_3)) {
5649       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5650       __Pyx_INCREF(__pyx_t_3);
5651       __Pyx_INCREF(function);
5652       __Pyx_DECREF_SET(__pyx_t_2, function);
5653     }
5654   }
5655   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_new_html) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_new_html);
5656   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5657   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
5658   __Pyx_GOTREF(__pyx_t_1);
5659   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5660   __pyx_v_new_html_tokens = __pyx_t_1;
5661   __pyx_t_1 = 0;
5662
5663   /* "lxml/html/diff.py":177
5664  *     old_html_tokens = tokenize(old_html)
5665  *     new_html_tokens = tokenize(new_html)
5666  *     result = htmldiff_tokens(old_html_tokens, new_html_tokens)             # <<<<<<<<<<<<<<
5667  *     result = ''.join(result).strip()
5668  *     return fixup_ins_del_tags(result)
5669  */
5670   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_htmldiff_tokens); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
5671   __Pyx_GOTREF(__pyx_t_2);
5672   __pyx_t_3 = NULL;
5673   __pyx_t_4 = 0;
5674   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5675     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5676     if (likely(__pyx_t_3)) {
5677       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5678       __Pyx_INCREF(__pyx_t_3);
5679       __Pyx_INCREF(function);
5680       __Pyx_DECREF_SET(__pyx_t_2, function);
5681       __pyx_t_4 = 1;
5682     }
5683   }
5684   #if CYTHON_FAST_PYCALL
5685   if (PyFunction_Check(__pyx_t_2)) {
5686     PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_old_html_tokens, __pyx_v_new_html_tokens};
5687     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
5688     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5689     __Pyx_GOTREF(__pyx_t_1);
5690   } else
5691   #endif
5692   #if CYTHON_FAST_PYCCALL
5693   if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
5694     PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_old_html_tokens, __pyx_v_new_html_tokens};
5695     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
5696     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5697     __Pyx_GOTREF(__pyx_t_1);
5698   } else
5699   #endif
5700   {
5701     __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
5702     __Pyx_GOTREF(__pyx_t_5);
5703     if (__pyx_t_3) {
5704       __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
5705     }
5706     __Pyx_INCREF(__pyx_v_old_html_tokens);
5707     __Pyx_GIVEREF(__pyx_v_old_html_tokens);
5708     PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_old_html_tokens);
5709     __Pyx_INCREF(__pyx_v_new_html_tokens);
5710     __Pyx_GIVEREF(__pyx_v_new_html_tokens);
5711     PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_new_html_tokens);
5712     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
5713     __Pyx_GOTREF(__pyx_t_1);
5714     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5715   }
5716   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5717   __pyx_v_result = __pyx_t_1;
5718   __pyx_t_1 = 0;
5719
5720   /* "lxml/html/diff.py":178
5721  *     new_html_tokens = tokenize(new_html)
5722  *     result = htmldiff_tokens(old_html_tokens, new_html_tokens)
5723  *     result = ''.join(result).strip()             # <<<<<<<<<<<<<<
5724  *     return fixup_ins_del_tags(result)
5725  * 
5726  */
5727   __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__2, __pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
5728   __Pyx_GOTREF(__pyx_t_2);
5729   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
5730   __Pyx_GOTREF(__pyx_t_5);
5731   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5732   __pyx_t_2 = NULL;
5733   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
5734     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
5735     if (likely(__pyx_t_2)) {
5736       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5737       __Pyx_INCREF(__pyx_t_2);
5738       __Pyx_INCREF(function);
5739       __Pyx_DECREF_SET(__pyx_t_5, function);
5740     }
5741   }
5742   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
5743   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5744   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
5745   __Pyx_GOTREF(__pyx_t_1);
5746   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5747   __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1);
5748   __pyx_t_1 = 0;
5749
5750   /* "lxml/html/diff.py":179
5751  *     result = htmldiff_tokens(old_html_tokens, new_html_tokens)
5752  *     result = ''.join(result).strip()
5753  *     return fixup_ins_del_tags(result)             # <<<<<<<<<<<<<<
5754  * 
5755  * def htmldiff_tokens(html1_tokens, html2_tokens):
5756  */
5757   __Pyx_XDECREF(__pyx_r);
5758   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_fixup_ins_del_tags); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error)
5759   __Pyx_GOTREF(__pyx_t_5);
5760   __pyx_t_2 = NULL;
5761   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
5762     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
5763     if (likely(__pyx_t_2)) {
5764       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5765       __Pyx_INCREF(__pyx_t_2);
5766       __Pyx_INCREF(function);
5767       __Pyx_DECREF_SET(__pyx_t_5, function);
5768     }
5769   }
5770   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_2, __pyx_v_result) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_result);
5771   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5772   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
5773   __Pyx_GOTREF(__pyx_t_1);
5774   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5775   __pyx_r = __pyx_t_1;
5776   __pyx_t_1 = 0;
5777   goto __pyx_L0;
5778
5779   /* "lxml/html/diff.py":158
5780  * ############################################################
5781  * 
5782  * def htmldiff(old_html, new_html):             # <<<<<<<<<<<<<<
5783  *     ## FIXME: this should take parsed documents too, and use their body
5784  *     ## or other content.
5785  */
5786
5787   /* function exit code */
5788   __pyx_L1_error:;
5789   __Pyx_XDECREF(__pyx_t_1);
5790   __Pyx_XDECREF(__pyx_t_2);
5791   __Pyx_XDECREF(__pyx_t_3);
5792   __Pyx_XDECREF(__pyx_t_5);
5793   __Pyx_AddTraceback("lxml.html.diff.htmldiff", __pyx_clineno, __pyx_lineno, __pyx_filename);
5794   __pyx_r = NULL;
5795   __pyx_L0:;
5796   __Pyx_XDECREF(__pyx_v_old_html_tokens);
5797   __Pyx_XDECREF(__pyx_v_new_html_tokens);
5798   __Pyx_XDECREF(__pyx_v_result);
5799   __Pyx_XGIVEREF(__pyx_r);
5800   __Pyx_RefNannyFinishContext();
5801   return __pyx_r;
5802 }
5803
5804 /* "lxml/html/diff.py":181
5805  *     return fixup_ins_del_tags(result)
5806  * 
5807  * def htmldiff_tokens(html1_tokens, html2_tokens):             # <<<<<<<<<<<<<<
5808  *     """ Does a diff on the tokens themselves, returning a list of text
5809  *     chunks (not tokens).
5810  */
5811
5812 /* Python wrapper */
5813 static PyObject *__pyx_pw_4lxml_4html_4diff_20htmldiff_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5814 static char __pyx_doc_4lxml_4html_4diff_19htmldiff_tokens[] = " Does a diff on the tokens themselves, returning a list of text\n    chunks (not tokens).\n    ";
5815 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_20htmldiff_tokens = {"htmldiff_tokens", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_20htmldiff_tokens, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_19htmldiff_tokens};
5816 static PyObject *__pyx_pw_4lxml_4html_4diff_20htmldiff_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5817   PyObject *__pyx_v_html1_tokens = 0;
5818   PyObject *__pyx_v_html2_tokens = 0;
5819   int __pyx_lineno = 0;
5820   const char *__pyx_filename = NULL;
5821   int __pyx_clineno = 0;
5822   PyObject *__pyx_r = 0;
5823   __Pyx_RefNannyDeclarations
5824   __Pyx_RefNannySetupContext("htmldiff_tokens (wrapper)", 0);
5825   {
5826     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_html1_tokens,&__pyx_n_s_html2_tokens,0};
5827     PyObject* values[2] = {0,0};
5828     if (unlikely(__pyx_kwds)) {
5829       Py_ssize_t kw_args;
5830       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5831       switch (pos_args) {
5832         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5833         CYTHON_FALLTHROUGH;
5834         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5835         CYTHON_FALLTHROUGH;
5836         case  0: break;
5837         default: goto __pyx_L5_argtuple_error;
5838       }
5839       kw_args = PyDict_Size(__pyx_kwds);
5840       switch (pos_args) {
5841         case  0:
5842         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_html1_tokens)) != 0)) kw_args--;
5843         else goto __pyx_L5_argtuple_error;
5844         CYTHON_FALLTHROUGH;
5845         case  1:
5846         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_html2_tokens)) != 0)) kw_args--;
5847         else {
5848           __Pyx_RaiseArgtupleInvalid("htmldiff_tokens", 1, 2, 2, 1); __PYX_ERR(0, 181, __pyx_L3_error)
5849         }
5850       }
5851       if (unlikely(kw_args > 0)) {
5852         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "htmldiff_tokens") < 0)) __PYX_ERR(0, 181, __pyx_L3_error)
5853       }
5854     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5855       goto __pyx_L5_argtuple_error;
5856     } else {
5857       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5858       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5859     }
5860     __pyx_v_html1_tokens = values[0];
5861     __pyx_v_html2_tokens = values[1];
5862   }
5863   goto __pyx_L4_argument_unpacking_done;
5864   __pyx_L5_argtuple_error:;
5865   __Pyx_RaiseArgtupleInvalid("htmldiff_tokens", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error)
5866   __pyx_L3_error:;
5867   __Pyx_AddTraceback("lxml.html.diff.htmldiff_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
5868   __Pyx_RefNannyFinishContext();
5869   return NULL;
5870   __pyx_L4_argument_unpacking_done:;
5871   __pyx_r = __pyx_pf_4lxml_4html_4diff_19htmldiff_tokens(__pyx_self, __pyx_v_html1_tokens, __pyx_v_html2_tokens);
5872
5873   /* function exit code */
5874   __Pyx_RefNannyFinishContext();
5875   return __pyx_r;
5876 }
5877
5878 static PyObject *__pyx_pf_4lxml_4html_4diff_19htmldiff_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html1_tokens, PyObject *__pyx_v_html2_tokens) {
5879   PyObject *__pyx_v_s = NULL;
5880   PyObject *__pyx_v_commands = NULL;
5881   PyObject *__pyx_v_result = NULL;
5882   PyObject *__pyx_v_command = NULL;
5883   PyObject *__pyx_v_i1 = NULL;
5884   PyObject *__pyx_v_i2 = NULL;
5885   PyObject *__pyx_v_j1 = NULL;
5886   PyObject *__pyx_v_j2 = NULL;
5887   PyObject *__pyx_v_ins_tokens = NULL;
5888   PyObject *__pyx_v_del_tokens = NULL;
5889   PyObject *__pyx_r = NULL;
5890   __Pyx_RefNannyDeclarations
5891   PyObject *__pyx_t_1 = NULL;
5892   PyObject *__pyx_t_2 = NULL;
5893   PyObject *__pyx_t_3 = NULL;
5894   Py_ssize_t __pyx_t_4;
5895   PyObject *(*__pyx_t_5)(PyObject *);
5896   PyObject *__pyx_t_6 = NULL;
5897   PyObject *__pyx_t_7 = NULL;
5898   PyObject *__pyx_t_8 = NULL;
5899   PyObject *__pyx_t_9 = NULL;
5900   PyObject *__pyx_t_10 = NULL;
5901   PyObject *(*__pyx_t_11)(PyObject *);
5902   int __pyx_t_12;
5903   int __pyx_t_13;
5904   int __pyx_t_14;
5905   int __pyx_lineno = 0;
5906   const char *__pyx_filename = NULL;
5907   int __pyx_clineno = 0;
5908   __Pyx_RefNannySetupContext("htmldiff_tokens", 0);
5909
5910   /* "lxml/html/diff.py":198
5911  *     # fuzzy where in the new document the old text would have gone.
5912  *     # Again we just do a best effort attempt.
5913  *     s = InsensitiveSequenceMatcher(a=html1_tokens, b=html2_tokens)             # <<<<<<<<<<<<<<
5914  *     commands = s.get_opcodes()
5915  *     result = []
5916  */
5917   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_InsensitiveSequenceMatcher); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
5918   __Pyx_GOTREF(__pyx_t_1);
5919   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
5920   __Pyx_GOTREF(__pyx_t_2);
5921   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_a, __pyx_v_html1_tokens) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
5922   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_b, __pyx_v_html2_tokens) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
5923   __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
5924   __Pyx_GOTREF(__pyx_t_3);
5925   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5926   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5927   __pyx_v_s = __pyx_t_3;
5928   __pyx_t_3 = 0;
5929
5930   /* "lxml/html/diff.py":199
5931  *     # Again we just do a best effort attempt.
5932  *     s = InsensitiveSequenceMatcher(a=html1_tokens, b=html2_tokens)
5933  *     commands = s.get_opcodes()             # <<<<<<<<<<<<<<
5934  *     result = []
5935  *     for command, i1, i2, j1, j2 in commands:
5936  */
5937   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_get_opcodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
5938   __Pyx_GOTREF(__pyx_t_2);
5939   __pyx_t_1 = NULL;
5940   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
5941     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
5942     if (likely(__pyx_t_1)) {
5943       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5944       __Pyx_INCREF(__pyx_t_1);
5945       __Pyx_INCREF(function);
5946       __Pyx_DECREF_SET(__pyx_t_2, function);
5947     }
5948   }
5949   __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
5950   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5951   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
5952   __Pyx_GOTREF(__pyx_t_3);
5953   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5954   __pyx_v_commands = __pyx_t_3;
5955   __pyx_t_3 = 0;
5956
5957   /* "lxml/html/diff.py":200
5958  *     s = InsensitiveSequenceMatcher(a=html1_tokens, b=html2_tokens)
5959  *     commands = s.get_opcodes()
5960  *     result = []             # <<<<<<<<<<<<<<
5961  *     for command, i1, i2, j1, j2 in commands:
5962  *         if command == 'equal':
5963  */
5964   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
5965   __Pyx_GOTREF(__pyx_t_3);
5966   __pyx_v_result = __pyx_t_3;
5967   __pyx_t_3 = 0;
5968
5969   /* "lxml/html/diff.py":201
5970  *     commands = s.get_opcodes()
5971  *     result = []
5972  *     for command, i1, i2, j1, j2 in commands:             # <<<<<<<<<<<<<<
5973  *         if command == 'equal':
5974  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
5975  */
5976   if (likely(PyList_CheckExact(__pyx_v_commands)) || PyTuple_CheckExact(__pyx_v_commands)) {
5977     __pyx_t_3 = __pyx_v_commands; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
5978     __pyx_t_5 = NULL;
5979   } else {
5980     __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_commands); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 201, __pyx_L1_error)
5981     __Pyx_GOTREF(__pyx_t_3);
5982     __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 201, __pyx_L1_error)
5983   }
5984   for (;;) {
5985     if (likely(!__pyx_t_5)) {
5986       if (likely(PyList_CheckExact(__pyx_t_3))) {
5987         if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
5988         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5989         __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
5990         #else
5991         __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
5992         __Pyx_GOTREF(__pyx_t_2);
5993         #endif
5994       } else {
5995         if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
5996         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5997         __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
5998         #else
5999         __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
6000         __Pyx_GOTREF(__pyx_t_2);
6001         #endif
6002       }
6003     } else {
6004       __pyx_t_2 = __pyx_t_5(__pyx_t_3);
6005       if (unlikely(!__pyx_t_2)) {
6006         PyObject* exc_type = PyErr_Occurred();
6007         if (exc_type) {
6008           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6009           else __PYX_ERR(0, 201, __pyx_L1_error)
6010         }
6011         break;
6012       }
6013       __Pyx_GOTREF(__pyx_t_2);
6014     }
6015     if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
6016       PyObject* sequence = __pyx_t_2;
6017       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
6018       if (unlikely(size != 5)) {
6019         if (size > 5) __Pyx_RaiseTooManyValuesError(5);
6020         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
6021         __PYX_ERR(0, 201, __pyx_L1_error)
6022       }
6023       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6024       if (likely(PyTuple_CheckExact(sequence))) {
6025         __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
6026         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
6027         __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
6028         __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
6029         __pyx_t_9 = PyTuple_GET_ITEM(sequence, 4); 
6030       } else {
6031         __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
6032         __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
6033         __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
6034         __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
6035         __pyx_t_9 = PyList_GET_ITEM(sequence, 4); 
6036       }
6037       __Pyx_INCREF(__pyx_t_1);
6038       __Pyx_INCREF(__pyx_t_6);
6039       __Pyx_INCREF(__pyx_t_7);
6040       __Pyx_INCREF(__pyx_t_8);
6041       __Pyx_INCREF(__pyx_t_9);
6042       #else
6043       {
6044         Py_ssize_t i;
6045         PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9};
6046         for (i=0; i < 5; i++) {
6047           PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 201, __pyx_L1_error)
6048           __Pyx_GOTREF(item);
6049           *(temps[i]) = item;
6050         }
6051       }
6052       #endif
6053       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6054     } else {
6055       Py_ssize_t index = -1;
6056       PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9};
6057       __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 201, __pyx_L1_error)
6058       __Pyx_GOTREF(__pyx_t_10);
6059       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6060       __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
6061       for (index=0; index < 5; index++) {
6062         PyObject* item = __pyx_t_11(__pyx_t_10); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
6063         __Pyx_GOTREF(item);
6064         *(temps[index]) = item;
6065       }
6066       if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 5) < 0) __PYX_ERR(0, 201, __pyx_L1_error)
6067       __pyx_t_11 = NULL;
6068       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6069       goto __pyx_L6_unpacking_done;
6070       __pyx_L5_unpacking_failed:;
6071       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6072       __pyx_t_11 = NULL;
6073       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
6074       __PYX_ERR(0, 201, __pyx_L1_error)
6075       __pyx_L6_unpacking_done:;
6076     }
6077     __Pyx_XDECREF_SET(__pyx_v_command, __pyx_t_1);
6078     __pyx_t_1 = 0;
6079     __Pyx_XDECREF_SET(__pyx_v_i1, __pyx_t_6);
6080     __pyx_t_6 = 0;
6081     __Pyx_XDECREF_SET(__pyx_v_i2, __pyx_t_7);
6082     __pyx_t_7 = 0;
6083     __Pyx_XDECREF_SET(__pyx_v_j1, __pyx_t_8);
6084     __pyx_t_8 = 0;
6085     __Pyx_XDECREF_SET(__pyx_v_j2, __pyx_t_9);
6086     __pyx_t_9 = 0;
6087
6088     /* "lxml/html/diff.py":202
6089  *     result = []
6090  *     for command, i1, i2, j1, j2 in commands:
6091  *         if command == 'equal':             # <<<<<<<<<<<<<<
6092  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6093  *             continue
6094  */
6095     __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_equal, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 202, __pyx_L1_error)
6096     if (__pyx_t_12) {
6097
6098       /* "lxml/html/diff.py":203
6099  *     for command, i1, i2, j1, j2 in commands:
6100  *         if command == 'equal':
6101  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))             # <<<<<<<<<<<<<<
6102  *             continue
6103  *         if command == 'insert' or command == 'replace':
6104  */
6105       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_extend); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
6106       __Pyx_GOTREF(__pyx_t_9);
6107       __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_expand_tokens); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 203, __pyx_L1_error)
6108       __Pyx_GOTREF(__pyx_t_8);
6109       __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_html2_tokens, 0, 0, &__pyx_v_j1, &__pyx_v_j2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 203, __pyx_L1_error)
6110       __Pyx_GOTREF(__pyx_t_7);
6111       __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error)
6112       __Pyx_GOTREF(__pyx_t_6);
6113       __Pyx_GIVEREF(__pyx_t_7);
6114       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
6115       __pyx_t_7 = 0;
6116       __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 203, __pyx_L1_error)
6117       __Pyx_GOTREF(__pyx_t_7);
6118       if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_equal, Py_True) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
6119       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
6120       __Pyx_GOTREF(__pyx_t_1);
6121       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6122       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6123       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6124       __pyx_t_7 = NULL;
6125       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
6126         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
6127         if (likely(__pyx_t_7)) {
6128           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6129           __Pyx_INCREF(__pyx_t_7);
6130           __Pyx_INCREF(function);
6131           __Pyx_DECREF_SET(__pyx_t_9, function);
6132         }
6133       }
6134       __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1);
6135       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6136       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6137       if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
6138       __Pyx_GOTREF(__pyx_t_2);
6139       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
6140       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6141
6142       /* "lxml/html/diff.py":204
6143  *         if command == 'equal':
6144  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6145  *             continue             # <<<<<<<<<<<<<<
6146  *         if command == 'insert' or command == 'replace':
6147  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6148  */
6149       goto __pyx_L3_continue;
6150
6151       /* "lxml/html/diff.py":202
6152  *     result = []
6153  *     for command, i1, i2, j1, j2 in commands:
6154  *         if command == 'equal':             # <<<<<<<<<<<<<<
6155  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6156  *             continue
6157  */
6158     }
6159
6160     /* "lxml/html/diff.py":205
6161  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6162  *             continue
6163  *         if command == 'insert' or command == 'replace':             # <<<<<<<<<<<<<<
6164  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6165  *             merge_insert(ins_tokens, result)
6166  */
6167     __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_insert, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 205, __pyx_L1_error)
6168     if (!__pyx_t_13) {
6169     } else {
6170       __pyx_t_12 = __pyx_t_13;
6171       goto __pyx_L9_bool_binop_done;
6172     }
6173     __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_replace, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 205, __pyx_L1_error)
6174     __pyx_t_12 = __pyx_t_13;
6175     __pyx_L9_bool_binop_done:;
6176     if (__pyx_t_12) {
6177
6178       /* "lxml/html/diff.py":206
6179  *             continue
6180  *         if command == 'insert' or command == 'replace':
6181  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])             # <<<<<<<<<<<<<<
6182  *             merge_insert(ins_tokens, result)
6183  *         if command == 'delete' or command == 'replace':
6184  */
6185       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_expand_tokens); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 206, __pyx_L1_error)
6186       __Pyx_GOTREF(__pyx_t_9);
6187       __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_html2_tokens, 0, 0, &__pyx_v_j1, &__pyx_v_j2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
6188       __Pyx_GOTREF(__pyx_t_1);
6189       __pyx_t_7 = NULL;
6190       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
6191         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
6192         if (likely(__pyx_t_7)) {
6193           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6194           __Pyx_INCREF(__pyx_t_7);
6195           __Pyx_INCREF(function);
6196           __Pyx_DECREF_SET(__pyx_t_9, function);
6197         }
6198       }
6199       __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1);
6200       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6201       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6202       if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
6203       __Pyx_GOTREF(__pyx_t_2);
6204       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
6205       __Pyx_XDECREF_SET(__pyx_v_ins_tokens, __pyx_t_2);
6206       __pyx_t_2 = 0;
6207
6208       /* "lxml/html/diff.py":207
6209  *         if command == 'insert' or command == 'replace':
6210  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6211  *             merge_insert(ins_tokens, result)             # <<<<<<<<<<<<<<
6212  *         if command == 'delete' or command == 'replace':
6213  *             del_tokens = expand_tokens(html1_tokens[i1:i2])
6214  */
6215       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_merge_insert); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L1_error)
6216       __Pyx_GOTREF(__pyx_t_9);
6217       __pyx_t_1 = NULL;
6218       __pyx_t_14 = 0;
6219       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
6220         __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
6221         if (likely(__pyx_t_1)) {
6222           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6223           __Pyx_INCREF(__pyx_t_1);
6224           __Pyx_INCREF(function);
6225           __Pyx_DECREF_SET(__pyx_t_9, function);
6226           __pyx_t_14 = 1;
6227         }
6228       }
6229       #if CYTHON_FAST_PYCALL
6230       if (PyFunction_Check(__pyx_t_9)) {
6231         PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_ins_tokens, __pyx_v_result};
6232         __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
6233         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6234         __Pyx_GOTREF(__pyx_t_2);
6235       } else
6236       #endif
6237       #if CYTHON_FAST_PYCCALL
6238       if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
6239         PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_ins_tokens, __pyx_v_result};
6240         __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
6241         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6242         __Pyx_GOTREF(__pyx_t_2);
6243       } else
6244       #endif
6245       {
6246         __pyx_t_7 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 207, __pyx_L1_error)
6247         __Pyx_GOTREF(__pyx_t_7);
6248         if (__pyx_t_1) {
6249           __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
6250         }
6251         __Pyx_INCREF(__pyx_v_ins_tokens);
6252         __Pyx_GIVEREF(__pyx_v_ins_tokens);
6253         PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_14, __pyx_v_ins_tokens);
6254         __Pyx_INCREF(__pyx_v_result);
6255         __Pyx_GIVEREF(__pyx_v_result);
6256         PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_14, __pyx_v_result);
6257         __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
6258         __Pyx_GOTREF(__pyx_t_2);
6259         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6260       }
6261       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
6262       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6263
6264       /* "lxml/html/diff.py":205
6265  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6266  *             continue
6267  *         if command == 'insert' or command == 'replace':             # <<<<<<<<<<<<<<
6268  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6269  *             merge_insert(ins_tokens, result)
6270  */
6271     }
6272
6273     /* "lxml/html/diff.py":208
6274  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6275  *             merge_insert(ins_tokens, result)
6276  *         if command == 'delete' or command == 'replace':             # <<<<<<<<<<<<<<
6277  *             del_tokens = expand_tokens(html1_tokens[i1:i2])
6278  *             merge_delete(del_tokens, result)
6279  */
6280     __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_delete, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
6281     if (!__pyx_t_13) {
6282     } else {
6283       __pyx_t_12 = __pyx_t_13;
6284       goto __pyx_L12_bool_binop_done;
6285     }
6286     __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_command, __pyx_n_u_replace, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
6287     __pyx_t_12 = __pyx_t_13;
6288     __pyx_L12_bool_binop_done:;
6289     if (__pyx_t_12) {
6290
6291       /* "lxml/html/diff.py":209
6292  *             merge_insert(ins_tokens, result)
6293  *         if command == 'delete' or command == 'replace':
6294  *             del_tokens = expand_tokens(html1_tokens[i1:i2])             # <<<<<<<<<<<<<<
6295  *             merge_delete(del_tokens, result)
6296  *     # If deletes were inserted directly as <del> then we'd have an
6297  */
6298       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_expand_tokens); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
6299       __Pyx_GOTREF(__pyx_t_9);
6300       __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_html1_tokens, 0, 0, &__pyx_v_i1, &__pyx_v_i2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 209, __pyx_L1_error)
6301       __Pyx_GOTREF(__pyx_t_7);
6302       __pyx_t_1 = NULL;
6303       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
6304         __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
6305         if (likely(__pyx_t_1)) {
6306           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6307           __Pyx_INCREF(__pyx_t_1);
6308           __Pyx_INCREF(function);
6309           __Pyx_DECREF_SET(__pyx_t_9, function);
6310         }
6311       }
6312       __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_1, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7);
6313       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6314       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6315       if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
6316       __Pyx_GOTREF(__pyx_t_2);
6317       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
6318       __Pyx_XDECREF_SET(__pyx_v_del_tokens, __pyx_t_2);
6319       __pyx_t_2 = 0;
6320
6321       /* "lxml/html/diff.py":210
6322  *         if command == 'delete' or command == 'replace':
6323  *             del_tokens = expand_tokens(html1_tokens[i1:i2])
6324  *             merge_delete(del_tokens, result)             # <<<<<<<<<<<<<<
6325  *     # If deletes were inserted directly as <del> then we'd have an
6326  *     # invalid document at this point.  Instead we put in special
6327  */
6328       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_merge_delete); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 210, __pyx_L1_error)
6329       __Pyx_GOTREF(__pyx_t_9);
6330       __pyx_t_7 = NULL;
6331       __pyx_t_14 = 0;
6332       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
6333         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
6334         if (likely(__pyx_t_7)) {
6335           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6336           __Pyx_INCREF(__pyx_t_7);
6337           __Pyx_INCREF(function);
6338           __Pyx_DECREF_SET(__pyx_t_9, function);
6339           __pyx_t_14 = 1;
6340         }
6341       }
6342       #if CYTHON_FAST_PYCALL
6343       if (PyFunction_Check(__pyx_t_9)) {
6344         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_del_tokens, __pyx_v_result};
6345         __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
6346         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6347         __Pyx_GOTREF(__pyx_t_2);
6348       } else
6349       #endif
6350       #if CYTHON_FAST_PYCCALL
6351       if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
6352         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_del_tokens, __pyx_v_result};
6353         __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
6354         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6355         __Pyx_GOTREF(__pyx_t_2);
6356       } else
6357       #endif
6358       {
6359         __pyx_t_1 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
6360         __Pyx_GOTREF(__pyx_t_1);
6361         if (__pyx_t_7) {
6362           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL;
6363         }
6364         __Pyx_INCREF(__pyx_v_del_tokens);
6365         __Pyx_GIVEREF(__pyx_v_del_tokens);
6366         PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_14, __pyx_v_del_tokens);
6367         __Pyx_INCREF(__pyx_v_result);
6368         __Pyx_GIVEREF(__pyx_v_result);
6369         PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_14, __pyx_v_result);
6370         __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
6371         __Pyx_GOTREF(__pyx_t_2);
6372         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6373       }
6374       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
6375       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6376
6377       /* "lxml/html/diff.py":208
6378  *             ins_tokens = expand_tokens(html2_tokens[j1:j2])
6379  *             merge_insert(ins_tokens, result)
6380  *         if command == 'delete' or command == 'replace':             # <<<<<<<<<<<<<<
6381  *             del_tokens = expand_tokens(html1_tokens[i1:i2])
6382  *             merge_delete(del_tokens, result)
6383  */
6384     }
6385
6386     /* "lxml/html/diff.py":201
6387  *     commands = s.get_opcodes()
6388  *     result = []
6389  *     for command, i1, i2, j1, j2 in commands:             # <<<<<<<<<<<<<<
6390  *         if command == 'equal':
6391  *             result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
6392  */
6393     __pyx_L3_continue:;
6394   }
6395   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6396
6397   /* "lxml/html/diff.py":215
6398  *     # markers, and when the complete diffed document has been created
6399  *     # we try to move the deletes around and resolve any problems.
6400  *     result = cleanup_delete(result)             # <<<<<<<<<<<<<<
6401  * 
6402  *     return result
6403  */
6404   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_cleanup_delete); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error)
6405   __Pyx_GOTREF(__pyx_t_2);
6406   __pyx_t_9 = NULL;
6407   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6408     __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
6409     if (likely(__pyx_t_9)) {
6410       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6411       __Pyx_INCREF(__pyx_t_9);
6412       __Pyx_INCREF(function);
6413       __Pyx_DECREF_SET(__pyx_t_2, function);
6414     }
6415   }
6416   __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_v_result) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_result);
6417   __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6418   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
6419   __Pyx_GOTREF(__pyx_t_3);
6420   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6421   __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3);
6422   __pyx_t_3 = 0;
6423
6424   /* "lxml/html/diff.py":217
6425  *     result = cleanup_delete(result)
6426  * 
6427  *     return result             # <<<<<<<<<<<<<<
6428  * 
6429  * def expand_tokens(tokens, equal=False):
6430  */
6431   __Pyx_XDECREF(__pyx_r);
6432   __Pyx_INCREF(__pyx_v_result);
6433   __pyx_r = __pyx_v_result;
6434   goto __pyx_L0;
6435
6436   /* "lxml/html/diff.py":181
6437  *     return fixup_ins_del_tags(result)
6438  * 
6439  * def htmldiff_tokens(html1_tokens, html2_tokens):             # <<<<<<<<<<<<<<
6440  *     """ Does a diff on the tokens themselves, returning a list of text
6441  *     chunks (not tokens).
6442  */
6443
6444   /* function exit code */
6445   __pyx_L1_error:;
6446   __Pyx_XDECREF(__pyx_t_1);
6447   __Pyx_XDECREF(__pyx_t_2);
6448   __Pyx_XDECREF(__pyx_t_3);
6449   __Pyx_XDECREF(__pyx_t_6);
6450   __Pyx_XDECREF(__pyx_t_7);
6451   __Pyx_XDECREF(__pyx_t_8);
6452   __Pyx_XDECREF(__pyx_t_9);
6453   __Pyx_XDECREF(__pyx_t_10);
6454   __Pyx_AddTraceback("lxml.html.diff.htmldiff_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
6455   __pyx_r = NULL;
6456   __pyx_L0:;
6457   __Pyx_XDECREF(__pyx_v_s);
6458   __Pyx_XDECREF(__pyx_v_commands);
6459   __Pyx_XDECREF(__pyx_v_result);
6460   __Pyx_XDECREF(__pyx_v_command);
6461   __Pyx_XDECREF(__pyx_v_i1);
6462   __Pyx_XDECREF(__pyx_v_i2);
6463   __Pyx_XDECREF(__pyx_v_j1);
6464   __Pyx_XDECREF(__pyx_v_j2);
6465   __Pyx_XDECREF(__pyx_v_ins_tokens);
6466   __Pyx_XDECREF(__pyx_v_del_tokens);
6467   __Pyx_XGIVEREF(__pyx_r);
6468   __Pyx_RefNannyFinishContext();
6469   return __pyx_r;
6470 }
6471 static PyObject *__pyx_gb_4lxml_4html_4diff_23generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
6472
6473 /* "lxml/html/diff.py":219
6474  *     return result
6475  * 
6476  * def expand_tokens(tokens, equal=False):             # <<<<<<<<<<<<<<
6477  *     """Given a list of tokens, return a generator of the chunks of
6478  *     text for the data in the tokens.
6479  */
6480
6481 /* Python wrapper */
6482 static PyObject *__pyx_pw_4lxml_4html_4diff_22expand_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6483 static char __pyx_doc_4lxml_4html_4diff_21expand_tokens[] = "Given a list of tokens, return a generator of the chunks of\n    text for the data in the tokens.\n    ";
6484 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_22expand_tokens = {"expand_tokens", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_22expand_tokens, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_21expand_tokens};
6485 static PyObject *__pyx_pw_4lxml_4html_4diff_22expand_tokens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6486   PyObject *__pyx_v_tokens = 0;
6487   PyObject *__pyx_v_equal = 0;
6488   int __pyx_lineno = 0;
6489   const char *__pyx_filename = NULL;
6490   int __pyx_clineno = 0;
6491   PyObject *__pyx_r = 0;
6492   __Pyx_RefNannyDeclarations
6493   __Pyx_RefNannySetupContext("expand_tokens (wrapper)", 0);
6494   {
6495     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tokens,&__pyx_n_s_equal,0};
6496     PyObject* values[2] = {0,0};
6497     values[1] = ((PyObject *)((PyObject *)Py_False));
6498     if (unlikely(__pyx_kwds)) {
6499       Py_ssize_t kw_args;
6500       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6501       switch (pos_args) {
6502         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6503         CYTHON_FALLTHROUGH;
6504         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6505         CYTHON_FALLTHROUGH;
6506         case  0: break;
6507         default: goto __pyx_L5_argtuple_error;
6508       }
6509       kw_args = PyDict_Size(__pyx_kwds);
6510       switch (pos_args) {
6511         case  0:
6512         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tokens)) != 0)) kw_args--;
6513         else goto __pyx_L5_argtuple_error;
6514         CYTHON_FALLTHROUGH;
6515         case  1:
6516         if (kw_args > 0) {
6517           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_equal);
6518           if (value) { values[1] = value; kw_args--; }
6519         }
6520       }
6521       if (unlikely(kw_args > 0)) {
6522         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expand_tokens") < 0)) __PYX_ERR(0, 219, __pyx_L3_error)
6523       }
6524     } else {
6525       switch (PyTuple_GET_SIZE(__pyx_args)) {
6526         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6527         CYTHON_FALLTHROUGH;
6528         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6529         break;
6530         default: goto __pyx_L5_argtuple_error;
6531       }
6532     }
6533     __pyx_v_tokens = values[0];
6534     __pyx_v_equal = values[1];
6535   }
6536   goto __pyx_L4_argument_unpacking_done;
6537   __pyx_L5_argtuple_error:;
6538   __Pyx_RaiseArgtupleInvalid("expand_tokens", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 219, __pyx_L3_error)
6539   __pyx_L3_error:;
6540   __Pyx_AddTraceback("lxml.html.diff.expand_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
6541   __Pyx_RefNannyFinishContext();
6542   return NULL;
6543   __pyx_L4_argument_unpacking_done:;
6544   __pyx_r = __pyx_pf_4lxml_4html_4diff_21expand_tokens(__pyx_self, __pyx_v_tokens, __pyx_v_equal);
6545
6546   /* function exit code */
6547   __Pyx_RefNannyFinishContext();
6548   return __pyx_r;
6549 }
6550
6551 static PyObject *__pyx_pf_4lxml_4html_4diff_21expand_tokens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tokens, PyObject *__pyx_v_equal) {
6552   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *__pyx_cur_scope;
6553   PyObject *__pyx_r = NULL;
6554   __Pyx_RefNannyDeclarations
6555   int __pyx_lineno = 0;
6556   const char *__pyx_filename = NULL;
6557   int __pyx_clineno = 0;
6558   __Pyx_RefNannySetupContext("expand_tokens", 0);
6559   __pyx_cur_scope = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens(__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens, __pyx_empty_tuple, NULL);
6560   if (unlikely(!__pyx_cur_scope)) {
6561     __pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)Py_None);
6562     __Pyx_INCREF(Py_None);
6563     __PYX_ERR(0, 219, __pyx_L1_error)
6564   } else {
6565     __Pyx_GOTREF(__pyx_cur_scope);
6566   }
6567   __pyx_cur_scope->__pyx_v_tokens = __pyx_v_tokens;
6568   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_tokens);
6569   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_tokens);
6570   __pyx_cur_scope->__pyx_v_equal = __pyx_v_equal;
6571   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_equal);
6572   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_equal);
6573   {
6574     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4lxml_4html_4diff_23generator1, __pyx_codeobj__5, (PyObject *) __pyx_cur_scope, __pyx_n_s_expand_tokens, __pyx_n_s_expand_tokens, __pyx_n_s_lxml_html_diff); if (unlikely(!gen)) __PYX_ERR(0, 219, __pyx_L1_error)
6575     __Pyx_DECREF(__pyx_cur_scope);
6576     __Pyx_RefNannyFinishContext();
6577     return (PyObject *) gen;
6578   }
6579
6580   /* function exit code */
6581   __pyx_L1_error:;
6582   __Pyx_AddTraceback("lxml.html.diff.expand_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
6583   __pyx_r = NULL;
6584   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
6585   __Pyx_XGIVEREF(__pyx_r);
6586   __Pyx_RefNannyFinishContext();
6587   return __pyx_r;
6588 }
6589
6590 static PyObject *__pyx_gb_4lxml_4html_4diff_23generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
6591 {
6592   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *__pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)__pyx_generator->closure);
6593   PyObject *__pyx_r = NULL;
6594   PyObject *__pyx_t_1 = NULL;
6595   Py_ssize_t __pyx_t_2;
6596   PyObject *(*__pyx_t_3)(PyObject *);
6597   PyObject *__pyx_t_4 = NULL;
6598   PyObject *__pyx_t_5 = NULL;
6599   Py_ssize_t __pyx_t_6;
6600   PyObject *(*__pyx_t_7)(PyObject *);
6601   int __pyx_t_8;
6602   int __pyx_t_9;
6603   int __pyx_t_10;
6604   PyObject *__pyx_t_11 = NULL;
6605   int __pyx_lineno = 0;
6606   const char *__pyx_filename = NULL;
6607   int __pyx_clineno = 0;
6608   __Pyx_RefNannyDeclarations
6609   __Pyx_RefNannySetupContext("expand_tokens", 0);
6610   switch (__pyx_generator->resume_label) {
6611     case 0: goto __pyx_L3_first_run;
6612     case 1: goto __pyx_L8_resume_from_yield;
6613     case 2: goto __pyx_L13_resume_from_yield;
6614     case 3: goto __pyx_L14_resume_from_yield;
6615     case 4: goto __pyx_L17_resume_from_yield;
6616     default: /* CPython raises the right error here */
6617     __Pyx_RefNannyFinishContext();
6618     return NULL;
6619   }
6620   __pyx_L3_first_run:;
6621   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 219, __pyx_L1_error)
6622
6623   /* "lxml/html/diff.py":223
6624  *     text for the data in the tokens.
6625  *     """
6626  *     for token in tokens:             # <<<<<<<<<<<<<<
6627  *         for pre in token.pre_tags:
6628  *             yield pre
6629  */
6630   if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_tokens)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_tokens)) {
6631     __pyx_t_1 = __pyx_cur_scope->__pyx_v_tokens; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
6632     __pyx_t_3 = NULL;
6633   } else {
6634     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error)
6635     __Pyx_GOTREF(__pyx_t_1);
6636     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L1_error)
6637   }
6638   for (;;) {
6639     if (likely(!__pyx_t_3)) {
6640       if (likely(PyList_CheckExact(__pyx_t_1))) {
6641         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
6642         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6643         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
6644         #else
6645         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error)
6646         __Pyx_GOTREF(__pyx_t_4);
6647         #endif
6648       } else {
6649         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
6650         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6651         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
6652         #else
6653         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error)
6654         __Pyx_GOTREF(__pyx_t_4);
6655         #endif
6656       }
6657     } else {
6658       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
6659       if (unlikely(!__pyx_t_4)) {
6660         PyObject* exc_type = PyErr_Occurred();
6661         if (exc_type) {
6662           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6663           else __PYX_ERR(0, 223, __pyx_L1_error)
6664         }
6665         break;
6666       }
6667       __Pyx_GOTREF(__pyx_t_4);
6668     }
6669     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_token);
6670     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_token, __pyx_t_4);
6671     __Pyx_GIVEREF(__pyx_t_4);
6672     __pyx_t_4 = 0;
6673
6674     /* "lxml/html/diff.py":224
6675  *     """
6676  *     for token in tokens:
6677  *         for pre in token.pre_tags:             # <<<<<<<<<<<<<<
6678  *             yield pre
6679  *         if not equal or not token.hide_when_equal:
6680  */
6681     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
6682     __Pyx_GOTREF(__pyx_t_4);
6683     if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
6684       __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
6685       __pyx_t_7 = NULL;
6686     } else {
6687       __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
6688       __Pyx_GOTREF(__pyx_t_5);
6689       __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 224, __pyx_L1_error)
6690     }
6691     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6692     for (;;) {
6693       if (likely(!__pyx_t_7)) {
6694         if (likely(PyList_CheckExact(__pyx_t_5))) {
6695           if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
6696           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6697           __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
6698           #else
6699           __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
6700           __Pyx_GOTREF(__pyx_t_4);
6701           #endif
6702         } else {
6703           if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
6704           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6705           __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
6706           #else
6707           __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
6708           __Pyx_GOTREF(__pyx_t_4);
6709           #endif
6710         }
6711       } else {
6712         __pyx_t_4 = __pyx_t_7(__pyx_t_5);
6713         if (unlikely(!__pyx_t_4)) {
6714           PyObject* exc_type = PyErr_Occurred();
6715           if (exc_type) {
6716             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6717             else __PYX_ERR(0, 224, __pyx_L1_error)
6718           }
6719           break;
6720         }
6721         __Pyx_GOTREF(__pyx_t_4);
6722       }
6723       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pre);
6724       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pre, __pyx_t_4);
6725       __Pyx_GIVEREF(__pyx_t_4);
6726       __pyx_t_4 = 0;
6727
6728       /* "lxml/html/diff.py":225
6729  *     for token in tokens:
6730  *         for pre in token.pre_tags:
6731  *             yield pre             # <<<<<<<<<<<<<<
6732  *         if not equal or not token.hide_when_equal:
6733  *             if token.trailing_whitespace:
6734  */
6735       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pre);
6736       __pyx_r = __pyx_cur_scope->__pyx_v_pre;
6737       __Pyx_XGIVEREF(__pyx_t_1);
6738       __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
6739       __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
6740       __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
6741       __Pyx_XGIVEREF(__pyx_t_5);
6742       __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
6743       __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
6744       __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
6745       __Pyx_XGIVEREF(__pyx_r);
6746       __Pyx_RefNannyFinishContext();
6747       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
6748       /* return from generator, yielding value */
6749       __pyx_generator->resume_label = 1;
6750       return __pyx_r;
6751       __pyx_L8_resume_from_yield:;
6752       __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
6753       __pyx_cur_scope->__pyx_t_0 = 0;
6754       __Pyx_XGOTREF(__pyx_t_1);
6755       __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
6756       __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
6757       __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
6758       __pyx_cur_scope->__pyx_t_3 = 0;
6759       __Pyx_XGOTREF(__pyx_t_5);
6760       __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
6761       __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
6762       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 225, __pyx_L1_error)
6763
6764       /* "lxml/html/diff.py":224
6765  *     """
6766  *     for token in tokens:
6767  *         for pre in token.pre_tags:             # <<<<<<<<<<<<<<
6768  *             yield pre
6769  *         if not equal or not token.hide_when_equal:
6770  */
6771     }
6772     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6773
6774     /* "lxml/html/diff.py":226
6775  *         for pre in token.pre_tags:
6776  *             yield pre
6777  *         if not equal or not token.hide_when_equal:             # <<<<<<<<<<<<<<
6778  *             if token.trailing_whitespace:
6779  *                 yield token.html() + token.trailing_whitespace
6780  */
6781     __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_equal); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 226, __pyx_L1_error)
6782     __pyx_t_10 = ((!__pyx_t_9) != 0);
6783     if (!__pyx_t_10) {
6784     } else {
6785       __pyx_t_8 = __pyx_t_10;
6786       goto __pyx_L10_bool_binop_done;
6787     }
6788     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_hide_when_equal); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
6789     __Pyx_GOTREF(__pyx_t_5);
6790     __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 226, __pyx_L1_error)
6791     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6792     __pyx_t_9 = ((!__pyx_t_10) != 0);
6793     __pyx_t_8 = __pyx_t_9;
6794     __pyx_L10_bool_binop_done:;
6795     if (__pyx_t_8) {
6796
6797       /* "lxml/html/diff.py":227
6798  *             yield pre
6799  *         if not equal or not token.hide_when_equal:
6800  *             if token.trailing_whitespace:             # <<<<<<<<<<<<<<
6801  *                 yield token.html() + token.trailing_whitespace
6802  *             else:
6803  */
6804       __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error)
6805       __Pyx_GOTREF(__pyx_t_5);
6806       __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 227, __pyx_L1_error)
6807       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6808       if (__pyx_t_8) {
6809
6810         /* "lxml/html/diff.py":228
6811  *         if not equal or not token.hide_when_equal:
6812  *             if token.trailing_whitespace:
6813  *                 yield token.html() + token.trailing_whitespace             # <<<<<<<<<<<<<<
6814  *             else:
6815  *                 yield token.html()
6816  */
6817         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_html); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
6818         __Pyx_GOTREF(__pyx_t_4);
6819         __pyx_t_11 = NULL;
6820         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6821           __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
6822           if (likely(__pyx_t_11)) {
6823             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6824             __Pyx_INCREF(__pyx_t_11);
6825             __Pyx_INCREF(function);
6826             __Pyx_DECREF_SET(__pyx_t_4, function);
6827           }
6828         }
6829         __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6830         __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
6831         if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 228, __pyx_L1_error)
6832         __Pyx_GOTREF(__pyx_t_5);
6833         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6834         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
6835         __Pyx_GOTREF(__pyx_t_4);
6836         __pyx_t_11 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 228, __pyx_L1_error)
6837         __Pyx_GOTREF(__pyx_t_11);
6838         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6839         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6840         __pyx_r = __pyx_t_11;
6841         __pyx_t_11 = 0;
6842         __Pyx_XGIVEREF(__pyx_t_1);
6843         __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
6844         __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
6845         __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
6846         __Pyx_XGIVEREF(__pyx_r);
6847         __Pyx_RefNannyFinishContext();
6848         __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
6849         /* return from generator, yielding value */
6850         __pyx_generator->resume_label = 2;
6851         return __pyx_r;
6852         __pyx_L13_resume_from_yield:;
6853         __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
6854         __pyx_cur_scope->__pyx_t_0 = 0;
6855         __Pyx_XGOTREF(__pyx_t_1);
6856         __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
6857         __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
6858         if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 228, __pyx_L1_error)
6859
6860         /* "lxml/html/diff.py":227
6861  *             yield pre
6862  *         if not equal or not token.hide_when_equal:
6863  *             if token.trailing_whitespace:             # <<<<<<<<<<<<<<
6864  *                 yield token.html() + token.trailing_whitespace
6865  *             else:
6866  */
6867         goto __pyx_L12;
6868       }
6869
6870       /* "lxml/html/diff.py":230
6871  *                 yield token.html() + token.trailing_whitespace
6872  *             else:
6873  *                 yield token.html()             # <<<<<<<<<<<<<<
6874  *         for post in token.post_tags:
6875  *             yield post
6876  */
6877       /*else*/ {
6878         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_html); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
6879         __Pyx_GOTREF(__pyx_t_4);
6880         __pyx_t_5 = NULL;
6881         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6882           __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
6883           if (likely(__pyx_t_5)) {
6884             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6885             __Pyx_INCREF(__pyx_t_5);
6886             __Pyx_INCREF(function);
6887             __Pyx_DECREF_SET(__pyx_t_4, function);
6888           }
6889         }
6890         __pyx_t_11 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6891         __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6892         if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error)
6893         __Pyx_GOTREF(__pyx_t_11);
6894         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6895         __pyx_r = __pyx_t_11;
6896         __pyx_t_11 = 0;
6897         __Pyx_XGIVEREF(__pyx_t_1);
6898         __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
6899         __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
6900         __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
6901         __Pyx_XGIVEREF(__pyx_r);
6902         __Pyx_RefNannyFinishContext();
6903         __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
6904         /* return from generator, yielding value */
6905         __pyx_generator->resume_label = 3;
6906         return __pyx_r;
6907         __pyx_L14_resume_from_yield:;
6908         __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
6909         __pyx_cur_scope->__pyx_t_0 = 0;
6910         __Pyx_XGOTREF(__pyx_t_1);
6911         __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
6912         __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
6913         if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 230, __pyx_L1_error)
6914       }
6915       __pyx_L12:;
6916
6917       /* "lxml/html/diff.py":226
6918  *         for pre in token.pre_tags:
6919  *             yield pre
6920  *         if not equal or not token.hide_when_equal:             # <<<<<<<<<<<<<<
6921  *             if token.trailing_whitespace:
6922  *                 yield token.html() + token.trailing_whitespace
6923  */
6924     }
6925
6926     /* "lxml/html/diff.py":231
6927  *             else:
6928  *                 yield token.html()
6929  *         for post in token.post_tags:             # <<<<<<<<<<<<<<
6930  *             yield post
6931  * 
6932  */
6933     __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_token, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
6934     __Pyx_GOTREF(__pyx_t_11);
6935     if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
6936       __pyx_t_4 = __pyx_t_11; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
6937       __pyx_t_7 = NULL;
6938     } else {
6939       __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error)
6940       __Pyx_GOTREF(__pyx_t_4);
6941       __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 231, __pyx_L1_error)
6942     }
6943     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
6944     for (;;) {
6945       if (likely(!__pyx_t_7)) {
6946         if (likely(PyList_CheckExact(__pyx_t_4))) {
6947           if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
6948           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6949           __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_11); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 231, __pyx_L1_error)
6950           #else
6951           __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
6952           __Pyx_GOTREF(__pyx_t_11);
6953           #endif
6954         } else {
6955           if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
6956           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6957           __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_11); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 231, __pyx_L1_error)
6958           #else
6959           __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
6960           __Pyx_GOTREF(__pyx_t_11);
6961           #endif
6962         }
6963       } else {
6964         __pyx_t_11 = __pyx_t_7(__pyx_t_4);
6965         if (unlikely(!__pyx_t_11)) {
6966           PyObject* exc_type = PyErr_Occurred();
6967           if (exc_type) {
6968             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6969             else __PYX_ERR(0, 231, __pyx_L1_error)
6970           }
6971           break;
6972         }
6973         __Pyx_GOTREF(__pyx_t_11);
6974       }
6975       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_post);
6976       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_post, __pyx_t_11);
6977       __Pyx_GIVEREF(__pyx_t_11);
6978       __pyx_t_11 = 0;
6979
6980       /* "lxml/html/diff.py":232
6981  *                 yield token.html()
6982  *         for post in token.post_tags:
6983  *             yield post             # <<<<<<<<<<<<<<
6984  * 
6985  * def merge_insert(ins_chunks, doc):
6986  */
6987       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_post);
6988       __pyx_r = __pyx_cur_scope->__pyx_v_post;
6989       __Pyx_XGIVEREF(__pyx_t_1);
6990       __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
6991       __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
6992       __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
6993       __Pyx_XGIVEREF(__pyx_t_4);
6994       __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
6995       __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
6996       __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
6997       __Pyx_XGIVEREF(__pyx_r);
6998       __Pyx_RefNannyFinishContext();
6999       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
7000       /* return from generator, yielding value */
7001       __pyx_generator->resume_label = 4;
7002       return __pyx_r;
7003       __pyx_L17_resume_from_yield:;
7004       __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
7005       __pyx_cur_scope->__pyx_t_0 = 0;
7006       __Pyx_XGOTREF(__pyx_t_1);
7007       __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
7008       __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
7009       __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
7010       __pyx_cur_scope->__pyx_t_3 = 0;
7011       __Pyx_XGOTREF(__pyx_t_4);
7012       __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
7013       __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
7014       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 232, __pyx_L1_error)
7015
7016       /* "lxml/html/diff.py":231
7017  *             else:
7018  *                 yield token.html()
7019  *         for post in token.post_tags:             # <<<<<<<<<<<<<<
7020  *             yield post
7021  * 
7022  */
7023     }
7024     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7025
7026     /* "lxml/html/diff.py":223
7027  *     text for the data in the tokens.
7028  *     """
7029  *     for token in tokens:             # <<<<<<<<<<<<<<
7030  *         for pre in token.pre_tags:
7031  *             yield pre
7032  */
7033   }
7034   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7035   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
7036
7037   /* "lxml/html/diff.py":219
7038  *     return result
7039  * 
7040  * def expand_tokens(tokens, equal=False):             # <<<<<<<<<<<<<<
7041  *     """Given a list of tokens, return a generator of the chunks of
7042  *     text for the data in the tokens.
7043  */
7044
7045   /* function exit code */
7046   PyErr_SetNone(PyExc_StopIteration);
7047   goto __pyx_L0;
7048   __pyx_L1_error:;
7049   __Pyx_XDECREF(__pyx_t_1);
7050   __Pyx_XDECREF(__pyx_t_4);
7051   __Pyx_XDECREF(__pyx_t_5);
7052   __Pyx_XDECREF(__pyx_t_11);
7053   __Pyx_AddTraceback("expand_tokens", __pyx_clineno, __pyx_lineno, __pyx_filename);
7054   __pyx_L0:;
7055   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
7056   #if !CYTHON_USE_EXC_INFO_STACK
7057   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
7058   #endif
7059   __pyx_generator->resume_label = -1;
7060   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
7061   __Pyx_RefNannyFinishContext();
7062   return __pyx_r;
7063 }
7064
7065 /* "lxml/html/diff.py":234
7066  *             yield post
7067  * 
7068  * def merge_insert(ins_chunks, doc):             # <<<<<<<<<<<<<<
7069  *     """ doc is the already-handled document (as a list of text chunks);
7070  *     here we add <ins>ins_chunks</ins> to the end of that.  """
7071  */
7072
7073 /* Python wrapper */
7074 static PyObject *__pyx_pw_4lxml_4html_4diff_25merge_insert(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7075 static char __pyx_doc_4lxml_4html_4diff_24merge_insert[] = " doc is the already-handled document (as a list of text chunks);\n    here we add <ins>ins_chunks</ins> to the end of that.  ";
7076 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_25merge_insert = {"merge_insert", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_25merge_insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_24merge_insert};
7077 static PyObject *__pyx_pw_4lxml_4html_4diff_25merge_insert(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7078   PyObject *__pyx_v_ins_chunks = 0;
7079   PyObject *__pyx_v_doc = 0;
7080   int __pyx_lineno = 0;
7081   const char *__pyx_filename = NULL;
7082   int __pyx_clineno = 0;
7083   PyObject *__pyx_r = 0;
7084   __Pyx_RefNannyDeclarations
7085   __Pyx_RefNannySetupContext("merge_insert (wrapper)", 0);
7086   {
7087     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ins_chunks,&__pyx_n_s_doc,0};
7088     PyObject* values[2] = {0,0};
7089     if (unlikely(__pyx_kwds)) {
7090       Py_ssize_t kw_args;
7091       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7092       switch (pos_args) {
7093         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7094         CYTHON_FALLTHROUGH;
7095         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7096         CYTHON_FALLTHROUGH;
7097         case  0: break;
7098         default: goto __pyx_L5_argtuple_error;
7099       }
7100       kw_args = PyDict_Size(__pyx_kwds);
7101       switch (pos_args) {
7102         case  0:
7103         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ins_chunks)) != 0)) kw_args--;
7104         else goto __pyx_L5_argtuple_error;
7105         CYTHON_FALLTHROUGH;
7106         case  1:
7107         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc)) != 0)) kw_args--;
7108         else {
7109           __Pyx_RaiseArgtupleInvalid("merge_insert", 1, 2, 2, 1); __PYX_ERR(0, 234, __pyx_L3_error)
7110         }
7111       }
7112       if (unlikely(kw_args > 0)) {
7113         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge_insert") < 0)) __PYX_ERR(0, 234, __pyx_L3_error)
7114       }
7115     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
7116       goto __pyx_L5_argtuple_error;
7117     } else {
7118       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7119       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7120     }
7121     __pyx_v_ins_chunks = values[0];
7122     __pyx_v_doc = values[1];
7123   }
7124   goto __pyx_L4_argument_unpacking_done;
7125   __pyx_L5_argtuple_error:;
7126   __Pyx_RaiseArgtupleInvalid("merge_insert", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 234, __pyx_L3_error)
7127   __pyx_L3_error:;
7128   __Pyx_AddTraceback("lxml.html.diff.merge_insert", __pyx_clineno, __pyx_lineno, __pyx_filename);
7129   __Pyx_RefNannyFinishContext();
7130   return NULL;
7131   __pyx_L4_argument_unpacking_done:;
7132   __pyx_r = __pyx_pf_4lxml_4html_4diff_24merge_insert(__pyx_self, __pyx_v_ins_chunks, __pyx_v_doc);
7133
7134   /* function exit code */
7135   __Pyx_RefNannyFinishContext();
7136   return __pyx_r;
7137 }
7138
7139 static PyObject *__pyx_pf_4lxml_4html_4diff_24merge_insert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ins_chunks, PyObject *__pyx_v_doc) {
7140   PyObject *__pyx_v_unbalanced_start = NULL;
7141   PyObject *__pyx_v_balanced = NULL;
7142   PyObject *__pyx_v_unbalanced_end = NULL;
7143   PyObject *__pyx_r = NULL;
7144   __Pyx_RefNannyDeclarations
7145   PyObject *__pyx_t_1 = NULL;
7146   PyObject *__pyx_t_2 = NULL;
7147   PyObject *__pyx_t_3 = NULL;
7148   PyObject *__pyx_t_4 = NULL;
7149   PyObject *__pyx_t_5 = NULL;
7150   PyObject *(*__pyx_t_6)(PyObject *);
7151   int __pyx_t_7;
7152   int __pyx_t_8;
7153   int __pyx_t_9;
7154   Py_ssize_t __pyx_t_10;
7155   int __pyx_t_11;
7156   int __pyx_lineno = 0;
7157   const char *__pyx_filename = NULL;
7158   int __pyx_clineno = 0;
7159   __Pyx_RefNannySetupContext("merge_insert", 0);
7160
7161   /* "lxml/html/diff.py":240
7162  *     # (we assume there is accompanying markup later or earlier in the
7163  *     # document), we only put <ins> around the balanced portion.
7164  *     unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)             # <<<<<<<<<<<<<<
7165  *     doc.extend(unbalanced_start)
7166  *     if doc and not doc[-1].endswith(' '):
7167  */
7168   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_split_unbalanced); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
7169   __Pyx_GOTREF(__pyx_t_2);
7170   __pyx_t_3 = NULL;
7171   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
7172     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
7173     if (likely(__pyx_t_3)) {
7174       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
7175       __Pyx_INCREF(__pyx_t_3);
7176       __Pyx_INCREF(function);
7177       __Pyx_DECREF_SET(__pyx_t_2, function);
7178     }
7179   }
7180   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_ins_chunks) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ins_chunks);
7181   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7182   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
7183   __Pyx_GOTREF(__pyx_t_1);
7184   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7185   if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
7186     PyObject* sequence = __pyx_t_1;
7187     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
7188     if (unlikely(size != 3)) {
7189       if (size > 3) __Pyx_RaiseTooManyValuesError(3);
7190       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
7191       __PYX_ERR(0, 240, __pyx_L1_error)
7192     }
7193     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7194     if (likely(PyTuple_CheckExact(sequence))) {
7195       __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
7196       __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
7197       __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
7198     } else {
7199       __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
7200       __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
7201       __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
7202     }
7203     __Pyx_INCREF(__pyx_t_2);
7204     __Pyx_INCREF(__pyx_t_3);
7205     __Pyx_INCREF(__pyx_t_4);
7206     #else
7207     __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
7208     __Pyx_GOTREF(__pyx_t_2);
7209     __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
7210     __Pyx_GOTREF(__pyx_t_3);
7211     __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 240, __pyx_L1_error)
7212     __Pyx_GOTREF(__pyx_t_4);
7213     #endif
7214     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7215   } else {
7216     Py_ssize_t index = -1;
7217     __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 240, __pyx_L1_error)
7218     __Pyx_GOTREF(__pyx_t_5);
7219     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7220     __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
7221     index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
7222     __Pyx_GOTREF(__pyx_t_2);
7223     index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
7224     __Pyx_GOTREF(__pyx_t_3);
7225     index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
7226     __Pyx_GOTREF(__pyx_t_4);
7227     if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 240, __pyx_L1_error)
7228     __pyx_t_6 = NULL;
7229     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7230     goto __pyx_L4_unpacking_done;
7231     __pyx_L3_unpacking_failed:;
7232     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7233     __pyx_t_6 = NULL;
7234     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
7235     __PYX_ERR(0, 240, __pyx_L1_error)
7236     __pyx_L4_unpacking_done:;
7237   }
7238   __pyx_v_unbalanced_start = __pyx_t_2;
7239   __pyx_t_2 = 0;
7240   __pyx_v_balanced = __pyx_t_3;
7241   __pyx_t_3 = 0;
7242   __pyx_v_unbalanced_end = __pyx_t_4;
7243   __pyx_t_4 = 0;
7244
7245   /* "lxml/html/diff.py":241
7246  *     # document), we only put <ins> around the balanced portion.
7247  *     unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)
7248  *     doc.extend(unbalanced_start)             # <<<<<<<<<<<<<<
7249  *     if doc and not doc[-1].endswith(' '):
7250  *         # Fix up the case where the word before the insert didn't end with
7251  */
7252   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L1_error)
7253   __Pyx_GOTREF(__pyx_t_4);
7254   __pyx_t_3 = NULL;
7255   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
7256     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
7257     if (likely(__pyx_t_3)) {
7258       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
7259       __Pyx_INCREF(__pyx_t_3);
7260       __Pyx_INCREF(function);
7261       __Pyx_DECREF_SET(__pyx_t_4, function);
7262     }
7263   }
7264   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_unbalanced_start) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_unbalanced_start);
7265   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7266   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error)
7267   __Pyx_GOTREF(__pyx_t_1);
7268   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7269   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7270
7271   /* "lxml/html/diff.py":242
7272  *     unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)
7273  *     doc.extend(unbalanced_start)
7274  *     if doc and not doc[-1].endswith(' '):             # <<<<<<<<<<<<<<
7275  *         # Fix up the case where the word before the insert didn't end with
7276  *         # a space
7277  */
7278   __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_doc); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
7279   if (__pyx_t_8) {
7280   } else {
7281     __pyx_t_7 = __pyx_t_8;
7282     goto __pyx_L6_bool_binop_done;
7283   }
7284   __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_doc, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L1_error)
7285   __Pyx_GOTREF(__pyx_t_4);
7286   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_endswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error)
7287   __Pyx_GOTREF(__pyx_t_3);
7288   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7289   __pyx_t_4 = NULL;
7290   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
7291     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
7292     if (likely(__pyx_t_4)) {
7293       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7294       __Pyx_INCREF(__pyx_t_4);
7295       __Pyx_INCREF(function);
7296       __Pyx_DECREF_SET(__pyx_t_3, function);
7297     }
7298   }
7299   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u__6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u__6);
7300   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7301   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
7302   __Pyx_GOTREF(__pyx_t_1);
7303   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7304   __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
7305   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7306   __pyx_t_9 = ((!__pyx_t_8) != 0);
7307   __pyx_t_7 = __pyx_t_9;
7308   __pyx_L6_bool_binop_done:;
7309   if (__pyx_t_7) {
7310
7311     /* "lxml/html/diff.py":245
7312  *         # Fix up the case where the word before the insert didn't end with
7313  *         # a space
7314  *         doc[-1] += ' '             # <<<<<<<<<<<<<<
7315  *     doc.append('<ins>')
7316  *     if balanced and balanced[-1].endswith(' '):
7317  */
7318     __pyx_t_10 = -1L;
7319     __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_doc, __pyx_t_10, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
7320     __Pyx_GOTREF(__pyx_t_1);
7321     __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_kp_u__6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
7322     __Pyx_GOTREF(__pyx_t_3);
7323     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7324     if (unlikely(__Pyx_SetItemInt(__pyx_v_doc, __pyx_t_10, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 245, __pyx_L1_error)
7325     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7326
7327     /* "lxml/html/diff.py":242
7328  *     unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)
7329  *     doc.extend(unbalanced_start)
7330  *     if doc and not doc[-1].endswith(' '):             # <<<<<<<<<<<<<<
7331  *         # Fix up the case where the word before the insert didn't end with
7332  *         # a space
7333  */
7334   }
7335
7336   /* "lxml/html/diff.py":246
7337  *         # a space
7338  *         doc[-1] += ' '
7339  *     doc.append('<ins>')             # <<<<<<<<<<<<<<
7340  *     if balanced and balanced[-1].endswith(' '):
7341  *         # We move space outside of </ins>
7342  */
7343   __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_kp_u_ins); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 246, __pyx_L1_error)
7344
7345   /* "lxml/html/diff.py":247
7346  *         doc[-1] += ' '
7347  *     doc.append('<ins>')
7348  *     if balanced and balanced[-1].endswith(' '):             # <<<<<<<<<<<<<<
7349  *         # We move space outside of </ins>
7350  *         balanced[-1] = balanced[-1][:-1]
7351  */
7352   __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_balanced); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 247, __pyx_L1_error)
7353   if (__pyx_t_9) {
7354   } else {
7355     __pyx_t_7 = __pyx_t_9;
7356     goto __pyx_L9_bool_binop_done;
7357   }
7358   __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_balanced, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error)
7359   __Pyx_GOTREF(__pyx_t_1);
7360   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_endswith); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
7361   __Pyx_GOTREF(__pyx_t_4);
7362   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7363   __pyx_t_1 = NULL;
7364   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
7365     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
7366     if (likely(__pyx_t_1)) {
7367       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
7368       __Pyx_INCREF(__pyx_t_1);
7369       __Pyx_INCREF(function);
7370       __Pyx_DECREF_SET(__pyx_t_4, function);
7371     }
7372   }
7373   __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_kp_u__6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__6);
7374   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7375   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
7376   __Pyx_GOTREF(__pyx_t_3);
7377   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7378   __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 247, __pyx_L1_error)
7379   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7380   __pyx_t_7 = __pyx_t_9;
7381   __pyx_L9_bool_binop_done:;
7382   if (__pyx_t_7) {
7383
7384     /* "lxml/html/diff.py":249
7385  *     if balanced and balanced[-1].endswith(' '):
7386  *         # We move space outside of </ins>
7387  *         balanced[-1] = balanced[-1][:-1]             # <<<<<<<<<<<<<<
7388  *     doc.extend(balanced)
7389  *     doc.append('</ins> ')
7390  */
7391     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_balanced, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
7392     __Pyx_GOTREF(__pyx_t_3);
7393     __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, -1L, NULL, NULL, &__pyx_slice__7, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error)
7394     __Pyx_GOTREF(__pyx_t_4);
7395     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7396     if (unlikely(__Pyx_SetItemInt(__pyx_v_balanced, -1L, __pyx_t_4, long, 1, __Pyx_PyInt_From_long, 0, 1, 1) < 0)) __PYX_ERR(0, 249, __pyx_L1_error)
7397     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7398
7399     /* "lxml/html/diff.py":247
7400  *         doc[-1] += ' '
7401  *     doc.append('<ins>')
7402  *     if balanced and balanced[-1].endswith(' '):             # <<<<<<<<<<<<<<
7403  *         # We move space outside of </ins>
7404  *         balanced[-1] = balanced[-1][:-1]
7405  */
7406   }
7407
7408   /* "lxml/html/diff.py":250
7409  *         # We move space outside of </ins>
7410  *         balanced[-1] = balanced[-1][:-1]
7411  *     doc.extend(balanced)             # <<<<<<<<<<<<<<
7412  *     doc.append('</ins> ')
7413  *     doc.extend(unbalanced_end)
7414  */
7415   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
7416   __Pyx_GOTREF(__pyx_t_3);
7417   __pyx_t_1 = NULL;
7418   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
7419     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
7420     if (likely(__pyx_t_1)) {
7421       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7422       __Pyx_INCREF(__pyx_t_1);
7423       __Pyx_INCREF(function);
7424       __Pyx_DECREF_SET(__pyx_t_3, function);
7425     }
7426   }
7427   __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_balanced) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_balanced);
7428   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7429   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
7430   __Pyx_GOTREF(__pyx_t_4);
7431   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7432   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7433
7434   /* "lxml/html/diff.py":251
7435  *         balanced[-1] = balanced[-1][:-1]
7436  *     doc.extend(balanced)
7437  *     doc.append('</ins> ')             # <<<<<<<<<<<<<<
7438  *     doc.extend(unbalanced_end)
7439  * 
7440  */
7441   __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_kp_u_ins_2); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 251, __pyx_L1_error)
7442
7443   /* "lxml/html/diff.py":252
7444  *     doc.extend(balanced)
7445  *     doc.append('</ins> ')
7446  *     doc.extend(unbalanced_end)             # <<<<<<<<<<<<<<
7447  * 
7448  * # These are sentinals to represent the start and end of a <del>
7449  */
7450   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error)
7451   __Pyx_GOTREF(__pyx_t_3);
7452   __pyx_t_1 = NULL;
7453   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
7454     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
7455     if (likely(__pyx_t_1)) {
7456       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7457       __Pyx_INCREF(__pyx_t_1);
7458       __Pyx_INCREF(function);
7459       __Pyx_DECREF_SET(__pyx_t_3, function);
7460     }
7461   }
7462   __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_unbalanced_end) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_unbalanced_end);
7463   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7464   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 252, __pyx_L1_error)
7465   __Pyx_GOTREF(__pyx_t_4);
7466   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7467   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7468
7469   /* "lxml/html/diff.py":234
7470  *             yield post
7471  * 
7472  * def merge_insert(ins_chunks, doc):             # <<<<<<<<<<<<<<
7473  *     """ doc is the already-handled document (as a list of text chunks);
7474  *     here we add <ins>ins_chunks</ins> to the end of that.  """
7475  */
7476
7477   /* function exit code */
7478   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7479   goto __pyx_L0;
7480   __pyx_L1_error:;
7481   __Pyx_XDECREF(__pyx_t_1);
7482   __Pyx_XDECREF(__pyx_t_2);
7483   __Pyx_XDECREF(__pyx_t_3);
7484   __Pyx_XDECREF(__pyx_t_4);
7485   __Pyx_XDECREF(__pyx_t_5);
7486   __Pyx_AddTraceback("lxml.html.diff.merge_insert", __pyx_clineno, __pyx_lineno, __pyx_filename);
7487   __pyx_r = NULL;
7488   __pyx_L0:;
7489   __Pyx_XDECREF(__pyx_v_unbalanced_start);
7490   __Pyx_XDECREF(__pyx_v_balanced);
7491   __Pyx_XDECREF(__pyx_v_unbalanced_end);
7492   __Pyx_XGIVEREF(__pyx_r);
7493   __Pyx_RefNannyFinishContext();
7494   return __pyx_r;
7495 }
7496
7497 /* "lxml/html/diff.py":266
7498  *     (DEL_START/DEL_END) """
7499  * 
7500  * def merge_delete(del_chunks, doc):             # <<<<<<<<<<<<<<
7501  *     """ Adds the text chunks in del_chunks to the document doc (another
7502  *     list of text chunks) with marker to show it is a delete.
7503  */
7504
7505 /* Python wrapper */
7506 static PyObject *__pyx_pw_4lxml_4html_4diff_27merge_delete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7507 static char __pyx_doc_4lxml_4html_4diff_26merge_delete[] = " Adds the text chunks in del_chunks to the document doc (another\n    list of text chunks) with marker to show it is a delete.\n    cleanup_delete later resolves these markers into <del> tags.";
7508 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_27merge_delete = {"merge_delete", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_27merge_delete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_26merge_delete};
7509 static PyObject *__pyx_pw_4lxml_4html_4diff_27merge_delete(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7510   PyObject *__pyx_v_del_chunks = 0;
7511   PyObject *__pyx_v_doc = 0;
7512   int __pyx_lineno = 0;
7513   const char *__pyx_filename = NULL;
7514   int __pyx_clineno = 0;
7515   PyObject *__pyx_r = 0;
7516   __Pyx_RefNannyDeclarations
7517   __Pyx_RefNannySetupContext("merge_delete (wrapper)", 0);
7518   {
7519     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_del_chunks,&__pyx_n_s_doc,0};
7520     PyObject* values[2] = {0,0};
7521     if (unlikely(__pyx_kwds)) {
7522       Py_ssize_t kw_args;
7523       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7524       switch (pos_args) {
7525         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7526         CYTHON_FALLTHROUGH;
7527         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7528         CYTHON_FALLTHROUGH;
7529         case  0: break;
7530         default: goto __pyx_L5_argtuple_error;
7531       }
7532       kw_args = PyDict_Size(__pyx_kwds);
7533       switch (pos_args) {
7534         case  0:
7535         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_del_chunks)) != 0)) kw_args--;
7536         else goto __pyx_L5_argtuple_error;
7537         CYTHON_FALLTHROUGH;
7538         case  1:
7539         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc)) != 0)) kw_args--;
7540         else {
7541           __Pyx_RaiseArgtupleInvalid("merge_delete", 1, 2, 2, 1); __PYX_ERR(0, 266, __pyx_L3_error)
7542         }
7543       }
7544       if (unlikely(kw_args > 0)) {
7545         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge_delete") < 0)) __PYX_ERR(0, 266, __pyx_L3_error)
7546       }
7547     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
7548       goto __pyx_L5_argtuple_error;
7549     } else {
7550       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7551       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7552     }
7553     __pyx_v_del_chunks = values[0];
7554     __pyx_v_doc = values[1];
7555   }
7556   goto __pyx_L4_argument_unpacking_done;
7557   __pyx_L5_argtuple_error:;
7558   __Pyx_RaiseArgtupleInvalid("merge_delete", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 266, __pyx_L3_error)
7559   __pyx_L3_error:;
7560   __Pyx_AddTraceback("lxml.html.diff.merge_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
7561   __Pyx_RefNannyFinishContext();
7562   return NULL;
7563   __pyx_L4_argument_unpacking_done:;
7564   __pyx_r = __pyx_pf_4lxml_4html_4diff_26merge_delete(__pyx_self, __pyx_v_del_chunks, __pyx_v_doc);
7565
7566   /* function exit code */
7567   __Pyx_RefNannyFinishContext();
7568   return __pyx_r;
7569 }
7570
7571 static PyObject *__pyx_pf_4lxml_4html_4diff_26merge_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_del_chunks, PyObject *__pyx_v_doc) {
7572   PyObject *__pyx_r = NULL;
7573   __Pyx_RefNannyDeclarations
7574   PyObject *__pyx_t_1 = NULL;
7575   int __pyx_t_2;
7576   PyObject *__pyx_t_3 = NULL;
7577   PyObject *__pyx_t_4 = NULL;
7578   int __pyx_lineno = 0;
7579   const char *__pyx_filename = NULL;
7580   int __pyx_clineno = 0;
7581   __Pyx_RefNannySetupContext("merge_delete", 0);
7582
7583   /* "lxml/html/diff.py":270
7584  *     list of text chunks) with marker to show it is a delete.
7585  *     cleanup_delete later resolves these markers into <del> tags."""
7586  *     doc.append(DEL_START)             # <<<<<<<<<<<<<<
7587  *     doc.extend(del_chunks)
7588  *     doc.append(DEL_END)
7589  */
7590   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_DEL_START); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
7591   __Pyx_GOTREF(__pyx_t_1);
7592   __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 270, __pyx_L1_error)
7593   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7594
7595   /* "lxml/html/diff.py":271
7596  *     cleanup_delete later resolves these markers into <del> tags."""
7597  *     doc.append(DEL_START)
7598  *     doc.extend(del_chunks)             # <<<<<<<<<<<<<<
7599  *     doc.append(DEL_END)
7600  * 
7601  */
7602   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
7603   __Pyx_GOTREF(__pyx_t_3);
7604   __pyx_t_4 = NULL;
7605   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
7606     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
7607     if (likely(__pyx_t_4)) {
7608       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7609       __Pyx_INCREF(__pyx_t_4);
7610       __Pyx_INCREF(function);
7611       __Pyx_DECREF_SET(__pyx_t_3, function);
7612     }
7613   }
7614   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_del_chunks) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_del_chunks);
7615   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7616   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
7617   __Pyx_GOTREF(__pyx_t_1);
7618   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7619   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7620
7621   /* "lxml/html/diff.py":272
7622  *     doc.append(DEL_START)
7623  *     doc.extend(del_chunks)
7624  *     doc.append(DEL_END)             # <<<<<<<<<<<<<<
7625  * 
7626  * def cleanup_delete(chunks):
7627  */
7628   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_DEL_END); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
7629   __Pyx_GOTREF(__pyx_t_1);
7630   __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 272, __pyx_L1_error)
7631   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7632
7633   /* "lxml/html/diff.py":266
7634  *     (DEL_START/DEL_END) """
7635  * 
7636  * def merge_delete(del_chunks, doc):             # <<<<<<<<<<<<<<
7637  *     """ Adds the text chunks in del_chunks to the document doc (another
7638  *     list of text chunks) with marker to show it is a delete.
7639  */
7640
7641   /* function exit code */
7642   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7643   goto __pyx_L0;
7644   __pyx_L1_error:;
7645   __Pyx_XDECREF(__pyx_t_1);
7646   __Pyx_XDECREF(__pyx_t_3);
7647   __Pyx_XDECREF(__pyx_t_4);
7648   __Pyx_AddTraceback("lxml.html.diff.merge_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
7649   __pyx_r = NULL;
7650   __pyx_L0:;
7651   __Pyx_XGIVEREF(__pyx_r);
7652   __Pyx_RefNannyFinishContext();
7653   return __pyx_r;
7654 }
7655
7656 /* "lxml/html/diff.py":274
7657  *     doc.append(DEL_END)
7658  * 
7659  * def cleanup_delete(chunks):             # <<<<<<<<<<<<<<
7660  *     """ Cleans up any DEL_START/DEL_END markers in the document, replacing
7661  *     them with <del></del>.  To do this while keeping the document
7662  */
7663
7664 /* Python wrapper */
7665 static PyObject *__pyx_pw_4lxml_4html_4diff_29cleanup_delete(PyObject *__pyx_self, PyObject *__pyx_v_chunks); /*proto*/
7666 static char __pyx_doc_4lxml_4html_4diff_28cleanup_delete[] = " Cleans up any DEL_START/DEL_END markers in the document, replacing\n    them with <del></del>.  To do this while keeping the document\n    valid, it may need to drop some tags (either start or end tags).\n\n    It may also move the del into adjacent tags to try to move it to a\n    similar location where it was originally located (e.g., moving a\n    delete into preceding <div> tag, if the del looks like (DEL_START,\n    'Text</div>', DEL_END)";
7667 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_29cleanup_delete = {"cleanup_delete", (PyCFunction)__pyx_pw_4lxml_4html_4diff_29cleanup_delete, METH_O, __pyx_doc_4lxml_4html_4diff_28cleanup_delete};
7668 static PyObject *__pyx_pw_4lxml_4html_4diff_29cleanup_delete(PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
7669   PyObject *__pyx_r = 0;
7670   __Pyx_RefNannyDeclarations
7671   __Pyx_RefNannySetupContext("cleanup_delete (wrapper)", 0);
7672   __pyx_r = __pyx_pf_4lxml_4html_4diff_28cleanup_delete(__pyx_self, ((PyObject *)__pyx_v_chunks));
7673
7674   /* function exit code */
7675   __Pyx_RefNannyFinishContext();
7676   return __pyx_r;
7677 }
7678
7679 static PyObject *__pyx_pf_4lxml_4html_4diff_28cleanup_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
7680   PyObject *__pyx_v_pre_delete = NULL;
7681   PyObject *__pyx_v_delete = NULL;
7682   PyObject *__pyx_v_post_delete = NULL;
7683   PyObject *__pyx_v_unbalanced_start = NULL;
7684   PyObject *__pyx_v_balanced = NULL;
7685   PyObject *__pyx_v_unbalanced_end = NULL;
7686   PyObject *__pyx_v_doc = NULL;
7687   PyObject *__pyx_r = NULL;
7688   __Pyx_RefNannyDeclarations
7689   PyObject *__pyx_t_1 = NULL;
7690   PyObject *__pyx_t_2 = NULL;
7691   PyObject *__pyx_t_3 = NULL;
7692   PyObject *__pyx_t_4 = NULL;
7693   PyObject *__pyx_t_5 = NULL;
7694   PyObject *__pyx_t_6 = NULL;
7695   PyObject *__pyx_t_7 = NULL;
7696   PyObject *__pyx_t_8 = NULL;
7697   PyObject *(*__pyx_t_9)(PyObject *);
7698   int __pyx_t_10;
7699   int __pyx_t_11;
7700   int __pyx_t_12;
7701   int __pyx_t_13;
7702   Py_ssize_t __pyx_t_14;
7703   int __pyx_t_15;
7704   int __pyx_lineno = 0;
7705   const char *__pyx_filename = NULL;
7706   int __pyx_clineno = 0;
7707   __Pyx_RefNannySetupContext("cleanup_delete", 0);
7708   __Pyx_INCREF(__pyx_v_chunks);
7709
7710   /* "lxml/html/diff.py":283
7711  *     delete into preceding <div> tag, if the del looks like (DEL_START,
7712  *     'Text</div>', DEL_END)"""
7713  *     while 1:             # <<<<<<<<<<<<<<
7714  *         # Find a pending DEL_START/DEL_END, splitting the document
7715  *         # into stuff-preceding-DEL_START, stuff-inside, and
7716  */
7717   while (1) {
7718
7719     /* "lxml/html/diff.py":287
7720  *         # into stuff-preceding-DEL_START, stuff-inside, and
7721  *         # stuff-following-DEL_END
7722  *         try:             # <<<<<<<<<<<<<<
7723  *             pre_delete, delete, post_delete = split_delete(chunks)
7724  *         except NoDeletes:
7725  */
7726     {
7727       __Pyx_PyThreadState_declare
7728       __Pyx_PyThreadState_assign
7729       __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7730       __Pyx_XGOTREF(__pyx_t_1);
7731       __Pyx_XGOTREF(__pyx_t_2);
7732       __Pyx_XGOTREF(__pyx_t_3);
7733       /*try:*/ {
7734
7735         /* "lxml/html/diff.py":288
7736  *         # stuff-following-DEL_END
7737  *         try:
7738  *             pre_delete, delete, post_delete = split_delete(chunks)             # <<<<<<<<<<<<<<
7739  *         except NoDeletes:
7740  *             # Nothing found, we've cleaned up the entire doc
7741  */
7742         __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_split_delete); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L5_error)
7743         __Pyx_GOTREF(__pyx_t_5);
7744         __pyx_t_6 = NULL;
7745         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
7746           __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
7747           if (likely(__pyx_t_6)) {
7748             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7749             __Pyx_INCREF(__pyx_t_6);
7750             __Pyx_INCREF(function);
7751             __Pyx_DECREF_SET(__pyx_t_5, function);
7752           }
7753         }
7754         __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_chunks) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_chunks);
7755         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7756         if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L5_error)
7757         __Pyx_GOTREF(__pyx_t_4);
7758         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7759         if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
7760           PyObject* sequence = __pyx_t_4;
7761           Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
7762           if (unlikely(size != 3)) {
7763             if (size > 3) __Pyx_RaiseTooManyValuesError(3);
7764             else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
7765             __PYX_ERR(0, 288, __pyx_L5_error)
7766           }
7767           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7768           if (likely(PyTuple_CheckExact(sequence))) {
7769             __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
7770             __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
7771             __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
7772           } else {
7773             __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
7774             __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
7775             __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
7776           }
7777           __Pyx_INCREF(__pyx_t_5);
7778           __Pyx_INCREF(__pyx_t_6);
7779           __Pyx_INCREF(__pyx_t_7);
7780           #else
7781           __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L5_error)
7782           __Pyx_GOTREF(__pyx_t_5);
7783           __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L5_error)
7784           __Pyx_GOTREF(__pyx_t_6);
7785           __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 288, __pyx_L5_error)
7786           __Pyx_GOTREF(__pyx_t_7);
7787           #endif
7788           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7789         } else {
7790           Py_ssize_t index = -1;
7791           __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 288, __pyx_L5_error)
7792           __Pyx_GOTREF(__pyx_t_8);
7793           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7794           __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
7795           index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L13_unpacking_failed;
7796           __Pyx_GOTREF(__pyx_t_5);
7797           index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L13_unpacking_failed;
7798           __Pyx_GOTREF(__pyx_t_6);
7799           index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L13_unpacking_failed;
7800           __Pyx_GOTREF(__pyx_t_7);
7801           if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(0, 288, __pyx_L5_error)
7802           __pyx_t_9 = NULL;
7803           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7804           goto __pyx_L14_unpacking_done;
7805           __pyx_L13_unpacking_failed:;
7806           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7807           __pyx_t_9 = NULL;
7808           if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
7809           __PYX_ERR(0, 288, __pyx_L5_error)
7810           __pyx_L14_unpacking_done:;
7811         }
7812         __Pyx_XDECREF_SET(__pyx_v_pre_delete, __pyx_t_5);
7813         __pyx_t_5 = 0;
7814         __Pyx_XDECREF_SET(__pyx_v_delete, __pyx_t_6);
7815         __pyx_t_6 = 0;
7816         __Pyx_XDECREF_SET(__pyx_v_post_delete, __pyx_t_7);
7817         __pyx_t_7 = 0;
7818
7819         /* "lxml/html/diff.py":287
7820  *         # into stuff-preceding-DEL_START, stuff-inside, and
7821  *         # stuff-following-DEL_END
7822  *         try:             # <<<<<<<<<<<<<<
7823  *             pre_delete, delete, post_delete = split_delete(chunks)
7824  *         except NoDeletes:
7825  */
7826       }
7827       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7828       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7829       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7830       goto __pyx_L12_try_end;
7831       __pyx_L5_error:;
7832       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7833       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7834       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7835       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
7836       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7837
7838       /* "lxml/html/diff.py":289
7839  *         try:
7840  *             pre_delete, delete, post_delete = split_delete(chunks)
7841  *         except NoDeletes:             # <<<<<<<<<<<<<<
7842  *             # Nothing found, we've cleaned up the entire doc
7843  *             break
7844  */
7845       __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_7, &__pyx_t_6);
7846       __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_NoDeletes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L7_except_error)
7847       __Pyx_GOTREF(__pyx_t_5);
7848       __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_5);
7849       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7850       __Pyx_ErrRestore(__pyx_t_4, __pyx_t_7, __pyx_t_6);
7851       __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0;
7852       if (__pyx_t_10) {
7853         __Pyx_AddTraceback("lxml.html.diff.cleanup_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
7854         if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_4) < 0) __PYX_ERR(0, 289, __pyx_L7_except_error)
7855         __Pyx_GOTREF(__pyx_t_6);
7856         __Pyx_GOTREF(__pyx_t_7);
7857         __Pyx_GOTREF(__pyx_t_4);
7858
7859         /* "lxml/html/diff.py":291
7860  *         except NoDeletes:
7861  *             # Nothing found, we've cleaned up the entire doc
7862  *             break             # <<<<<<<<<<<<<<
7863  *         # The stuff-inside-DEL_START/END may not be well balanced
7864  *         # markup.  First we figure out what unbalanced portions there are:
7865  */
7866         goto __pyx_L15_except_break;
7867         __pyx_L15_except_break:;
7868         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7869         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7870         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7871         goto __pyx_L10_try_break;
7872       }
7873       goto __pyx_L7_except_error;
7874       __pyx_L7_except_error:;
7875
7876       /* "lxml/html/diff.py":287
7877  *         # into stuff-preceding-DEL_START, stuff-inside, and
7878  *         # stuff-following-DEL_END
7879  *         try:             # <<<<<<<<<<<<<<
7880  *             pre_delete, delete, post_delete = split_delete(chunks)
7881  *         except NoDeletes:
7882  */
7883       __Pyx_XGIVEREF(__pyx_t_1);
7884       __Pyx_XGIVEREF(__pyx_t_2);
7885       __Pyx_XGIVEREF(__pyx_t_3);
7886       __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7887       goto __pyx_L1_error;
7888       __pyx_L10_try_break:;
7889       __Pyx_XGIVEREF(__pyx_t_1);
7890       __Pyx_XGIVEREF(__pyx_t_2);
7891       __Pyx_XGIVEREF(__pyx_t_3);
7892       __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7893       goto __pyx_L4_break;
7894       __pyx_L12_try_end:;
7895     }
7896
7897     /* "lxml/html/diff.py":294
7898  *         # The stuff-inside-DEL_START/END may not be well balanced
7899  *         # markup.  First we figure out what unbalanced portions there are:
7900  *         unbalanced_start, balanced, unbalanced_end = split_unbalanced(delete)             # <<<<<<<<<<<<<<
7901  *         # Then we move the span forward and/or backward based on these
7902  *         # unbalanced portions:
7903  */
7904     __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_split_unbalanced); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
7905     __Pyx_GOTREF(__pyx_t_7);
7906     __pyx_t_6 = NULL;
7907     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
7908       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
7909       if (likely(__pyx_t_6)) {
7910         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
7911         __Pyx_INCREF(__pyx_t_6);
7912         __Pyx_INCREF(function);
7913         __Pyx_DECREF_SET(__pyx_t_7, function);
7914       }
7915     }
7916     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_v_delete) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_delete);
7917     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7918     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error)
7919     __Pyx_GOTREF(__pyx_t_4);
7920     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7921     if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
7922       PyObject* sequence = __pyx_t_4;
7923       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
7924       if (unlikely(size != 3)) {
7925         if (size > 3) __Pyx_RaiseTooManyValuesError(3);
7926         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
7927         __PYX_ERR(0, 294, __pyx_L1_error)
7928       }
7929       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7930       if (likely(PyTuple_CheckExact(sequence))) {
7931         __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
7932         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
7933         __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
7934       } else {
7935         __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
7936         __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
7937         __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
7938       }
7939       __Pyx_INCREF(__pyx_t_7);
7940       __Pyx_INCREF(__pyx_t_6);
7941       __Pyx_INCREF(__pyx_t_5);
7942       #else
7943       __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
7944       __Pyx_GOTREF(__pyx_t_7);
7945       __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 294, __pyx_L1_error)
7946       __Pyx_GOTREF(__pyx_t_6);
7947       __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 294, __pyx_L1_error)
7948       __Pyx_GOTREF(__pyx_t_5);
7949       #endif
7950       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7951     } else {
7952       Py_ssize_t index = -1;
7953       __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 294, __pyx_L1_error)
7954       __Pyx_GOTREF(__pyx_t_8);
7955       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7956       __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
7957       index = 0; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L17_unpacking_failed;
7958       __Pyx_GOTREF(__pyx_t_7);
7959       index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L17_unpacking_failed;
7960       __Pyx_GOTREF(__pyx_t_6);
7961       index = 2; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L17_unpacking_failed;
7962       __Pyx_GOTREF(__pyx_t_5);
7963       if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(0, 294, __pyx_L1_error)
7964       __pyx_t_9 = NULL;
7965       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7966       goto __pyx_L18_unpacking_done;
7967       __pyx_L17_unpacking_failed:;
7968       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7969       __pyx_t_9 = NULL;
7970       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
7971       __PYX_ERR(0, 294, __pyx_L1_error)
7972       __pyx_L18_unpacking_done:;
7973     }
7974     __Pyx_XDECREF_SET(__pyx_v_unbalanced_start, __pyx_t_7);
7975     __pyx_t_7 = 0;
7976     __Pyx_XDECREF_SET(__pyx_v_balanced, __pyx_t_6);
7977     __pyx_t_6 = 0;
7978     __Pyx_XDECREF_SET(__pyx_v_unbalanced_end, __pyx_t_5);
7979     __pyx_t_5 = 0;
7980
7981     /* "lxml/html/diff.py":297
7982  *         # Then we move the span forward and/or backward based on these
7983  *         # unbalanced portions:
7984  *         locate_unbalanced_start(unbalanced_start, pre_delete, post_delete)             # <<<<<<<<<<<<<<
7985  *         locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
7986  *         doc = pre_delete
7987  */
7988     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_locate_unbalanced_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 297, __pyx_L1_error)
7989     __Pyx_GOTREF(__pyx_t_5);
7990     __pyx_t_6 = NULL;
7991     __pyx_t_10 = 0;
7992     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
7993       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
7994       if (likely(__pyx_t_6)) {
7995         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7996         __Pyx_INCREF(__pyx_t_6);
7997         __Pyx_INCREF(function);
7998         __Pyx_DECREF_SET(__pyx_t_5, function);
7999         __pyx_t_10 = 1;
8000       }
8001     }
8002     #if CYTHON_FAST_PYCALL
8003     if (PyFunction_Check(__pyx_t_5)) {
8004       PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_unbalanced_start, __pyx_v_pre_delete, __pyx_v_post_delete};
8005       __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error)
8006       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
8007       __Pyx_GOTREF(__pyx_t_4);
8008     } else
8009     #endif
8010     #if CYTHON_FAST_PYCCALL
8011     if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
8012       PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_unbalanced_start, __pyx_v_pre_delete, __pyx_v_post_delete};
8013       __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error)
8014       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
8015       __Pyx_GOTREF(__pyx_t_4);
8016     } else
8017     #endif
8018     {
8019       __pyx_t_7 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 297, __pyx_L1_error)
8020       __Pyx_GOTREF(__pyx_t_7);
8021       if (__pyx_t_6) {
8022         __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
8023       }
8024       __Pyx_INCREF(__pyx_v_unbalanced_start);
8025       __Pyx_GIVEREF(__pyx_v_unbalanced_start);
8026       PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_10, __pyx_v_unbalanced_start);
8027       __Pyx_INCREF(__pyx_v_pre_delete);
8028       __Pyx_GIVEREF(__pyx_v_pre_delete);
8029       PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_10, __pyx_v_pre_delete);
8030       __Pyx_INCREF(__pyx_v_post_delete);
8031       __Pyx_GIVEREF(__pyx_v_post_delete);
8032       PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_10, __pyx_v_post_delete);
8033       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error)
8034       __Pyx_GOTREF(__pyx_t_4);
8035       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8036     }
8037     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8038     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8039
8040     /* "lxml/html/diff.py":298
8041  *         # unbalanced portions:
8042  *         locate_unbalanced_start(unbalanced_start, pre_delete, post_delete)
8043  *         locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)             # <<<<<<<<<<<<<<
8044  *         doc = pre_delete
8045  *         if doc and not doc[-1].endswith(' '):
8046  */
8047     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_locate_unbalanced_end); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
8048     __Pyx_GOTREF(__pyx_t_5);
8049     __pyx_t_7 = NULL;
8050     __pyx_t_10 = 0;
8051     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
8052       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
8053       if (likely(__pyx_t_7)) {
8054         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
8055         __Pyx_INCREF(__pyx_t_7);
8056         __Pyx_INCREF(function);
8057         __Pyx_DECREF_SET(__pyx_t_5, function);
8058         __pyx_t_10 = 1;
8059       }
8060     }
8061     #if CYTHON_FAST_PYCALL
8062     if (PyFunction_Check(__pyx_t_5)) {
8063       PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_unbalanced_end, __pyx_v_pre_delete, __pyx_v_post_delete};
8064       __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
8065       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
8066       __Pyx_GOTREF(__pyx_t_4);
8067     } else
8068     #endif
8069     #if CYTHON_FAST_PYCCALL
8070     if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
8071       PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_unbalanced_end, __pyx_v_pre_delete, __pyx_v_post_delete};
8072       __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
8073       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
8074       __Pyx_GOTREF(__pyx_t_4);
8075     } else
8076     #endif
8077     {
8078       __pyx_t_6 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L1_error)
8079       __Pyx_GOTREF(__pyx_t_6);
8080       if (__pyx_t_7) {
8081         __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
8082       }
8083       __Pyx_INCREF(__pyx_v_unbalanced_end);
8084       __Pyx_GIVEREF(__pyx_v_unbalanced_end);
8085       PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_v_unbalanced_end);
8086       __Pyx_INCREF(__pyx_v_pre_delete);
8087       __Pyx_GIVEREF(__pyx_v_pre_delete);
8088       PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_pre_delete);
8089       __Pyx_INCREF(__pyx_v_post_delete);
8090       __Pyx_GIVEREF(__pyx_v_post_delete);
8091       PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_10, __pyx_v_post_delete);
8092       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
8093       __Pyx_GOTREF(__pyx_t_4);
8094       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8095     }
8096     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8097     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8098
8099     /* "lxml/html/diff.py":299
8100  *         locate_unbalanced_start(unbalanced_start, pre_delete, post_delete)
8101  *         locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
8102  *         doc = pre_delete             # <<<<<<<<<<<<<<
8103  *         if doc and not doc[-1].endswith(' '):
8104  *             # Fix up case where the word before us didn't have a trailing space
8105  */
8106     __Pyx_INCREF(__pyx_v_pre_delete);
8107     __Pyx_XDECREF_SET(__pyx_v_doc, __pyx_v_pre_delete);
8108
8109     /* "lxml/html/diff.py":300
8110  *         locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
8111  *         doc = pre_delete
8112  *         if doc and not doc[-1].endswith(' '):             # <<<<<<<<<<<<<<
8113  *             # Fix up case where the word before us didn't have a trailing space
8114  *             doc[-1] += ' '
8115  */
8116     __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_doc); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
8117     if (__pyx_t_12) {
8118     } else {
8119       __pyx_t_11 = __pyx_t_12;
8120       goto __pyx_L20_bool_binop_done;
8121     }
8122     __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_doc, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
8123     __Pyx_GOTREF(__pyx_t_5);
8124     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_endswith); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 300, __pyx_L1_error)
8125     __Pyx_GOTREF(__pyx_t_6);
8126     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8127     __pyx_t_5 = NULL;
8128     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
8129       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
8130       if (likely(__pyx_t_5)) {
8131         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
8132         __Pyx_INCREF(__pyx_t_5);
8133         __Pyx_INCREF(function);
8134         __Pyx_DECREF_SET(__pyx_t_6, function);
8135       }
8136     }
8137     __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_kp_u__6) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_u__6);
8138     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
8139     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L1_error)
8140     __Pyx_GOTREF(__pyx_t_4);
8141     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8142     __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
8143     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8144     __pyx_t_13 = ((!__pyx_t_12) != 0);
8145     __pyx_t_11 = __pyx_t_13;
8146     __pyx_L20_bool_binop_done:;
8147     if (__pyx_t_11) {
8148
8149       /* "lxml/html/diff.py":302
8150  *         if doc and not doc[-1].endswith(' '):
8151  *             # Fix up case where the word before us didn't have a trailing space
8152  *             doc[-1] += ' '             # <<<<<<<<<<<<<<
8153  *         doc.append('<del>')
8154  *         if balanced and balanced[-1].endswith(' '):
8155  */
8156       __pyx_t_14 = -1L;
8157       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_doc, __pyx_t_14, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error)
8158       __Pyx_GOTREF(__pyx_t_4);
8159       __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_kp_u__6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 302, __pyx_L1_error)
8160       __Pyx_GOTREF(__pyx_t_6);
8161       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8162       if (unlikely(__Pyx_SetItemInt(__pyx_v_doc, __pyx_t_14, __pyx_t_6, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 302, __pyx_L1_error)
8163       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8164
8165       /* "lxml/html/diff.py":300
8166  *         locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
8167  *         doc = pre_delete
8168  *         if doc and not doc[-1].endswith(' '):             # <<<<<<<<<<<<<<
8169  *             # Fix up case where the word before us didn't have a trailing space
8170  *             doc[-1] += ' '
8171  */
8172     }
8173
8174     /* "lxml/html/diff.py":303
8175  *             # Fix up case where the word before us didn't have a trailing space
8176  *             doc[-1] += ' '
8177  *         doc.append('<del>')             # <<<<<<<<<<<<<<
8178  *         if balanced and balanced[-1].endswith(' '):
8179  *             # We move space outside of </del>
8180  */
8181     __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_kp_u_del); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 303, __pyx_L1_error)
8182
8183     /* "lxml/html/diff.py":304
8184  *             doc[-1] += ' '
8185  *         doc.append('<del>')
8186  *         if balanced and balanced[-1].endswith(' '):             # <<<<<<<<<<<<<<
8187  *             # We move space outside of </del>
8188  *             balanced[-1] = balanced[-1][:-1]
8189  */
8190     __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_balanced); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 304, __pyx_L1_error)
8191     if (__pyx_t_13) {
8192     } else {
8193       __pyx_t_11 = __pyx_t_13;
8194       goto __pyx_L23_bool_binop_done;
8195     }
8196     __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_balanced, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error)
8197     __Pyx_GOTREF(__pyx_t_4);
8198     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_endswith); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error)
8199     __Pyx_GOTREF(__pyx_t_5);
8200     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8201     __pyx_t_4 = NULL;
8202     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
8203       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
8204       if (likely(__pyx_t_4)) {
8205         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
8206         __Pyx_INCREF(__pyx_t_4);
8207         __Pyx_INCREF(function);
8208         __Pyx_DECREF_SET(__pyx_t_5, function);
8209       }
8210     }
8211     __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u__6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u__6);
8212     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
8213     if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L1_error)
8214     __Pyx_GOTREF(__pyx_t_6);
8215     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8216     __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 304, __pyx_L1_error)
8217     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8218     __pyx_t_11 = __pyx_t_13;
8219     __pyx_L23_bool_binop_done:;
8220     if (__pyx_t_11) {
8221
8222       /* "lxml/html/diff.py":306
8223  *         if balanced and balanced[-1].endswith(' '):
8224  *             # We move space outside of </del>
8225  *             balanced[-1] = balanced[-1][:-1]             # <<<<<<<<<<<<<<
8226  *         doc.extend(balanced)
8227  *         doc.append('</del> ')
8228  */
8229       __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_balanced, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 306, __pyx_L1_error)
8230       __Pyx_GOTREF(__pyx_t_6);
8231       __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, -1L, NULL, NULL, &__pyx_slice__7, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error)
8232       __Pyx_GOTREF(__pyx_t_5);
8233       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8234       if (unlikely(__Pyx_SetItemInt(__pyx_v_balanced, -1L, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 0, 1, 1) < 0)) __PYX_ERR(0, 306, __pyx_L1_error)
8235       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8236
8237       /* "lxml/html/diff.py":304
8238  *             doc[-1] += ' '
8239  *         doc.append('<del>')
8240  *         if balanced and balanced[-1].endswith(' '):             # <<<<<<<<<<<<<<
8241  *             # We move space outside of </del>
8242  *             balanced[-1] = balanced[-1][:-1]
8243  */
8244     }
8245
8246     /* "lxml/html/diff.py":307
8247  *             # We move space outside of </del>
8248  *             balanced[-1] = balanced[-1][:-1]
8249  *         doc.extend(balanced)             # <<<<<<<<<<<<<<
8250  *         doc.append('</del> ')
8251  *         doc.extend(post_delete)
8252  */
8253     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
8254     __Pyx_GOTREF(__pyx_t_6);
8255     __pyx_t_4 = NULL;
8256     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
8257       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
8258       if (likely(__pyx_t_4)) {
8259         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
8260         __Pyx_INCREF(__pyx_t_4);
8261         __Pyx_INCREF(function);
8262         __Pyx_DECREF_SET(__pyx_t_6, function);
8263       }
8264     }
8265     __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_v_balanced) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_balanced);
8266     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
8267     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
8268     __Pyx_GOTREF(__pyx_t_5);
8269     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8270     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8271
8272     /* "lxml/html/diff.py":308
8273  *             balanced[-1] = balanced[-1][:-1]
8274  *         doc.extend(balanced)
8275  *         doc.append('</del> ')             # <<<<<<<<<<<<<<
8276  *         doc.extend(post_delete)
8277  *         chunks = doc
8278  */
8279     __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_doc, __pyx_kp_u_del_2); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 308, __pyx_L1_error)
8280
8281     /* "lxml/html/diff.py":309
8282  *         doc.extend(balanced)
8283  *         doc.append('</del> ')
8284  *         doc.extend(post_delete)             # <<<<<<<<<<<<<<
8285  *         chunks = doc
8286  *     return chunks
8287  */
8288     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_extend); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 309, __pyx_L1_error)
8289     __Pyx_GOTREF(__pyx_t_6);
8290     __pyx_t_4 = NULL;
8291     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
8292       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
8293       if (likely(__pyx_t_4)) {
8294         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
8295         __Pyx_INCREF(__pyx_t_4);
8296         __Pyx_INCREF(function);
8297         __Pyx_DECREF_SET(__pyx_t_6, function);
8298       }
8299     }
8300     __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_v_post_delete) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_post_delete);
8301     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
8302     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 309, __pyx_L1_error)
8303     __Pyx_GOTREF(__pyx_t_5);
8304     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8305     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8306
8307     /* "lxml/html/diff.py":310
8308  *         doc.append('</del> ')
8309  *         doc.extend(post_delete)
8310  *         chunks = doc             # <<<<<<<<<<<<<<
8311  *     return chunks
8312  * 
8313  */
8314     __Pyx_INCREF(__pyx_v_doc);
8315     __Pyx_DECREF_SET(__pyx_v_chunks, __pyx_v_doc);
8316   }
8317   __pyx_L4_break:;
8318
8319   /* "lxml/html/diff.py":311
8320  *         doc.extend(post_delete)
8321  *         chunks = doc
8322  *     return chunks             # <<<<<<<<<<<<<<
8323  * 
8324  * def split_unbalanced(chunks):
8325  */
8326   __Pyx_XDECREF(__pyx_r);
8327   __Pyx_INCREF(__pyx_v_chunks);
8328   __pyx_r = __pyx_v_chunks;
8329   goto __pyx_L0;
8330
8331   /* "lxml/html/diff.py":274
8332  *     doc.append(DEL_END)
8333  * 
8334  * def cleanup_delete(chunks):             # <<<<<<<<<<<<<<
8335  *     """ Cleans up any DEL_START/DEL_END markers in the document, replacing
8336  *     them with <del></del>.  To do this while keeping the document
8337  */
8338
8339   /* function exit code */
8340   __pyx_L1_error:;
8341   __Pyx_XDECREF(__pyx_t_4);
8342   __Pyx_XDECREF(__pyx_t_5);
8343   __Pyx_XDECREF(__pyx_t_6);
8344   __Pyx_XDECREF(__pyx_t_7);
8345   __Pyx_XDECREF(__pyx_t_8);
8346   __Pyx_AddTraceback("lxml.html.diff.cleanup_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
8347   __pyx_r = NULL;
8348   __pyx_L0:;
8349   __Pyx_XDECREF(__pyx_v_pre_delete);
8350   __Pyx_XDECREF(__pyx_v_delete);
8351   __Pyx_XDECREF(__pyx_v_post_delete);
8352   __Pyx_XDECREF(__pyx_v_unbalanced_start);
8353   __Pyx_XDECREF(__pyx_v_balanced);
8354   __Pyx_XDECREF(__pyx_v_unbalanced_end);
8355   __Pyx_XDECREF(__pyx_v_doc);
8356   __Pyx_XDECREF(__pyx_v_chunks);
8357   __Pyx_XGIVEREF(__pyx_r);
8358   __Pyx_RefNannyFinishContext();
8359   return __pyx_r;
8360 }
8361
8362 /* "lxml/html/diff.py":313
8363  *     return chunks
8364  * 
8365  * def split_unbalanced(chunks):             # <<<<<<<<<<<<<<
8366  *     """Return (unbalanced_start, balanced, unbalanced_end), where each is
8367  *     a list of text and tag chunks.
8368  */
8369
8370 /* Python wrapper */
8371 static PyObject *__pyx_pw_4lxml_4html_4diff_31split_unbalanced(PyObject *__pyx_self, PyObject *__pyx_v_chunks); /*proto*/
8372 static char __pyx_doc_4lxml_4html_4diff_30split_unbalanced[] = "Return (unbalanced_start, balanced, unbalanced_end), where each is\n    a list of text and tag chunks.\n\n    unbalanced_start is a list of all the tags that are opened, but\n    not closed in this span.  Similarly, unbalanced_end is a list of\n    tags that are closed but were not opened.  Extracting these might\n    mean some reordering of the chunks.";
8373 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_31split_unbalanced = {"split_unbalanced", (PyCFunction)__pyx_pw_4lxml_4html_4diff_31split_unbalanced, METH_O, __pyx_doc_4lxml_4html_4diff_30split_unbalanced};
8374 static PyObject *__pyx_pw_4lxml_4html_4diff_31split_unbalanced(PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
8375   PyObject *__pyx_r = 0;
8376   __Pyx_RefNannyDeclarations
8377   __Pyx_RefNannySetupContext("split_unbalanced (wrapper)", 0);
8378   __pyx_r = __pyx_pf_4lxml_4html_4diff_30split_unbalanced(__pyx_self, ((PyObject *)__pyx_v_chunks));
8379
8380   /* function exit code */
8381   __Pyx_RefNannyFinishContext();
8382   return __pyx_r;
8383 }
8384
8385 static PyObject *__pyx_pf_4lxml_4html_4diff_30split_unbalanced(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
8386   PyObject *__pyx_v_start = NULL;
8387   PyObject *__pyx_v_end = NULL;
8388   PyObject *__pyx_v_tag_stack = NULL;
8389   PyObject *__pyx_v_balanced = NULL;
8390   PyObject *__pyx_v_chunk = NULL;
8391   PyObject *__pyx_v_endtag = NULL;
8392   PyObject *__pyx_v_name = NULL;
8393   PyObject *__pyx_v_pos = NULL;
8394   PyObject *__pyx_v_tag = NULL;
8395   CYTHON_UNUSED PyObject *__pyx_8genexpr1__pyx_v_name = NULL;
8396   CYTHON_UNUSED PyObject *__pyx_8genexpr1__pyx_v_pos = NULL;
8397   PyObject *__pyx_8genexpr1__pyx_v_tag = NULL;
8398   CYTHON_UNUSED PyObject *__pyx_8genexpr2__pyx_v_name = NULL;
8399   CYTHON_UNUSED PyObject *__pyx_8genexpr2__pyx_v_pos = NULL;
8400   PyObject *__pyx_8genexpr2__pyx_v_chunk = NULL;
8401   PyObject *__pyx_8genexpr3__pyx_v_chunk = NULL;
8402   PyObject *__pyx_r = NULL;
8403   __Pyx_RefNannyDeclarations
8404   PyObject *__pyx_t_1 = NULL;
8405   Py_ssize_t __pyx_t_2;
8406   PyObject *(*__pyx_t_3)(PyObject *);
8407   PyObject *__pyx_t_4 = NULL;
8408   PyObject *__pyx_t_5 = NULL;
8409   PyObject *__pyx_t_6 = NULL;
8410   int __pyx_t_7;
8411   int __pyx_t_8;
8412   int __pyx_t_9;
8413   PyObject *__pyx_t_10 = NULL;
8414   PyObject *__pyx_t_11 = NULL;
8415   PyObject *(*__pyx_t_12)(PyObject *);
8416   Py_ssize_t __pyx_t_13;
8417   PyObject *__pyx_t_14 = NULL;
8418   PyObject *__pyx_t_15 = NULL;
8419   int __pyx_lineno = 0;
8420   const char *__pyx_filename = NULL;
8421   int __pyx_clineno = 0;
8422   __Pyx_RefNannySetupContext("split_unbalanced", 0);
8423
8424   /* "lxml/html/diff.py":321
8425  *     tags that are closed but were not opened.  Extracting these might
8426  *     mean some reordering of the chunks."""
8427  *     start = []             # <<<<<<<<<<<<<<
8428  *     end = []
8429  *     tag_stack = []
8430  */
8431   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
8432   __Pyx_GOTREF(__pyx_t_1);
8433   __pyx_v_start = ((PyObject*)__pyx_t_1);
8434   __pyx_t_1 = 0;
8435
8436   /* "lxml/html/diff.py":322
8437  *     mean some reordering of the chunks."""
8438  *     start = []
8439  *     end = []             # <<<<<<<<<<<<<<
8440  *     tag_stack = []
8441  *     balanced = []
8442  */
8443   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error)
8444   __Pyx_GOTREF(__pyx_t_1);
8445   __pyx_v_end = ((PyObject*)__pyx_t_1);
8446   __pyx_t_1 = 0;
8447
8448   /* "lxml/html/diff.py":323
8449  *     start = []
8450  *     end = []
8451  *     tag_stack = []             # <<<<<<<<<<<<<<
8452  *     balanced = []
8453  *     for chunk in chunks:
8454  */
8455   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
8456   __Pyx_GOTREF(__pyx_t_1);
8457   __pyx_v_tag_stack = ((PyObject*)__pyx_t_1);
8458   __pyx_t_1 = 0;
8459
8460   /* "lxml/html/diff.py":324
8461  *     end = []
8462  *     tag_stack = []
8463  *     balanced = []             # <<<<<<<<<<<<<<
8464  *     for chunk in chunks:
8465  *         if not chunk.startswith('<'):
8466  */
8467   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error)
8468   __Pyx_GOTREF(__pyx_t_1);
8469   __pyx_v_balanced = ((PyObject*)__pyx_t_1);
8470   __pyx_t_1 = 0;
8471
8472   /* "lxml/html/diff.py":325
8473  *     tag_stack = []
8474  *     balanced = []
8475  *     for chunk in chunks:             # <<<<<<<<<<<<<<
8476  *         if not chunk.startswith('<'):
8477  *             balanced.append(chunk)
8478  */
8479   if (likely(PyList_CheckExact(__pyx_v_chunks)) || PyTuple_CheckExact(__pyx_v_chunks)) {
8480     __pyx_t_1 = __pyx_v_chunks; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
8481     __pyx_t_3 = NULL;
8482   } else {
8483     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chunks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
8484     __Pyx_GOTREF(__pyx_t_1);
8485     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 325, __pyx_L1_error)
8486   }
8487   for (;;) {
8488     if (likely(!__pyx_t_3)) {
8489       if (likely(PyList_CheckExact(__pyx_t_1))) {
8490         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
8491         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8492         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 325, __pyx_L1_error)
8493         #else
8494         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 325, __pyx_L1_error)
8495         __Pyx_GOTREF(__pyx_t_4);
8496         #endif
8497       } else {
8498         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
8499         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8500         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 325, __pyx_L1_error)
8501         #else
8502         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 325, __pyx_L1_error)
8503         __Pyx_GOTREF(__pyx_t_4);
8504         #endif
8505       }
8506     } else {
8507       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
8508       if (unlikely(!__pyx_t_4)) {
8509         PyObject* exc_type = PyErr_Occurred();
8510         if (exc_type) {
8511           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
8512           else __PYX_ERR(0, 325, __pyx_L1_error)
8513         }
8514         break;
8515       }
8516       __Pyx_GOTREF(__pyx_t_4);
8517     }
8518     __Pyx_XDECREF_SET(__pyx_v_chunk, __pyx_t_4);
8519     __pyx_t_4 = 0;
8520
8521     /* "lxml/html/diff.py":326
8522  *     balanced = []
8523  *     for chunk in chunks:
8524  *         if not chunk.startswith('<'):             # <<<<<<<<<<<<<<
8525  *             balanced.append(chunk)
8526  *             continue
8527  */
8528     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_chunk, __pyx_n_s_startswith); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 326, __pyx_L1_error)
8529     __Pyx_GOTREF(__pyx_t_5);
8530     __pyx_t_6 = NULL;
8531     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
8532       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
8533       if (likely(__pyx_t_6)) {
8534         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
8535         __Pyx_INCREF(__pyx_t_6);
8536         __Pyx_INCREF(function);
8537         __Pyx_DECREF_SET(__pyx_t_5, function);
8538       }
8539     }
8540     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u__8);
8541     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
8542     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
8543     __Pyx_GOTREF(__pyx_t_4);
8544     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8545     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 326, __pyx_L1_error)
8546     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8547     __pyx_t_8 = ((!__pyx_t_7) != 0);
8548     if (__pyx_t_8) {
8549
8550       /* "lxml/html/diff.py":327
8551  *     for chunk in chunks:
8552  *         if not chunk.startswith('<'):
8553  *             balanced.append(chunk)             # <<<<<<<<<<<<<<
8554  *             continue
8555  *         endtag = chunk[1] == '/'
8556  */
8557       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_balanced, __pyx_v_chunk); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 327, __pyx_L1_error)
8558
8559       /* "lxml/html/diff.py":328
8560  *         if not chunk.startswith('<'):
8561  *             balanced.append(chunk)
8562  *             continue             # <<<<<<<<<<<<<<
8563  *         endtag = chunk[1] == '/'
8564  *         name = chunk.split()[0].strip('<>/')
8565  */
8566       goto __pyx_L3_continue;
8567
8568       /* "lxml/html/diff.py":326
8569  *     balanced = []
8570  *     for chunk in chunks:
8571  *         if not chunk.startswith('<'):             # <<<<<<<<<<<<<<
8572  *             balanced.append(chunk)
8573  *             continue
8574  */
8575     }
8576
8577     /* "lxml/html/diff.py":329
8578  *             balanced.append(chunk)
8579  *             continue
8580  *         endtag = chunk[1] == '/'             # <<<<<<<<<<<<<<
8581  *         name = chunk.split()[0].strip('<>/')
8582  *         if name in empty_tags:
8583  */
8584     __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_chunk, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
8585     __Pyx_GOTREF(__pyx_t_4);
8586     __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_kp_u__9, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 329, __pyx_L1_error)
8587     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8588     __Pyx_XDECREF_SET(__pyx_v_endtag, __pyx_t_5);
8589     __pyx_t_5 = 0;
8590
8591     /* "lxml/html/diff.py":330
8592  *             continue
8593  *         endtag = chunk[1] == '/'
8594  *         name = chunk.split()[0].strip('<>/')             # <<<<<<<<<<<<<<
8595  *         if name in empty_tags:
8596  *             balanced.append(chunk)
8597  */
8598     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_chunk, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 330, __pyx_L1_error)
8599     __Pyx_GOTREF(__pyx_t_6);
8600     __pyx_t_10 = NULL;
8601     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
8602       __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
8603       if (likely(__pyx_t_10)) {
8604         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
8605         __Pyx_INCREF(__pyx_t_10);
8606         __Pyx_INCREF(function);
8607         __Pyx_DECREF_SET(__pyx_t_6, function);
8608       }
8609     }
8610     __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
8611     __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
8612     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 330, __pyx_L1_error)
8613     __Pyx_GOTREF(__pyx_t_4);
8614     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8615     __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 330, __pyx_L1_error)
8616     __Pyx_GOTREF(__pyx_t_6);
8617     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8618     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 330, __pyx_L1_error)
8619     __Pyx_GOTREF(__pyx_t_4);
8620     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8621     __pyx_t_6 = NULL;
8622     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
8623       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
8624       if (likely(__pyx_t_6)) {
8625         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
8626         __Pyx_INCREF(__pyx_t_6);
8627         __Pyx_INCREF(function);
8628         __Pyx_DECREF_SET(__pyx_t_4, function);
8629       }
8630     }
8631     __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_kp_u__10) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__10);
8632     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
8633     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 330, __pyx_L1_error)
8634     __Pyx_GOTREF(__pyx_t_5);
8635     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8636     __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5);
8637     __pyx_t_5 = 0;
8638
8639     /* "lxml/html/diff.py":331
8640  *         endtag = chunk[1] == '/'
8641  *         name = chunk.split()[0].strip('<>/')
8642  *         if name in empty_tags:             # <<<<<<<<<<<<<<
8643  *             balanced.append(chunk)
8644  *             continue
8645  */
8646     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_empty_tags); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 331, __pyx_L1_error)
8647     __Pyx_GOTREF(__pyx_t_5);
8648     __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_t_5, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 331, __pyx_L1_error)
8649     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8650     __pyx_t_7 = (__pyx_t_8 != 0);
8651     if (__pyx_t_7) {
8652
8653       /* "lxml/html/diff.py":332
8654  *         name = chunk.split()[0].strip('<>/')
8655  *         if name in empty_tags:
8656  *             balanced.append(chunk)             # <<<<<<<<<<<<<<
8657  *             continue
8658  *         if endtag:
8659  */
8660       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_balanced, __pyx_v_chunk); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 332, __pyx_L1_error)
8661
8662       /* "lxml/html/diff.py":333
8663  *         if name in empty_tags:
8664  *             balanced.append(chunk)
8665  *             continue             # <<<<<<<<<<<<<<
8666  *         if endtag:
8667  *             if tag_stack and tag_stack[-1][0] == name:
8668  */
8669       goto __pyx_L3_continue;
8670
8671       /* "lxml/html/diff.py":331
8672  *         endtag = chunk[1] == '/'
8673  *         name = chunk.split()[0].strip('<>/')
8674  *         if name in empty_tags:             # <<<<<<<<<<<<<<
8675  *             balanced.append(chunk)
8676  *             continue
8677  */
8678     }
8679
8680     /* "lxml/html/diff.py":334
8681  *             balanced.append(chunk)
8682  *             continue
8683  *         if endtag:             # <<<<<<<<<<<<<<
8684  *             if tag_stack and tag_stack[-1][0] == name:
8685  *                 balanced.append(chunk)
8686  */
8687     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_endtag); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 334, __pyx_L1_error)
8688     if (__pyx_t_7) {
8689
8690       /* "lxml/html/diff.py":335
8691  *             continue
8692  *         if endtag:
8693  *             if tag_stack and tag_stack[-1][0] == name:             # <<<<<<<<<<<<<<
8694  *                 balanced.append(chunk)
8695  *                 name, pos, tag = tag_stack.pop()
8696  */
8697       __pyx_t_8 = (PyList_GET_SIZE(__pyx_v_tag_stack) != 0);
8698       if (__pyx_t_8) {
8699       } else {
8700         __pyx_t_7 = __pyx_t_8;
8701         goto __pyx_L9_bool_binop_done;
8702       }
8703       __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_tag_stack, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 335, __pyx_L1_error)
8704       __Pyx_GOTREF(__pyx_t_5);
8705       __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 335, __pyx_L1_error)
8706       __Pyx_GOTREF(__pyx_t_4);
8707       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8708       __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_v_name, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 335, __pyx_L1_error)
8709       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8710       __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 335, __pyx_L1_error)
8711       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8712       __pyx_t_7 = __pyx_t_8;
8713       __pyx_L9_bool_binop_done:;
8714       if (__pyx_t_7) {
8715
8716         /* "lxml/html/diff.py":336
8717  *         if endtag:
8718  *             if tag_stack and tag_stack[-1][0] == name:
8719  *                 balanced.append(chunk)             # <<<<<<<<<<<<<<
8720  *                 name, pos, tag = tag_stack.pop()
8721  *                 balanced[pos] = tag
8722  */
8723         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_balanced, __pyx_v_chunk); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
8724
8725         /* "lxml/html/diff.py":337
8726  *             if tag_stack and tag_stack[-1][0] == name:
8727  *                 balanced.append(chunk)
8728  *                 name, pos, tag = tag_stack.pop()             # <<<<<<<<<<<<<<
8729  *                 balanced[pos] = tag
8730  *             elif tag_stack:
8731  */
8732         __pyx_t_5 = __Pyx_PyList_Pop(__pyx_v_tag_stack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 337, __pyx_L1_error)
8733         __Pyx_GOTREF(__pyx_t_5);
8734         if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
8735           PyObject* sequence = __pyx_t_5;
8736           Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8737           if (unlikely(size != 3)) {
8738             if (size > 3) __Pyx_RaiseTooManyValuesError(3);
8739             else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8740             __PYX_ERR(0, 337, __pyx_L1_error)
8741           }
8742           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8743           if (likely(PyTuple_CheckExact(sequence))) {
8744             __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
8745             __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
8746             __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
8747           } else {
8748             __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
8749             __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
8750             __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
8751           }
8752           __Pyx_INCREF(__pyx_t_4);
8753           __Pyx_INCREF(__pyx_t_6);
8754           __Pyx_INCREF(__pyx_t_10);
8755           #else
8756           __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 337, __pyx_L1_error)
8757           __Pyx_GOTREF(__pyx_t_4);
8758           __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 337, __pyx_L1_error)
8759           __Pyx_GOTREF(__pyx_t_6);
8760           __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 337, __pyx_L1_error)
8761           __Pyx_GOTREF(__pyx_t_10);
8762           #endif
8763           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8764         } else {
8765           Py_ssize_t index = -1;
8766           __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 337, __pyx_L1_error)
8767           __Pyx_GOTREF(__pyx_t_11);
8768           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8769           __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
8770           index = 0; __pyx_t_4 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L11_unpacking_failed;
8771           __Pyx_GOTREF(__pyx_t_4);
8772           index = 1; __pyx_t_6 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
8773           __Pyx_GOTREF(__pyx_t_6);
8774           index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed;
8775           __Pyx_GOTREF(__pyx_t_10);
8776           if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 337, __pyx_L1_error)
8777           __pyx_t_12 = NULL;
8778           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8779           goto __pyx_L12_unpacking_done;
8780           __pyx_L11_unpacking_failed:;
8781           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8782           __pyx_t_12 = NULL;
8783           if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8784           __PYX_ERR(0, 337, __pyx_L1_error)
8785           __pyx_L12_unpacking_done:;
8786         }
8787         __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4);
8788         __pyx_t_4 = 0;
8789         __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_6);
8790         __pyx_t_6 = 0;
8791         __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_10);
8792         __pyx_t_10 = 0;
8793
8794         /* "lxml/html/diff.py":338
8795  *                 balanced.append(chunk)
8796  *                 name, pos, tag = tag_stack.pop()
8797  *                 balanced[pos] = tag             # <<<<<<<<<<<<<<
8798  *             elif tag_stack:
8799  *                 start.extend([tag for name, pos, tag in tag_stack])
8800  */
8801         if (unlikely(PyObject_SetItem(__pyx_v_balanced, __pyx_v_pos, __pyx_v_tag) < 0)) __PYX_ERR(0, 338, __pyx_L1_error)
8802
8803         /* "lxml/html/diff.py":335
8804  *             continue
8805  *         if endtag:
8806  *             if tag_stack and tag_stack[-1][0] == name:             # <<<<<<<<<<<<<<
8807  *                 balanced.append(chunk)
8808  *                 name, pos, tag = tag_stack.pop()
8809  */
8810         goto __pyx_L8;
8811       }
8812
8813       /* "lxml/html/diff.py":339
8814  *                 name, pos, tag = tag_stack.pop()
8815  *                 balanced[pos] = tag
8816  *             elif tag_stack:             # <<<<<<<<<<<<<<
8817  *                 start.extend([tag for name, pos, tag in tag_stack])
8818  *                 tag_stack = []
8819  */
8820       __pyx_t_7 = (PyList_GET_SIZE(__pyx_v_tag_stack) != 0);
8821       if (__pyx_t_7) {
8822
8823         /* "lxml/html/diff.py":340
8824  *                 balanced[pos] = tag
8825  *             elif tag_stack:
8826  *                 start.extend([tag for name, pos, tag in tag_stack])             # <<<<<<<<<<<<<<
8827  *                 tag_stack = []
8828  *                 end.append(chunk)
8829  */
8830         { /* enter inner scope */
8831           __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 340, __pyx_L15_error)
8832           __Pyx_GOTREF(__pyx_t_5);
8833           __pyx_t_10 = __pyx_v_tag_stack; __Pyx_INCREF(__pyx_t_10); __pyx_t_13 = 0;
8834           for (;;) {
8835             if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_10)) break;
8836             #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8837             __pyx_t_6 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 340, __pyx_L15_error)
8838             #else
8839             __pyx_t_6 = PySequence_ITEM(__pyx_t_10, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L15_error)
8840             __Pyx_GOTREF(__pyx_t_6);
8841             #endif
8842             if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
8843               PyObject* sequence = __pyx_t_6;
8844               Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8845               if (unlikely(size != 3)) {
8846                 if (size > 3) __Pyx_RaiseTooManyValuesError(3);
8847                 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8848                 __PYX_ERR(0, 340, __pyx_L15_error)
8849               }
8850               #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8851               if (likely(PyTuple_CheckExact(sequence))) {
8852                 __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
8853                 __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
8854                 __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); 
8855               } else {
8856                 __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
8857                 __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
8858                 __pyx_t_14 = PyList_GET_ITEM(sequence, 2); 
8859               }
8860               __Pyx_INCREF(__pyx_t_4);
8861               __Pyx_INCREF(__pyx_t_11);
8862               __Pyx_INCREF(__pyx_t_14);
8863               #else
8864               __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L15_error)
8865               __Pyx_GOTREF(__pyx_t_4);
8866               __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 340, __pyx_L15_error)
8867               __Pyx_GOTREF(__pyx_t_11);
8868               __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 340, __pyx_L15_error)
8869               __Pyx_GOTREF(__pyx_t_14);
8870               #endif
8871               __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8872             } else {
8873               Py_ssize_t index = -1;
8874               __pyx_t_15 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 340, __pyx_L15_error)
8875               __Pyx_GOTREF(__pyx_t_15);
8876               __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8877               __pyx_t_12 = Py_TYPE(__pyx_t_15)->tp_iternext;
8878               index = 0; __pyx_t_4 = __pyx_t_12(__pyx_t_15); if (unlikely(!__pyx_t_4)) goto __pyx_L18_unpacking_failed;
8879               __Pyx_GOTREF(__pyx_t_4);
8880               index = 1; __pyx_t_11 = __pyx_t_12(__pyx_t_15); if (unlikely(!__pyx_t_11)) goto __pyx_L18_unpacking_failed;
8881               __Pyx_GOTREF(__pyx_t_11);
8882               index = 2; __pyx_t_14 = __pyx_t_12(__pyx_t_15); if (unlikely(!__pyx_t_14)) goto __pyx_L18_unpacking_failed;
8883               __Pyx_GOTREF(__pyx_t_14);
8884               if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_15), 3) < 0) __PYX_ERR(0, 340, __pyx_L15_error)
8885               __pyx_t_12 = NULL;
8886               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8887               goto __pyx_L19_unpacking_done;
8888               __pyx_L18_unpacking_failed:;
8889               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8890               __pyx_t_12 = NULL;
8891               if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8892               __PYX_ERR(0, 340, __pyx_L15_error)
8893               __pyx_L19_unpacking_done:;
8894             }
8895             __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_name, __pyx_t_4);
8896             __pyx_t_4 = 0;
8897             __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_pos, __pyx_t_11);
8898             __pyx_t_11 = 0;
8899             __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_tag, __pyx_t_14);
8900             __pyx_t_14 = 0;
8901             if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_8genexpr1__pyx_v_tag))) __PYX_ERR(0, 340, __pyx_L15_error)
8902           }
8903           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8904           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_name); __pyx_8genexpr1__pyx_v_name = 0;
8905           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_pos); __pyx_8genexpr1__pyx_v_pos = 0;
8906           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_tag); __pyx_8genexpr1__pyx_v_tag = 0;
8907           goto __pyx_L20_exit_scope;
8908           __pyx_L15_error:;
8909           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_name); __pyx_8genexpr1__pyx_v_name = 0;
8910           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_pos); __pyx_8genexpr1__pyx_v_pos = 0;
8911           __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_tag); __pyx_8genexpr1__pyx_v_tag = 0;
8912           goto __pyx_L1_error;
8913           __pyx_L20_exit_scope:;
8914         } /* exit inner scope */
8915         __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_start, __pyx_t_5); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 340, __pyx_L1_error)
8916         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8917
8918         /* "lxml/html/diff.py":341
8919  *             elif tag_stack:
8920  *                 start.extend([tag for name, pos, tag in tag_stack])
8921  *                 tag_stack = []             # <<<<<<<<<<<<<<
8922  *                 end.append(chunk)
8923  *             else:
8924  */
8925         __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 341, __pyx_L1_error)
8926         __Pyx_GOTREF(__pyx_t_5);
8927         __Pyx_DECREF_SET(__pyx_v_tag_stack, ((PyObject*)__pyx_t_5));
8928         __pyx_t_5 = 0;
8929
8930         /* "lxml/html/diff.py":342
8931  *                 start.extend([tag for name, pos, tag in tag_stack])
8932  *                 tag_stack = []
8933  *                 end.append(chunk)             # <<<<<<<<<<<<<<
8934  *             else:
8935  *                 end.append(chunk)
8936  */
8937         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_end, __pyx_v_chunk); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 342, __pyx_L1_error)
8938
8939         /* "lxml/html/diff.py":339
8940  *                 name, pos, tag = tag_stack.pop()
8941  *                 balanced[pos] = tag
8942  *             elif tag_stack:             # <<<<<<<<<<<<<<
8943  *                 start.extend([tag for name, pos, tag in tag_stack])
8944  *                 tag_stack = []
8945  */
8946         goto __pyx_L8;
8947       }
8948
8949       /* "lxml/html/diff.py":344
8950  *                 end.append(chunk)
8951  *             else:
8952  *                 end.append(chunk)             # <<<<<<<<<<<<<<
8953  *         else:
8954  *             tag_stack.append((name, len(balanced), chunk))
8955  */
8956       /*else*/ {
8957         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_end, __pyx_v_chunk); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 344, __pyx_L1_error)
8958       }
8959       __pyx_L8:;
8960
8961       /* "lxml/html/diff.py":334
8962  *             balanced.append(chunk)
8963  *             continue
8964  *         if endtag:             # <<<<<<<<<<<<<<
8965  *             if tag_stack and tag_stack[-1][0] == name:
8966  *                 balanced.append(chunk)
8967  */
8968       goto __pyx_L7;
8969     }
8970
8971     /* "lxml/html/diff.py":346
8972  *                 end.append(chunk)
8973  *         else:
8974  *             tag_stack.append((name, len(balanced), chunk))             # <<<<<<<<<<<<<<
8975  *             balanced.append(None)
8976  *     start.extend(
8977  */
8978     /*else*/ {
8979       __pyx_t_13 = PyList_GET_SIZE(__pyx_v_balanced); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 346, __pyx_L1_error)
8980       __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L1_error)
8981       __Pyx_GOTREF(__pyx_t_5);
8982       __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 346, __pyx_L1_error)
8983       __Pyx_GOTREF(__pyx_t_10);
8984       __Pyx_INCREF(__pyx_v_name);
8985       __Pyx_GIVEREF(__pyx_v_name);
8986       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_name);
8987       __Pyx_GIVEREF(__pyx_t_5);
8988       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5);
8989       __Pyx_INCREF(__pyx_v_chunk);
8990       __Pyx_GIVEREF(__pyx_v_chunk);
8991       PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_chunk);
8992       __pyx_t_5 = 0;
8993       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_tag_stack, __pyx_t_10); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 346, __pyx_L1_error)
8994       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8995
8996       /* "lxml/html/diff.py":347
8997  *         else:
8998  *             tag_stack.append((name, len(balanced), chunk))
8999  *             balanced.append(None)             # <<<<<<<<<<<<<<
9000  *     start.extend(
9001  *         [chunk for name, pos, chunk in tag_stack])
9002  */
9003       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_balanced, Py_None); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 347, __pyx_L1_error)
9004     }
9005     __pyx_L7:;
9006
9007     /* "lxml/html/diff.py":325
9008  *     tag_stack = []
9009  *     balanced = []
9010  *     for chunk in chunks:             # <<<<<<<<<<<<<<
9011  *         if not chunk.startswith('<'):
9012  *             balanced.append(chunk)
9013  */
9014     __pyx_L3_continue:;
9015   }
9016   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9017
9018   /* "lxml/html/diff.py":348
9019  *             tag_stack.append((name, len(balanced), chunk))
9020  *             balanced.append(None)
9021  *     start.extend(             # <<<<<<<<<<<<<<
9022  *         [chunk for name, pos, chunk in tag_stack])
9023  *     balanced = [chunk for chunk in balanced if chunk is not None]
9024  */
9025   { /* enter inner scope */
9026
9027     /* "lxml/html/diff.py":349
9028  *             balanced.append(None)
9029  *     start.extend(
9030  *         [chunk for name, pos, chunk in tag_stack])             # <<<<<<<<<<<<<<
9031  *     balanced = [chunk for chunk in balanced if chunk is not None]
9032  *     return start, balanced, end
9033  */
9034     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L23_error)
9035     __Pyx_GOTREF(__pyx_t_1);
9036     __pyx_t_10 = __pyx_v_tag_stack; __Pyx_INCREF(__pyx_t_10); __pyx_t_2 = 0;
9037     for (;;) {
9038       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_10)) break;
9039       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9040       __pyx_t_5 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 349, __pyx_L23_error)
9041       #else
9042       __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L23_error)
9043       __Pyx_GOTREF(__pyx_t_5);
9044       #endif
9045       if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
9046         PyObject* sequence = __pyx_t_5;
9047         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
9048         if (unlikely(size != 3)) {
9049           if (size > 3) __Pyx_RaiseTooManyValuesError(3);
9050           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
9051           __PYX_ERR(0, 349, __pyx_L23_error)
9052         }
9053         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9054         if (likely(PyTuple_CheckExact(sequence))) {
9055           __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
9056           __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); 
9057           __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
9058         } else {
9059           __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
9060           __pyx_t_14 = PyList_GET_ITEM(sequence, 1); 
9061           __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
9062         }
9063         __Pyx_INCREF(__pyx_t_6);
9064         __Pyx_INCREF(__pyx_t_14);
9065         __Pyx_INCREF(__pyx_t_11);
9066         #else
9067         __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L23_error)
9068         __Pyx_GOTREF(__pyx_t_6);
9069         __pyx_t_14 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 349, __pyx_L23_error)
9070         __Pyx_GOTREF(__pyx_t_14);
9071         __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 349, __pyx_L23_error)
9072         __Pyx_GOTREF(__pyx_t_11);
9073         #endif
9074         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9075       } else {
9076         Py_ssize_t index = -1;
9077         __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 349, __pyx_L23_error)
9078         __Pyx_GOTREF(__pyx_t_4);
9079         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9080         __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext;
9081         index = 0; __pyx_t_6 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L26_unpacking_failed;
9082         __Pyx_GOTREF(__pyx_t_6);
9083         index = 1; __pyx_t_14 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_14)) goto __pyx_L26_unpacking_failed;
9084         __Pyx_GOTREF(__pyx_t_14);
9085         index = 2; __pyx_t_11 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_11)) goto __pyx_L26_unpacking_failed;
9086         __Pyx_GOTREF(__pyx_t_11);
9087         if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_4), 3) < 0) __PYX_ERR(0, 349, __pyx_L23_error)
9088         __pyx_t_12 = NULL;
9089         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9090         goto __pyx_L27_unpacking_done;
9091         __pyx_L26_unpacking_failed:;
9092         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9093         __pyx_t_12 = NULL;
9094         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
9095         __PYX_ERR(0, 349, __pyx_L23_error)
9096         __pyx_L27_unpacking_done:;
9097       }
9098       __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_name, __pyx_t_6);
9099       __pyx_t_6 = 0;
9100       __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_pos, __pyx_t_14);
9101       __pyx_t_14 = 0;
9102       __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_chunk, __pyx_t_11);
9103       __pyx_t_11 = 0;
9104       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_8genexpr2__pyx_v_chunk))) __PYX_ERR(0, 349, __pyx_L23_error)
9105     }
9106     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
9107     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_chunk); __pyx_8genexpr2__pyx_v_chunk = 0;
9108     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_name); __pyx_8genexpr2__pyx_v_name = 0;
9109     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_pos); __pyx_8genexpr2__pyx_v_pos = 0;
9110     goto __pyx_L28_exit_scope;
9111     __pyx_L23_error:;
9112     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_chunk); __pyx_8genexpr2__pyx_v_chunk = 0;
9113     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_name); __pyx_8genexpr2__pyx_v_name = 0;
9114     __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_pos); __pyx_8genexpr2__pyx_v_pos = 0;
9115     goto __pyx_L1_error;
9116     __pyx_L28_exit_scope:;
9117   } /* exit inner scope */
9118
9119   /* "lxml/html/diff.py":348
9120  *             tag_stack.append((name, len(balanced), chunk))
9121  *             balanced.append(None)
9122  *     start.extend(             # <<<<<<<<<<<<<<
9123  *         [chunk for name, pos, chunk in tag_stack])
9124  *     balanced = [chunk for chunk in balanced if chunk is not None]
9125  */
9126   __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_start, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 348, __pyx_L1_error)
9127   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9128
9129   /* "lxml/html/diff.py":350
9130  *     start.extend(
9131  *         [chunk for name, pos, chunk in tag_stack])
9132  *     balanced = [chunk for chunk in balanced if chunk is not None]             # <<<<<<<<<<<<<<
9133  *     return start, balanced, end
9134  * 
9135  */
9136   { /* enter inner scope */
9137     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L31_error)
9138     __Pyx_GOTREF(__pyx_t_1);
9139     __pyx_t_10 = __pyx_v_balanced; __Pyx_INCREF(__pyx_t_10); __pyx_t_2 = 0;
9140     for (;;) {
9141       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_10)) break;
9142       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9143       __pyx_t_5 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 350, __pyx_L31_error)
9144       #else
9145       __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 350, __pyx_L31_error)
9146       __Pyx_GOTREF(__pyx_t_5);
9147       #endif
9148       __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_chunk, __pyx_t_5);
9149       __pyx_t_5 = 0;
9150       __pyx_t_7 = (__pyx_8genexpr3__pyx_v_chunk != Py_None);
9151       __pyx_t_8 = (__pyx_t_7 != 0);
9152       if (__pyx_t_8) {
9153         if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_8genexpr3__pyx_v_chunk))) __PYX_ERR(0, 350, __pyx_L31_error)
9154       }
9155     }
9156     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
9157     __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_chunk); __pyx_8genexpr3__pyx_v_chunk = 0;
9158     goto __pyx_L35_exit_scope;
9159     __pyx_L31_error:;
9160     __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_chunk); __pyx_8genexpr3__pyx_v_chunk = 0;
9161     goto __pyx_L1_error;
9162     __pyx_L35_exit_scope:;
9163   } /* exit inner scope */
9164   __Pyx_DECREF_SET(__pyx_v_balanced, ((PyObject*)__pyx_t_1));
9165   __pyx_t_1 = 0;
9166
9167   /* "lxml/html/diff.py":351
9168  *         [chunk for name, pos, chunk in tag_stack])
9169  *     balanced = [chunk for chunk in balanced if chunk is not None]
9170  *     return start, balanced, end             # <<<<<<<<<<<<<<
9171  * 
9172  * def split_delete(chunks):
9173  */
9174   __Pyx_XDECREF(__pyx_r);
9175   __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error)
9176   __Pyx_GOTREF(__pyx_t_1);
9177   __Pyx_INCREF(__pyx_v_start);
9178   __Pyx_GIVEREF(__pyx_v_start);
9179   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_start);
9180   __Pyx_INCREF(__pyx_v_balanced);
9181   __Pyx_GIVEREF(__pyx_v_balanced);
9182   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_balanced);
9183   __Pyx_INCREF(__pyx_v_end);
9184   __Pyx_GIVEREF(__pyx_v_end);
9185   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
9186   __pyx_r = __pyx_t_1;
9187   __pyx_t_1 = 0;
9188   goto __pyx_L0;
9189
9190   /* "lxml/html/diff.py":313
9191  *     return chunks
9192  * 
9193  * def split_unbalanced(chunks):             # <<<<<<<<<<<<<<
9194  *     """Return (unbalanced_start, balanced, unbalanced_end), where each is
9195  *     a list of text and tag chunks.
9196  */
9197
9198   /* function exit code */
9199   __pyx_L1_error:;
9200   __Pyx_XDECREF(__pyx_t_1);
9201   __Pyx_XDECREF(__pyx_t_4);
9202   __Pyx_XDECREF(__pyx_t_5);
9203   __Pyx_XDECREF(__pyx_t_6);
9204   __Pyx_XDECREF(__pyx_t_10);
9205   __Pyx_XDECREF(__pyx_t_11);
9206   __Pyx_XDECREF(__pyx_t_14);
9207   __Pyx_XDECREF(__pyx_t_15);
9208   __Pyx_AddTraceback("lxml.html.diff.split_unbalanced", __pyx_clineno, __pyx_lineno, __pyx_filename);
9209   __pyx_r = NULL;
9210   __pyx_L0:;
9211   __Pyx_XDECREF(__pyx_v_start);
9212   __Pyx_XDECREF(__pyx_v_end);
9213   __Pyx_XDECREF(__pyx_v_tag_stack);
9214   __Pyx_XDECREF(__pyx_v_balanced);
9215   __Pyx_XDECREF(__pyx_v_chunk);
9216   __Pyx_XDECREF(__pyx_v_endtag);
9217   __Pyx_XDECREF(__pyx_v_name);
9218   __Pyx_XDECREF(__pyx_v_pos);
9219   __Pyx_XDECREF(__pyx_v_tag);
9220   __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_name);
9221   __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_pos);
9222   __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_tag);
9223   __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_name);
9224   __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_pos);
9225   __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_chunk);
9226   __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_chunk);
9227   __Pyx_XGIVEREF(__pyx_r);
9228   __Pyx_RefNannyFinishContext();
9229   return __pyx_r;
9230 }
9231
9232 /* "lxml/html/diff.py":353
9233  *     return start, balanced, end
9234  * 
9235  * def split_delete(chunks):             # <<<<<<<<<<<<<<
9236  *     """ Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
9237  *     stuff_after_DEL_END).  Returns the first case found (there may be
9238  */
9239
9240 /* Python wrapper */
9241 static PyObject *__pyx_pw_4lxml_4html_4diff_33split_delete(PyObject *__pyx_self, PyObject *__pyx_v_chunks); /*proto*/
9242 static char __pyx_doc_4lxml_4html_4diff_32split_delete[] = " Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,\n    stuff_after_DEL_END).  Returns the first case found (there may be\n    more DEL_STARTs in stuff_after_DEL_END).  Raises NoDeletes if\n    there's no DEL_START found. ";
9243 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_33split_delete = {"split_delete", (PyCFunction)__pyx_pw_4lxml_4html_4diff_33split_delete, METH_O, __pyx_doc_4lxml_4html_4diff_32split_delete};
9244 static PyObject *__pyx_pw_4lxml_4html_4diff_33split_delete(PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
9245   PyObject *__pyx_r = 0;
9246   __Pyx_RefNannyDeclarations
9247   __Pyx_RefNannySetupContext("split_delete (wrapper)", 0);
9248   __pyx_r = __pyx_pf_4lxml_4html_4diff_32split_delete(__pyx_self, ((PyObject *)__pyx_v_chunks));
9249
9250   /* function exit code */
9251   __Pyx_RefNannyFinishContext();
9252   return __pyx_r;
9253 }
9254
9255 static PyObject *__pyx_pf_4lxml_4html_4diff_32split_delete(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
9256   PyObject *__pyx_v_pos = NULL;
9257   PyObject *__pyx_v_pos2 = NULL;
9258   PyObject *__pyx_r = NULL;
9259   __Pyx_RefNannyDeclarations
9260   PyObject *__pyx_t_1 = NULL;
9261   PyObject *__pyx_t_2 = NULL;
9262   PyObject *__pyx_t_3 = NULL;
9263   PyObject *__pyx_t_4 = NULL;
9264   PyObject *__pyx_t_5 = NULL;
9265   PyObject *__pyx_t_6 = NULL;
9266   PyObject *__pyx_t_7 = NULL;
9267   int __pyx_t_8;
9268   int __pyx_lineno = 0;
9269   const char *__pyx_filename = NULL;
9270   int __pyx_clineno = 0;
9271   __Pyx_RefNannySetupContext("split_delete", 0);
9272
9273   /* "lxml/html/diff.py":358
9274  *     more DEL_STARTs in stuff_after_DEL_END).  Raises NoDeletes if
9275  *     there's no DEL_START found. """
9276  *     try:             # <<<<<<<<<<<<<<
9277  *         pos = chunks.index(DEL_START)
9278  *     except ValueError:
9279  */
9280   {
9281     __Pyx_PyThreadState_declare
9282     __Pyx_PyThreadState_assign
9283     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
9284     __Pyx_XGOTREF(__pyx_t_1);
9285     __Pyx_XGOTREF(__pyx_t_2);
9286     __Pyx_XGOTREF(__pyx_t_3);
9287     /*try:*/ {
9288
9289       /* "lxml/html/diff.py":359
9290  *     there's no DEL_START found. """
9291  *     try:
9292  *         pos = chunks.index(DEL_START)             # <<<<<<<<<<<<<<
9293  *     except ValueError:
9294  *         raise NoDeletes
9295  */
9296       __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_chunks, __pyx_n_s_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 359, __pyx_L3_error)
9297       __Pyx_GOTREF(__pyx_t_5);
9298       __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DEL_START); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 359, __pyx_L3_error)
9299       __Pyx_GOTREF(__pyx_t_6);
9300       __pyx_t_7 = NULL;
9301       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
9302         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
9303         if (likely(__pyx_t_7)) {
9304           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9305           __Pyx_INCREF(__pyx_t_7);
9306           __Pyx_INCREF(function);
9307           __Pyx_DECREF_SET(__pyx_t_5, function);
9308         }
9309       }
9310       __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
9311       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9312       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9313       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 359, __pyx_L3_error)
9314       __Pyx_GOTREF(__pyx_t_4);
9315       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9316       __pyx_v_pos = __pyx_t_4;
9317       __pyx_t_4 = 0;
9318
9319       /* "lxml/html/diff.py":358
9320  *     more DEL_STARTs in stuff_after_DEL_END).  Raises NoDeletes if
9321  *     there's no DEL_START found. """
9322  *     try:             # <<<<<<<<<<<<<<
9323  *         pos = chunks.index(DEL_START)
9324  *     except ValueError:
9325  */
9326     }
9327     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9328     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9329     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9330     goto __pyx_L8_try_end;
9331     __pyx_L3_error:;
9332     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9333     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9334     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
9335     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9336
9337     /* "lxml/html/diff.py":360
9338  *     try:
9339  *         pos = chunks.index(DEL_START)
9340  *     except ValueError:             # <<<<<<<<<<<<<<
9341  *         raise NoDeletes
9342  *     pos2 = chunks.index(DEL_END)
9343  */
9344     __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
9345     if (__pyx_t_8) {
9346       __Pyx_AddTraceback("lxml.html.diff.split_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
9347       if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 360, __pyx_L5_except_error)
9348       __Pyx_GOTREF(__pyx_t_4);
9349       __Pyx_GOTREF(__pyx_t_5);
9350       __Pyx_GOTREF(__pyx_t_6);
9351
9352       /* "lxml/html/diff.py":361
9353  *         pos = chunks.index(DEL_START)
9354  *     except ValueError:
9355  *         raise NoDeletes             # <<<<<<<<<<<<<<
9356  *     pos2 = chunks.index(DEL_END)
9357  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
9358  */
9359       __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_NoDeletes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 361, __pyx_L5_except_error)
9360       __Pyx_GOTREF(__pyx_t_7);
9361       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
9362       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9363       __PYX_ERR(0, 361, __pyx_L5_except_error)
9364     }
9365     goto __pyx_L5_except_error;
9366     __pyx_L5_except_error:;
9367
9368     /* "lxml/html/diff.py":358
9369  *     more DEL_STARTs in stuff_after_DEL_END).  Raises NoDeletes if
9370  *     there's no DEL_START found. """
9371  *     try:             # <<<<<<<<<<<<<<
9372  *         pos = chunks.index(DEL_START)
9373  *     except ValueError:
9374  */
9375     __Pyx_XGIVEREF(__pyx_t_1);
9376     __Pyx_XGIVEREF(__pyx_t_2);
9377     __Pyx_XGIVEREF(__pyx_t_3);
9378     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
9379     goto __pyx_L1_error;
9380     __pyx_L8_try_end:;
9381   }
9382
9383   /* "lxml/html/diff.py":362
9384  *     except ValueError:
9385  *         raise NoDeletes
9386  *     pos2 = chunks.index(DEL_END)             # <<<<<<<<<<<<<<
9387  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
9388  * 
9389  */
9390   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_chunks, __pyx_n_s_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 362, __pyx_L1_error)
9391   __Pyx_GOTREF(__pyx_t_5);
9392   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DEL_END); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __pyx_L1_error)
9393   __Pyx_GOTREF(__pyx_t_4);
9394   __pyx_t_7 = NULL;
9395   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
9396     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
9397     if (likely(__pyx_t_7)) {
9398       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9399       __Pyx_INCREF(__pyx_t_7);
9400       __Pyx_INCREF(function);
9401       __Pyx_DECREF_SET(__pyx_t_5, function);
9402     }
9403   }
9404   __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
9405   __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9406   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9407   if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 362, __pyx_L1_error)
9408   __Pyx_GOTREF(__pyx_t_6);
9409   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9410   __pyx_v_pos2 = __pyx_t_6;
9411   __pyx_t_6 = 0;
9412
9413   /* "lxml/html/diff.py":363
9414  *         raise NoDeletes
9415  *     pos2 = chunks.index(DEL_END)
9416  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]             # <<<<<<<<<<<<<<
9417  * 
9418  * def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):
9419  */
9420   __Pyx_XDECREF(__pyx_r);
9421   __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_chunks, 0, 0, NULL, &__pyx_v_pos, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 363, __pyx_L1_error)
9422   __Pyx_GOTREF(__pyx_t_6);
9423   __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_v_pos, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error)
9424   __Pyx_GOTREF(__pyx_t_5);
9425   __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_chunks, 0, 0, &__pyx_t_5, &__pyx_v_pos2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 363, __pyx_L1_error)
9426   __Pyx_GOTREF(__pyx_t_4);
9427   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9428   __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_v_pos2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error)
9429   __Pyx_GOTREF(__pyx_t_5);
9430   __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_chunks, 0, 0, &__pyx_t_5, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 363, __pyx_L1_error)
9431   __Pyx_GOTREF(__pyx_t_7);
9432   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9433   __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error)
9434   __Pyx_GOTREF(__pyx_t_5);
9435   __Pyx_GIVEREF(__pyx_t_6);
9436   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
9437   __Pyx_GIVEREF(__pyx_t_4);
9438   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
9439   __Pyx_GIVEREF(__pyx_t_7);
9440   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_7);
9441   __pyx_t_6 = 0;
9442   __pyx_t_4 = 0;
9443   __pyx_t_7 = 0;
9444   __pyx_r = __pyx_t_5;
9445   __pyx_t_5 = 0;
9446   goto __pyx_L0;
9447
9448   /* "lxml/html/diff.py":353
9449  *     return start, balanced, end
9450  * 
9451  * def split_delete(chunks):             # <<<<<<<<<<<<<<
9452  *     """ Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
9453  *     stuff_after_DEL_END).  Returns the first case found (there may be
9454  */
9455
9456   /* function exit code */
9457   __pyx_L1_error:;
9458   __Pyx_XDECREF(__pyx_t_4);
9459   __Pyx_XDECREF(__pyx_t_5);
9460   __Pyx_XDECREF(__pyx_t_6);
9461   __Pyx_XDECREF(__pyx_t_7);
9462   __Pyx_AddTraceback("lxml.html.diff.split_delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
9463   __pyx_r = NULL;
9464   __pyx_L0:;
9465   __Pyx_XDECREF(__pyx_v_pos);
9466   __Pyx_XDECREF(__pyx_v_pos2);
9467   __Pyx_XGIVEREF(__pyx_r);
9468   __Pyx_RefNannyFinishContext();
9469   return __pyx_r;
9470 }
9471
9472 /* "lxml/html/diff.py":365
9473  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
9474  * 
9475  * def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):             # <<<<<<<<<<<<<<
9476  *     """ pre_delete and post_delete implicitly point to a place in the
9477  *     document (where the two were split).  This moves that point (by
9478  */
9479
9480 /* Python wrapper */
9481 static PyObject *__pyx_pw_4lxml_4html_4diff_35locate_unbalanced_start(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9482 static char __pyx_doc_4lxml_4html_4diff_34locate_unbalanced_start[] = " pre_delete and post_delete implicitly point to a place in the\n    document (where the two were split).  This moves that point (by\n    popping items from one and pushing them onto the other).  It moves\n    the point to try to find a place where unbalanced_start applies.\n\n    As an example::\n\n        >>> unbalanced_start = ['<div>']\n        >>> doc = ['<p>', 'Text', '</p>', '<div>', 'More Text', '</div>']\n        >>> pre, post = doc[:3], doc[3:]\n        >>> pre, post\n        (['<p>', 'Text', '</p>'], ['<div>', 'More Text', '</div>'])\n        >>> locate_unbalanced_start(unbalanced_start, pre, post)\n        >>> pre, post\n        (['<p>', 'Text', '</p>', '<div>'], ['More Text', '</div>'])\n\n    As you can see, we moved the point so that the dangling <div> that\n    we found will be effectively replaced by the div in the original\n    document.  If this doesn't work out, we just throw away\n    unbalanced_start without doing anything.\n    ";
9483 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_35locate_unbalanced_start = {"locate_unbalanced_start", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_35locate_unbalanced_start, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_34locate_unbalanced_start};
9484 static PyObject *__pyx_pw_4lxml_4html_4diff_35locate_unbalanced_start(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9485   PyObject *__pyx_v_unbalanced_start = 0;
9486   PyObject *__pyx_v_pre_delete = 0;
9487   PyObject *__pyx_v_post_delete = 0;
9488   int __pyx_lineno = 0;
9489   const char *__pyx_filename = NULL;
9490   int __pyx_clineno = 0;
9491   PyObject *__pyx_r = 0;
9492   __Pyx_RefNannyDeclarations
9493   __Pyx_RefNannySetupContext("locate_unbalanced_start (wrapper)", 0);
9494   {
9495     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unbalanced_start,&__pyx_n_s_pre_delete,&__pyx_n_s_post_delete,0};
9496     PyObject* values[3] = {0,0,0};
9497     if (unlikely(__pyx_kwds)) {
9498       Py_ssize_t kw_args;
9499       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9500       switch (pos_args) {
9501         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9502         CYTHON_FALLTHROUGH;
9503         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9504         CYTHON_FALLTHROUGH;
9505         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9506         CYTHON_FALLTHROUGH;
9507         case  0: break;
9508         default: goto __pyx_L5_argtuple_error;
9509       }
9510       kw_args = PyDict_Size(__pyx_kwds);
9511       switch (pos_args) {
9512         case  0:
9513         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unbalanced_start)) != 0)) kw_args--;
9514         else goto __pyx_L5_argtuple_error;
9515         CYTHON_FALLTHROUGH;
9516         case  1:
9517         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pre_delete)) != 0)) kw_args--;
9518         else {
9519           __Pyx_RaiseArgtupleInvalid("locate_unbalanced_start", 1, 3, 3, 1); __PYX_ERR(0, 365, __pyx_L3_error)
9520         }
9521         CYTHON_FALLTHROUGH;
9522         case  2:
9523         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_delete)) != 0)) kw_args--;
9524         else {
9525           __Pyx_RaiseArgtupleInvalid("locate_unbalanced_start", 1, 3, 3, 2); __PYX_ERR(0, 365, __pyx_L3_error)
9526         }
9527       }
9528       if (unlikely(kw_args > 0)) {
9529         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "locate_unbalanced_start") < 0)) __PYX_ERR(0, 365, __pyx_L3_error)
9530       }
9531     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
9532       goto __pyx_L5_argtuple_error;
9533     } else {
9534       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9535       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9536       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9537     }
9538     __pyx_v_unbalanced_start = values[0];
9539     __pyx_v_pre_delete = values[1];
9540     __pyx_v_post_delete = values[2];
9541   }
9542   goto __pyx_L4_argument_unpacking_done;
9543   __pyx_L5_argtuple_error:;
9544   __Pyx_RaiseArgtupleInvalid("locate_unbalanced_start", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 365, __pyx_L3_error)
9545   __pyx_L3_error:;
9546   __Pyx_AddTraceback("lxml.html.diff.locate_unbalanced_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
9547   __Pyx_RefNannyFinishContext();
9548   return NULL;
9549   __pyx_L4_argument_unpacking_done:;
9550   __pyx_r = __pyx_pf_4lxml_4html_4diff_34locate_unbalanced_start(__pyx_self, __pyx_v_unbalanced_start, __pyx_v_pre_delete, __pyx_v_post_delete);
9551
9552   /* function exit code */
9553   __Pyx_RefNannyFinishContext();
9554   return __pyx_r;
9555 }
9556
9557 static PyObject *__pyx_pf_4lxml_4html_4diff_34locate_unbalanced_start(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_unbalanced_start, PyObject *__pyx_v_pre_delete, PyObject *__pyx_v_post_delete) {
9558   PyObject *__pyx_v_finding = NULL;
9559   PyObject *__pyx_v_finding_name = NULL;
9560   PyObject *__pyx_v_next = NULL;
9561   PyObject *__pyx_v_name = NULL;
9562   PyObject *__pyx_r = NULL;
9563   __Pyx_RefNannyDeclarations
9564   int __pyx_t_1;
9565   int __pyx_t_2;
9566   PyObject *__pyx_t_3 = NULL;
9567   PyObject *__pyx_t_4 = NULL;
9568   PyObject *__pyx_t_5 = NULL;
9569   PyObject *__pyx_t_6 = NULL;
9570   int __pyx_t_7;
9571   int __pyx_t_8;
9572   int __pyx_lineno = 0;
9573   const char *__pyx_filename = NULL;
9574   int __pyx_clineno = 0;
9575   __Pyx_RefNannySetupContext("locate_unbalanced_start", 0);
9576
9577   /* "lxml/html/diff.py":387
9578  *     unbalanced_start without doing anything.
9579  *     """
9580  *     while 1:             # <<<<<<<<<<<<<<
9581  *         if not unbalanced_start:
9582  *             # We have totally succeeded in finding the position
9583  */
9584   while (1) {
9585
9586     /* "lxml/html/diff.py":388
9587  *     """
9588  *     while 1:
9589  *         if not unbalanced_start:             # <<<<<<<<<<<<<<
9590  *             # We have totally succeeded in finding the position
9591  *             break
9592  */
9593     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_unbalanced_start); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 388, __pyx_L1_error)
9594     __pyx_t_2 = ((!__pyx_t_1) != 0);
9595     if (__pyx_t_2) {
9596
9597       /* "lxml/html/diff.py":390
9598  *         if not unbalanced_start:
9599  *             # We have totally succeeded in finding the position
9600  *             break             # <<<<<<<<<<<<<<
9601  *         finding = unbalanced_start[0]
9602  *         finding_name = finding.split()[0].strip('<>')
9603  */
9604       goto __pyx_L4_break;
9605
9606       /* "lxml/html/diff.py":388
9607  *     """
9608  *     while 1:
9609  *         if not unbalanced_start:             # <<<<<<<<<<<<<<
9610  *             # We have totally succeeded in finding the position
9611  *             break
9612  */
9613     }
9614
9615     /* "lxml/html/diff.py":391
9616  *             # We have totally succeeded in finding the position
9617  *             break
9618  *         finding = unbalanced_start[0]             # <<<<<<<<<<<<<<
9619  *         finding_name = finding.split()[0].strip('<>')
9620  *         if not post_delete:
9621  */
9622     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_unbalanced_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error)
9623     __Pyx_GOTREF(__pyx_t_3);
9624     __Pyx_XDECREF_SET(__pyx_v_finding, __pyx_t_3);
9625     __pyx_t_3 = 0;
9626
9627     /* "lxml/html/diff.py":392
9628  *             break
9629  *         finding = unbalanced_start[0]
9630  *         finding_name = finding.split()[0].strip('<>')             # <<<<<<<<<<<<<<
9631  *         if not post_delete:
9632  *             break
9633  */
9634     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_finding, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L1_error)
9635     __Pyx_GOTREF(__pyx_t_5);
9636     __pyx_t_6 = NULL;
9637     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
9638       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
9639       if (likely(__pyx_t_6)) {
9640         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9641         __Pyx_INCREF(__pyx_t_6);
9642         __Pyx_INCREF(function);
9643         __Pyx_DECREF_SET(__pyx_t_5, function);
9644       }
9645     }
9646     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
9647     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
9648     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
9649     __Pyx_GOTREF(__pyx_t_4);
9650     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9651     __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L1_error)
9652     __Pyx_GOTREF(__pyx_t_5);
9653     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9654     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
9655     __Pyx_GOTREF(__pyx_t_4);
9656     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9657     __pyx_t_5 = NULL;
9658     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
9659       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
9660       if (likely(__pyx_t_5)) {
9661         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
9662         __Pyx_INCREF(__pyx_t_5);
9663         __Pyx_INCREF(function);
9664         __Pyx_DECREF_SET(__pyx_t_4, function);
9665       }
9666     }
9667     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__11) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__11);
9668     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9669     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 392, __pyx_L1_error)
9670     __Pyx_GOTREF(__pyx_t_3);
9671     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9672     __Pyx_XDECREF_SET(__pyx_v_finding_name, __pyx_t_3);
9673     __pyx_t_3 = 0;
9674
9675     /* "lxml/html/diff.py":393
9676  *         finding = unbalanced_start[0]
9677  *         finding_name = finding.split()[0].strip('<>')
9678  *         if not post_delete:             # <<<<<<<<<<<<<<
9679  *             break
9680  *         next = post_delete[0]
9681  */
9682     __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_post_delete); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 393, __pyx_L1_error)
9683     __pyx_t_1 = ((!__pyx_t_2) != 0);
9684     if (__pyx_t_1) {
9685
9686       /* "lxml/html/diff.py":394
9687  *         finding_name = finding.split()[0].strip('<>')
9688  *         if not post_delete:
9689  *             break             # <<<<<<<<<<<<<<
9690  *         next = post_delete[0]
9691  *         if next is DEL_START or not next.startswith('<'):
9692  */
9693       goto __pyx_L4_break;
9694
9695       /* "lxml/html/diff.py":393
9696  *         finding = unbalanced_start[0]
9697  *         finding_name = finding.split()[0].strip('<>')
9698  *         if not post_delete:             # <<<<<<<<<<<<<<
9699  *             break
9700  *         next = post_delete[0]
9701  */
9702     }
9703
9704     /* "lxml/html/diff.py":395
9705  *         if not post_delete:
9706  *             break
9707  *         next = post_delete[0]             # <<<<<<<<<<<<<<
9708  *         if next is DEL_START or not next.startswith('<'):
9709  *             # Reached a word, we can't move the delete text forward
9710  */
9711     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_post_delete, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 395, __pyx_L1_error)
9712     __Pyx_GOTREF(__pyx_t_3);
9713     __Pyx_XDECREF_SET(__pyx_v_next, __pyx_t_3);
9714     __pyx_t_3 = 0;
9715
9716     /* "lxml/html/diff.py":396
9717  *             break
9718  *         next = post_delete[0]
9719  *         if next is DEL_START or not next.startswith('<'):             # <<<<<<<<<<<<<<
9720  *             # Reached a word, we can't move the delete text forward
9721  *             break
9722  */
9723     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DEL_START); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 396, __pyx_L1_error)
9724     __Pyx_GOTREF(__pyx_t_3);
9725     __pyx_t_2 = (__pyx_v_next == __pyx_t_3);
9726     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9727     __pyx_t_7 = (__pyx_t_2 != 0);
9728     if (!__pyx_t_7) {
9729     } else {
9730       __pyx_t_1 = __pyx_t_7;
9731       goto __pyx_L8_bool_binop_done;
9732     }
9733     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_next, __pyx_n_s_startswith); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 396, __pyx_L1_error)
9734     __Pyx_GOTREF(__pyx_t_4);
9735     __pyx_t_5 = NULL;
9736     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
9737       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
9738       if (likely(__pyx_t_5)) {
9739         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
9740         __Pyx_INCREF(__pyx_t_5);
9741         __Pyx_INCREF(function);
9742         __Pyx_DECREF_SET(__pyx_t_4, function);
9743       }
9744     }
9745     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__8);
9746     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9747     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 396, __pyx_L1_error)
9748     __Pyx_GOTREF(__pyx_t_3);
9749     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9750     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 396, __pyx_L1_error)
9751     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9752     __pyx_t_2 = ((!__pyx_t_7) != 0);
9753     __pyx_t_1 = __pyx_t_2;
9754     __pyx_L8_bool_binop_done:;
9755     if (__pyx_t_1) {
9756
9757       /* "lxml/html/diff.py":398
9758  *         if next is DEL_START or not next.startswith('<'):
9759  *             # Reached a word, we can't move the delete text forward
9760  *             break             # <<<<<<<<<<<<<<
9761  *         if next[1] == '/':
9762  *             # Reached a closing tag, can we go further?  Maybe not...
9763  */
9764       goto __pyx_L4_break;
9765
9766       /* "lxml/html/diff.py":396
9767  *             break
9768  *         next = post_delete[0]
9769  *         if next is DEL_START or not next.startswith('<'):             # <<<<<<<<<<<<<<
9770  *             # Reached a word, we can't move the delete text forward
9771  *             break
9772  */
9773     }
9774
9775     /* "lxml/html/diff.py":399
9776  *             # Reached a word, we can't move the delete text forward
9777  *             break
9778  *         if next[1] == '/':             # <<<<<<<<<<<<<<
9779  *             # Reached a closing tag, can we go further?  Maybe not...
9780  *             break
9781  */
9782     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_next, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
9783     __Pyx_GOTREF(__pyx_t_3);
9784     __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u__9, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
9785     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9786     if (__pyx_t_1) {
9787
9788       /* "lxml/html/diff.py":401
9789  *         if next[1] == '/':
9790  *             # Reached a closing tag, can we go further?  Maybe not...
9791  *             break             # <<<<<<<<<<<<<<
9792  *         name = next.split()[0].strip('<>')
9793  *         if name == 'ins':
9794  */
9795       goto __pyx_L4_break;
9796
9797       /* "lxml/html/diff.py":399
9798  *             # Reached a word, we can't move the delete text forward
9799  *             break
9800  *         if next[1] == '/':             # <<<<<<<<<<<<<<
9801  *             # Reached a closing tag, can we go further?  Maybe not...
9802  *             break
9803  */
9804     }
9805
9806     /* "lxml/html/diff.py":402
9807  *             # Reached a closing tag, can we go further?  Maybe not...
9808  *             break
9809  *         name = next.split()[0].strip('<>')             # <<<<<<<<<<<<<<
9810  *         if name == 'ins':
9811  *             # Can't move into an insert
9812  */
9813     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_next, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 402, __pyx_L1_error)
9814     __Pyx_GOTREF(__pyx_t_5);
9815     __pyx_t_6 = NULL;
9816     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
9817       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
9818       if (likely(__pyx_t_6)) {
9819         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9820         __Pyx_INCREF(__pyx_t_6);
9821         __Pyx_INCREF(function);
9822         __Pyx_DECREF_SET(__pyx_t_5, function);
9823       }
9824     }
9825     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
9826     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
9827     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
9828     __Pyx_GOTREF(__pyx_t_4);
9829     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9830     __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 402, __pyx_L1_error)
9831     __Pyx_GOTREF(__pyx_t_5);
9832     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9833     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
9834     __Pyx_GOTREF(__pyx_t_4);
9835     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9836     __pyx_t_5 = NULL;
9837     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
9838       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
9839       if (likely(__pyx_t_5)) {
9840         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
9841         __Pyx_INCREF(__pyx_t_5);
9842         __Pyx_INCREF(function);
9843         __Pyx_DECREF_SET(__pyx_t_4, function);
9844       }
9845     }
9846     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__11) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__11);
9847     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9848     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
9849     __Pyx_GOTREF(__pyx_t_3);
9850     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9851     __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_3);
9852     __pyx_t_3 = 0;
9853
9854     /* "lxml/html/diff.py":403
9855  *             break
9856  *         name = next.split()[0].strip('<>')
9857  *         if name == 'ins':             # <<<<<<<<<<<<<<
9858  *             # Can't move into an insert
9859  *             break
9860  */
9861     __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_ins_3, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 403, __pyx_L1_error)
9862     if (__pyx_t_1) {
9863
9864       /* "lxml/html/diff.py":405
9865  *         if name == 'ins':
9866  *             # Can't move into an insert
9867  *             break             # <<<<<<<<<<<<<<
9868  *         assert name != 'del', (
9869  *             "Unexpected delete tag: %r" % next)
9870  */
9871       goto __pyx_L4_break;
9872
9873       /* "lxml/html/diff.py":403
9874  *             break
9875  *         name = next.split()[0].strip('<>')
9876  *         if name == 'ins':             # <<<<<<<<<<<<<<
9877  *             # Can't move into an insert
9878  *             break
9879  */
9880     }
9881
9882     /* "lxml/html/diff.py":406
9883  *             # Can't move into an insert
9884  *             break
9885  *         assert name != 'del', (             # <<<<<<<<<<<<<<
9886  *             "Unexpected delete tag: %r" % next)
9887  *         if name == finding_name:
9888  */
9889     #ifndef CYTHON_WITHOUT_ASSERTIONS
9890     if (unlikely(!Py_OptimizeFlag)) {
9891       __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_del_3, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 406, __pyx_L1_error)
9892       if (unlikely(!__pyx_t_1)) {
9893
9894         /* "lxml/html/diff.py":407
9895  *             break
9896  *         assert name != 'del', (
9897  *             "Unexpected delete tag: %r" % next)             # <<<<<<<<<<<<<<
9898  *         if name == finding_name:
9899  *             unbalanced_start.pop(0)
9900  */
9901         __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Unexpected_delete_tag_r, __pyx_v_next); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
9902         __Pyx_GOTREF(__pyx_t_3);
9903         PyErr_SetObject(PyExc_AssertionError, __pyx_t_3);
9904         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9905         __PYX_ERR(0, 406, __pyx_L1_error)
9906       }
9907     }
9908     #endif
9909
9910     /* "lxml/html/diff.py":408
9911  *         assert name != 'del', (
9912  *             "Unexpected delete tag: %r" % next)
9913  *         if name == finding_name:             # <<<<<<<<<<<<<<
9914  *             unbalanced_start.pop(0)
9915  *             pre_delete.append(post_delete.pop(0))
9916  */
9917     __pyx_t_3 = PyObject_RichCompare(__pyx_v_name, __pyx_v_finding_name, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L1_error)
9918     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 408, __pyx_L1_error)
9919     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9920     if (__pyx_t_1) {
9921
9922       /* "lxml/html/diff.py":409
9923  *             "Unexpected delete tag: %r" % next)
9924  *         if name == finding_name:
9925  *             unbalanced_start.pop(0)             # <<<<<<<<<<<<<<
9926  *             pre_delete.append(post_delete.pop(0))
9927  *         else:
9928  */
9929       __pyx_t_3 = __Pyx_PyObject_PopIndex(__pyx_v_unbalanced_start, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
9930       __Pyx_GOTREF(__pyx_t_3);
9931       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9932
9933       /* "lxml/html/diff.py":410
9934  *         if name == finding_name:
9935  *             unbalanced_start.pop(0)
9936  *             pre_delete.append(post_delete.pop(0))             # <<<<<<<<<<<<<<
9937  *         else:
9938  *             # Found a tag that doesn't match
9939  */
9940       __pyx_t_3 = __Pyx_PyObject_PopIndex(__pyx_v_post_delete, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
9941       __Pyx_GOTREF(__pyx_t_3);
9942       __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_pre_delete, __pyx_t_3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 410, __pyx_L1_error)
9943       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9944
9945       /* "lxml/html/diff.py":408
9946  *         assert name != 'del', (
9947  *             "Unexpected delete tag: %r" % next)
9948  *         if name == finding_name:             # <<<<<<<<<<<<<<
9949  *             unbalanced_start.pop(0)
9950  *             pre_delete.append(post_delete.pop(0))
9951  */
9952       goto __pyx_L12;
9953     }
9954
9955     /* "lxml/html/diff.py":413
9956  *         else:
9957  *             # Found a tag that doesn't match
9958  *             break             # <<<<<<<<<<<<<<
9959  * 
9960  * def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):
9961  */
9962     /*else*/ {
9963       goto __pyx_L4_break;
9964     }
9965     __pyx_L12:;
9966   }
9967   __pyx_L4_break:;
9968
9969   /* "lxml/html/diff.py":365
9970  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
9971  * 
9972  * def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):             # <<<<<<<<<<<<<<
9973  *     """ pre_delete and post_delete implicitly point to a place in the
9974  *     document (where the two were split).  This moves that point (by
9975  */
9976
9977   /* function exit code */
9978   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9979   goto __pyx_L0;
9980   __pyx_L1_error:;
9981   __Pyx_XDECREF(__pyx_t_3);
9982   __Pyx_XDECREF(__pyx_t_4);
9983   __Pyx_XDECREF(__pyx_t_5);
9984   __Pyx_XDECREF(__pyx_t_6);
9985   __Pyx_AddTraceback("lxml.html.diff.locate_unbalanced_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
9986   __pyx_r = NULL;
9987   __pyx_L0:;
9988   __Pyx_XDECREF(__pyx_v_finding);
9989   __Pyx_XDECREF(__pyx_v_finding_name);
9990   __Pyx_XDECREF(__pyx_v_next);
9991   __Pyx_XDECREF(__pyx_v_name);
9992   __Pyx_XGIVEREF(__pyx_r);
9993   __Pyx_RefNannyFinishContext();
9994   return __pyx_r;
9995 }
9996
9997 /* "lxml/html/diff.py":415
9998  *             break
9999  * 
10000  * def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):             # <<<<<<<<<<<<<<
10001  *     """ like locate_unbalanced_start, except handling end tags and
10002  *     possibly moving the point earlier in the document.  """
10003  */
10004
10005 /* Python wrapper */
10006 static PyObject *__pyx_pw_4lxml_4html_4diff_37locate_unbalanced_end(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
10007 static char __pyx_doc_4lxml_4html_4diff_36locate_unbalanced_end[] = " like locate_unbalanced_start, except handling end tags and\n    possibly moving the point earlier in the document.  ";
10008 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_37locate_unbalanced_end = {"locate_unbalanced_end", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_37locate_unbalanced_end, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_36locate_unbalanced_end};
10009 static PyObject *__pyx_pw_4lxml_4html_4diff_37locate_unbalanced_end(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10010   PyObject *__pyx_v_unbalanced_end = 0;
10011   PyObject *__pyx_v_pre_delete = 0;
10012   PyObject *__pyx_v_post_delete = 0;
10013   int __pyx_lineno = 0;
10014   const char *__pyx_filename = NULL;
10015   int __pyx_clineno = 0;
10016   PyObject *__pyx_r = 0;
10017   __Pyx_RefNannyDeclarations
10018   __Pyx_RefNannySetupContext("locate_unbalanced_end (wrapper)", 0);
10019   {
10020     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unbalanced_end,&__pyx_n_s_pre_delete,&__pyx_n_s_post_delete,0};
10021     PyObject* values[3] = {0,0,0};
10022     if (unlikely(__pyx_kwds)) {
10023       Py_ssize_t kw_args;
10024       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10025       switch (pos_args) {
10026         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10027         CYTHON_FALLTHROUGH;
10028         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10029         CYTHON_FALLTHROUGH;
10030         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10031         CYTHON_FALLTHROUGH;
10032         case  0: break;
10033         default: goto __pyx_L5_argtuple_error;
10034       }
10035       kw_args = PyDict_Size(__pyx_kwds);
10036       switch (pos_args) {
10037         case  0:
10038         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unbalanced_end)) != 0)) kw_args--;
10039         else goto __pyx_L5_argtuple_error;
10040         CYTHON_FALLTHROUGH;
10041         case  1:
10042         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pre_delete)) != 0)) kw_args--;
10043         else {
10044           __Pyx_RaiseArgtupleInvalid("locate_unbalanced_end", 1, 3, 3, 1); __PYX_ERR(0, 415, __pyx_L3_error)
10045         }
10046         CYTHON_FALLTHROUGH;
10047         case  2:
10048         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_delete)) != 0)) kw_args--;
10049         else {
10050           __Pyx_RaiseArgtupleInvalid("locate_unbalanced_end", 1, 3, 3, 2); __PYX_ERR(0, 415, __pyx_L3_error)
10051         }
10052       }
10053       if (unlikely(kw_args > 0)) {
10054         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "locate_unbalanced_end") < 0)) __PYX_ERR(0, 415, __pyx_L3_error)
10055       }
10056     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
10057       goto __pyx_L5_argtuple_error;
10058     } else {
10059       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10060       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10061       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10062     }
10063     __pyx_v_unbalanced_end = values[0];
10064     __pyx_v_pre_delete = values[1];
10065     __pyx_v_post_delete = values[2];
10066   }
10067   goto __pyx_L4_argument_unpacking_done;
10068   __pyx_L5_argtuple_error:;
10069   __Pyx_RaiseArgtupleInvalid("locate_unbalanced_end", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 415, __pyx_L3_error)
10070   __pyx_L3_error:;
10071   __Pyx_AddTraceback("lxml.html.diff.locate_unbalanced_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
10072   __Pyx_RefNannyFinishContext();
10073   return NULL;
10074   __pyx_L4_argument_unpacking_done:;
10075   __pyx_r = __pyx_pf_4lxml_4html_4diff_36locate_unbalanced_end(__pyx_self, __pyx_v_unbalanced_end, __pyx_v_pre_delete, __pyx_v_post_delete);
10076
10077   /* function exit code */
10078   __Pyx_RefNannyFinishContext();
10079   return __pyx_r;
10080 }
10081
10082 static PyObject *__pyx_pf_4lxml_4html_4diff_36locate_unbalanced_end(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_unbalanced_end, PyObject *__pyx_v_pre_delete, PyObject *__pyx_v_post_delete) {
10083   PyObject *__pyx_v_finding = NULL;
10084   PyObject *__pyx_v_finding_name = NULL;
10085   PyObject *__pyx_v_next = NULL;
10086   PyObject *__pyx_v_name = NULL;
10087   PyObject *__pyx_r = NULL;
10088   __Pyx_RefNannyDeclarations
10089   int __pyx_t_1;
10090   int __pyx_t_2;
10091   PyObject *__pyx_t_3 = NULL;
10092   PyObject *__pyx_t_4 = NULL;
10093   PyObject *__pyx_t_5 = NULL;
10094   PyObject *__pyx_t_6 = NULL;
10095   int __pyx_t_7;
10096   int __pyx_t_8;
10097   PyObject *__pyx_t_9 = NULL;
10098   int __pyx_lineno = 0;
10099   const char *__pyx_filename = NULL;
10100   int __pyx_clineno = 0;
10101   __Pyx_RefNannySetupContext("locate_unbalanced_end", 0);
10102
10103   /* "lxml/html/diff.py":418
10104  *     """ like locate_unbalanced_start, except handling end tags and
10105  *     possibly moving the point earlier in the document.  """
10106  *     while 1:             # <<<<<<<<<<<<<<
10107  *         if not unbalanced_end:
10108  *             # Success
10109  */
10110   while (1) {
10111
10112     /* "lxml/html/diff.py":419
10113  *     possibly moving the point earlier in the document.  """
10114  *     while 1:
10115  *         if not unbalanced_end:             # <<<<<<<<<<<<<<
10116  *             # Success
10117  *             break
10118  */
10119     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_unbalanced_end); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
10120     __pyx_t_2 = ((!__pyx_t_1) != 0);
10121     if (__pyx_t_2) {
10122
10123       /* "lxml/html/diff.py":421
10124  *         if not unbalanced_end:
10125  *             # Success
10126  *             break             # <<<<<<<<<<<<<<
10127  *         finding = unbalanced_end[-1]
10128  *         finding_name = finding.split()[0].strip('<>/')
10129  */
10130       goto __pyx_L4_break;
10131
10132       /* "lxml/html/diff.py":419
10133  *     possibly moving the point earlier in the document.  """
10134  *     while 1:
10135  *         if not unbalanced_end:             # <<<<<<<<<<<<<<
10136  *             # Success
10137  *             break
10138  */
10139     }
10140
10141     /* "lxml/html/diff.py":422
10142  *             # Success
10143  *             break
10144  *         finding = unbalanced_end[-1]             # <<<<<<<<<<<<<<
10145  *         finding_name = finding.split()[0].strip('<>/')
10146  *         if not pre_delete:
10147  */
10148     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_unbalanced_end, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
10149     __Pyx_GOTREF(__pyx_t_3);
10150     __Pyx_XDECREF_SET(__pyx_v_finding, __pyx_t_3);
10151     __pyx_t_3 = 0;
10152
10153     /* "lxml/html/diff.py":423
10154  *             break
10155  *         finding = unbalanced_end[-1]
10156  *         finding_name = finding.split()[0].strip('<>/')             # <<<<<<<<<<<<<<
10157  *         if not pre_delete:
10158  *             break
10159  */
10160     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_finding, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error)
10161     __Pyx_GOTREF(__pyx_t_5);
10162     __pyx_t_6 = NULL;
10163     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
10164       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
10165       if (likely(__pyx_t_6)) {
10166         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
10167         __Pyx_INCREF(__pyx_t_6);
10168         __Pyx_INCREF(function);
10169         __Pyx_DECREF_SET(__pyx_t_5, function);
10170       }
10171     }
10172     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
10173     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
10174     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 423, __pyx_L1_error)
10175     __Pyx_GOTREF(__pyx_t_4);
10176     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10177     __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error)
10178     __Pyx_GOTREF(__pyx_t_5);
10179     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10180     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 423, __pyx_L1_error)
10181     __Pyx_GOTREF(__pyx_t_4);
10182     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10183     __pyx_t_5 = NULL;
10184     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
10185       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
10186       if (likely(__pyx_t_5)) {
10187         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
10188         __Pyx_INCREF(__pyx_t_5);
10189         __Pyx_INCREF(function);
10190         __Pyx_DECREF_SET(__pyx_t_4, function);
10191       }
10192     }
10193     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__10) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__10);
10194     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10195     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
10196     __Pyx_GOTREF(__pyx_t_3);
10197     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10198     __Pyx_XDECREF_SET(__pyx_v_finding_name, __pyx_t_3);
10199     __pyx_t_3 = 0;
10200
10201     /* "lxml/html/diff.py":424
10202  *         finding = unbalanced_end[-1]
10203  *         finding_name = finding.split()[0].strip('<>/')
10204  *         if not pre_delete:             # <<<<<<<<<<<<<<
10205  *             break
10206  *         next = pre_delete[-1]
10207  */
10208     __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pre_delete); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 424, __pyx_L1_error)
10209     __pyx_t_1 = ((!__pyx_t_2) != 0);
10210     if (__pyx_t_1) {
10211
10212       /* "lxml/html/diff.py":425
10213  *         finding_name = finding.split()[0].strip('<>/')
10214  *         if not pre_delete:
10215  *             break             # <<<<<<<<<<<<<<
10216  *         next = pre_delete[-1]
10217  *         if next is DEL_END or not next.startswith('</'):
10218  */
10219       goto __pyx_L4_break;
10220
10221       /* "lxml/html/diff.py":424
10222  *         finding = unbalanced_end[-1]
10223  *         finding_name = finding.split()[0].strip('<>/')
10224  *         if not pre_delete:             # <<<<<<<<<<<<<<
10225  *             break
10226  *         next = pre_delete[-1]
10227  */
10228     }
10229
10230     /* "lxml/html/diff.py":426
10231  *         if not pre_delete:
10232  *             break
10233  *         next = pre_delete[-1]             # <<<<<<<<<<<<<<
10234  *         if next is DEL_END or not next.startswith('</'):
10235  *             # A word or a start tag
10236  */
10237     __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pre_delete, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
10238     __Pyx_GOTREF(__pyx_t_3);
10239     __Pyx_XDECREF_SET(__pyx_v_next, __pyx_t_3);
10240     __pyx_t_3 = 0;
10241
10242     /* "lxml/html/diff.py":427
10243  *             break
10244  *         next = pre_delete[-1]
10245  *         if next is DEL_END or not next.startswith('</'):             # <<<<<<<<<<<<<<
10246  *             # A word or a start tag
10247  *             break
10248  */
10249     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DEL_END); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
10250     __Pyx_GOTREF(__pyx_t_3);
10251     __pyx_t_2 = (__pyx_v_next == __pyx_t_3);
10252     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10253     __pyx_t_7 = (__pyx_t_2 != 0);
10254     if (!__pyx_t_7) {
10255     } else {
10256       __pyx_t_1 = __pyx_t_7;
10257       goto __pyx_L8_bool_binop_done;
10258     }
10259     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_next, __pyx_n_s_startswith); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 427, __pyx_L1_error)
10260     __Pyx_GOTREF(__pyx_t_4);
10261     __pyx_t_5 = NULL;
10262     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
10263       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
10264       if (likely(__pyx_t_5)) {
10265         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
10266         __Pyx_INCREF(__pyx_t_5);
10267         __Pyx_INCREF(function);
10268         __Pyx_DECREF_SET(__pyx_t_4, function);
10269       }
10270     }
10271     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__12) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__12);
10272     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10273     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
10274     __Pyx_GOTREF(__pyx_t_3);
10275     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10276     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 427, __pyx_L1_error)
10277     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10278     __pyx_t_2 = ((!__pyx_t_7) != 0);
10279     __pyx_t_1 = __pyx_t_2;
10280     __pyx_L8_bool_binop_done:;
10281     if (__pyx_t_1) {
10282
10283       /* "lxml/html/diff.py":429
10284  *         if next is DEL_END or not next.startswith('</'):
10285  *             # A word or a start tag
10286  *             break             # <<<<<<<<<<<<<<
10287  *         name = next.split()[0].strip('<>/')
10288  *         if name == 'ins' or name == 'del':
10289  */
10290       goto __pyx_L4_break;
10291
10292       /* "lxml/html/diff.py":427
10293  *             break
10294  *         next = pre_delete[-1]
10295  *         if next is DEL_END or not next.startswith('</'):             # <<<<<<<<<<<<<<
10296  *             # A word or a start tag
10297  *             break
10298  */
10299     }
10300
10301     /* "lxml/html/diff.py":430
10302  *             # A word or a start tag
10303  *             break
10304  *         name = next.split()[0].strip('<>/')             # <<<<<<<<<<<<<<
10305  *         if name == 'ins' or name == 'del':
10306  *             # Can't move into an insert or delete
10307  */
10308     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_next, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 430, __pyx_L1_error)
10309     __Pyx_GOTREF(__pyx_t_5);
10310     __pyx_t_6 = NULL;
10311     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
10312       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
10313       if (likely(__pyx_t_6)) {
10314         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
10315         __Pyx_INCREF(__pyx_t_6);
10316         __Pyx_INCREF(function);
10317         __Pyx_DECREF_SET(__pyx_t_5, function);
10318       }
10319     }
10320     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
10321     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
10322     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error)
10323     __Pyx_GOTREF(__pyx_t_4);
10324     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10325     __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 430, __pyx_L1_error)
10326     __Pyx_GOTREF(__pyx_t_5);
10327     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10328     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error)
10329     __Pyx_GOTREF(__pyx_t_4);
10330     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10331     __pyx_t_5 = NULL;
10332     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
10333       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
10334       if (likely(__pyx_t_5)) {
10335         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
10336         __Pyx_INCREF(__pyx_t_5);
10337         __Pyx_INCREF(function);
10338         __Pyx_DECREF_SET(__pyx_t_4, function);
10339       }
10340     }
10341     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u__10) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__10);
10342     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10343     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
10344     __Pyx_GOTREF(__pyx_t_3);
10345     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10346     __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_3);
10347     __pyx_t_3 = 0;
10348
10349     /* "lxml/html/diff.py":431
10350  *             break
10351  *         name = next.split()[0].strip('<>/')
10352  *         if name == 'ins' or name == 'del':             # <<<<<<<<<<<<<<
10353  *             # Can't move into an insert or delete
10354  *             break
10355  */
10356     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_ins_3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 431, __pyx_L1_error)
10357     if (!__pyx_t_2) {
10358     } else {
10359       __pyx_t_1 = __pyx_t_2;
10360       goto __pyx_L11_bool_binop_done;
10361     }
10362     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_del_3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 431, __pyx_L1_error)
10363     __pyx_t_1 = __pyx_t_2;
10364     __pyx_L11_bool_binop_done:;
10365     if (__pyx_t_1) {
10366
10367       /* "lxml/html/diff.py":433
10368  *         if name == 'ins' or name == 'del':
10369  *             # Can't move into an insert or delete
10370  *             break             # <<<<<<<<<<<<<<
10371  *         if name == finding_name:
10372  *             unbalanced_end.pop()
10373  */
10374       goto __pyx_L4_break;
10375
10376       /* "lxml/html/diff.py":431
10377  *             break
10378  *         name = next.split()[0].strip('<>/')
10379  *         if name == 'ins' or name == 'del':             # <<<<<<<<<<<<<<
10380  *             # Can't move into an insert or delete
10381  *             break
10382  */
10383     }
10384
10385     /* "lxml/html/diff.py":434
10386  *             # Can't move into an insert or delete
10387  *             break
10388  *         if name == finding_name:             # <<<<<<<<<<<<<<
10389  *             unbalanced_end.pop()
10390  *             post_delete.insert(0, pre_delete.pop())
10391  */
10392     __pyx_t_3 = PyObject_RichCompare(__pyx_v_name, __pyx_v_finding_name, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 434, __pyx_L1_error)
10393     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 434, __pyx_L1_error)
10394     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10395     if (__pyx_t_1) {
10396
10397       /* "lxml/html/diff.py":435
10398  *             break
10399  *         if name == finding_name:
10400  *             unbalanced_end.pop()             # <<<<<<<<<<<<<<
10401  *             post_delete.insert(0, pre_delete.pop())
10402  *         else:
10403  */
10404       __pyx_t_3 = __Pyx_PyObject_Pop(__pyx_v_unbalanced_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
10405       __Pyx_GOTREF(__pyx_t_3);
10406       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10407
10408       /* "lxml/html/diff.py":436
10409  *         if name == finding_name:
10410  *             unbalanced_end.pop()
10411  *             post_delete.insert(0, pre_delete.pop())             # <<<<<<<<<<<<<<
10412  *         else:
10413  *             # Found a tag that doesn't match
10414  */
10415       __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_post_delete, __pyx_n_s_insert); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
10416       __Pyx_GOTREF(__pyx_t_4);
10417       __pyx_t_5 = __Pyx_PyObject_Pop(__pyx_v_pre_delete); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 436, __pyx_L1_error)
10418       __Pyx_GOTREF(__pyx_t_5);
10419       __pyx_t_6 = NULL;
10420       __pyx_t_8 = 0;
10421       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
10422         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
10423         if (likely(__pyx_t_6)) {
10424           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
10425           __Pyx_INCREF(__pyx_t_6);
10426           __Pyx_INCREF(function);
10427           __Pyx_DECREF_SET(__pyx_t_4, function);
10428           __pyx_t_8 = 1;
10429         }
10430       }
10431       #if CYTHON_FAST_PYCALL
10432       if (PyFunction_Check(__pyx_t_4)) {
10433         PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_0, __pyx_t_5};
10434         __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error)
10435         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
10436         __Pyx_GOTREF(__pyx_t_3);
10437         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10438       } else
10439       #endif
10440       #if CYTHON_FAST_PYCCALL
10441       if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
10442         PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_0, __pyx_t_5};
10443         __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error)
10444         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
10445         __Pyx_GOTREF(__pyx_t_3);
10446         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10447       } else
10448       #endif
10449       {
10450         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 436, __pyx_L1_error)
10451         __Pyx_GOTREF(__pyx_t_9);
10452         if (__pyx_t_6) {
10453           __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
10454         }
10455         __Pyx_INCREF(__pyx_int_0);
10456         __Pyx_GIVEREF(__pyx_int_0);
10457         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_int_0);
10458         __Pyx_GIVEREF(__pyx_t_5);
10459         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
10460         __pyx_t_5 = 0;
10461         __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error)
10462         __Pyx_GOTREF(__pyx_t_3);
10463         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
10464       }
10465       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10466       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10467
10468       /* "lxml/html/diff.py":434
10469  *             # Can't move into an insert or delete
10470  *             break
10471  *         if name == finding_name:             # <<<<<<<<<<<<<<
10472  *             unbalanced_end.pop()
10473  *             post_delete.insert(0, pre_delete.pop())
10474  */
10475       goto __pyx_L13;
10476     }
10477
10478     /* "lxml/html/diff.py":439
10479  *         else:
10480  *             # Found a tag that doesn't match
10481  *             break             # <<<<<<<<<<<<<<
10482  * 
10483  * class token(_unicode):
10484  */
10485     /*else*/ {
10486       goto __pyx_L4_break;
10487     }
10488     __pyx_L13:;
10489   }
10490   __pyx_L4_break:;
10491
10492   /* "lxml/html/diff.py":415
10493  *             break
10494  * 
10495  * def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):             # <<<<<<<<<<<<<<
10496  *     """ like locate_unbalanced_start, except handling end tags and
10497  *     possibly moving the point earlier in the document.  """
10498  */
10499
10500   /* function exit code */
10501   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10502   goto __pyx_L0;
10503   __pyx_L1_error:;
10504   __Pyx_XDECREF(__pyx_t_3);
10505   __Pyx_XDECREF(__pyx_t_4);
10506   __Pyx_XDECREF(__pyx_t_5);
10507   __Pyx_XDECREF(__pyx_t_6);
10508   __Pyx_XDECREF(__pyx_t_9);
10509   __Pyx_AddTraceback("lxml.html.diff.locate_unbalanced_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
10510   __pyx_r = NULL;
10511   __pyx_L0:;
10512   __Pyx_XDECREF(__pyx_v_finding);
10513   __Pyx_XDECREF(__pyx_v_finding_name);
10514   __Pyx_XDECREF(__pyx_v_next);
10515   __Pyx_XDECREF(__pyx_v_name);
10516   __Pyx_XGIVEREF(__pyx_r);
10517   __Pyx_RefNannyFinishContext();
10518   return __pyx_r;
10519 }
10520
10521 /* "lxml/html/diff.py":458
10522  *     hide_when_equal = False
10523  * 
10524  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):             # <<<<<<<<<<<<<<
10525  *         obj = _unicode.__new__(cls, text)
10526  * 
10527  */
10528
10529 /* Python wrapper */
10530 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
10531 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_5token_1__new__ = {"__new__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_5token_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
10532 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10533   PyObject *__pyx_v_cls = 0;
10534   PyObject *__pyx_v_text = 0;
10535   PyObject *__pyx_v_pre_tags = 0;
10536   PyObject *__pyx_v_post_tags = 0;
10537   PyObject *__pyx_v_trailing_whitespace = 0;
10538   int __pyx_lineno = 0;
10539   const char *__pyx_filename = NULL;
10540   int __pyx_clineno = 0;
10541   PyObject *__pyx_r = 0;
10542   __Pyx_RefNannyDeclarations
10543   __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
10544   {
10545     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_text,&__pyx_n_s_pre_tags,&__pyx_n_s_post_tags,&__pyx_n_s_trailing_whitespace,0};
10546     PyObject* values[5] = {0,0,0,0,0};
10547     values[2] = ((PyObject *)((PyObject *)Py_None));
10548     values[3] = ((PyObject *)((PyObject *)Py_None));
10549     values[4] = ((PyObject *)((PyObject*)__pyx_kp_u__2));
10550     if (unlikely(__pyx_kwds)) {
10551       Py_ssize_t kw_args;
10552       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10553       switch (pos_args) {
10554         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
10555         CYTHON_FALLTHROUGH;
10556         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
10557         CYTHON_FALLTHROUGH;
10558         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10559         CYTHON_FALLTHROUGH;
10560         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10561         CYTHON_FALLTHROUGH;
10562         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10563         CYTHON_FALLTHROUGH;
10564         case  0: break;
10565         default: goto __pyx_L5_argtuple_error;
10566       }
10567       kw_args = PyDict_Size(__pyx_kwds);
10568       switch (pos_args) {
10569         case  0:
10570         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
10571         else goto __pyx_L5_argtuple_error;
10572         CYTHON_FALLTHROUGH;
10573         case  1:
10574         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
10575         else {
10576           __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 5, 1); __PYX_ERR(0, 458, __pyx_L3_error)
10577         }
10578         CYTHON_FALLTHROUGH;
10579         case  2:
10580         if (kw_args > 0) {
10581           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pre_tags);
10582           if (value) { values[2] = value; kw_args--; }
10583         }
10584         CYTHON_FALLTHROUGH;
10585         case  3:
10586         if (kw_args > 0) {
10587           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_tags);
10588           if (value) { values[3] = value; kw_args--; }
10589         }
10590         CYTHON_FALLTHROUGH;
10591         case  4:
10592         if (kw_args > 0) {
10593           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_trailing_whitespace);
10594           if (value) { values[4] = value; kw_args--; }
10595         }
10596       }
10597       if (unlikely(kw_args > 0)) {
10598         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 458, __pyx_L3_error)
10599       }
10600     } else {
10601       switch (PyTuple_GET_SIZE(__pyx_args)) {
10602         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
10603         CYTHON_FALLTHROUGH;
10604         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
10605         CYTHON_FALLTHROUGH;
10606         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10607         CYTHON_FALLTHROUGH;
10608         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10609         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10610         break;
10611         default: goto __pyx_L5_argtuple_error;
10612       }
10613     }
10614     __pyx_v_cls = values[0];
10615     __pyx_v_text = values[1];
10616     __pyx_v_pre_tags = values[2];
10617     __pyx_v_post_tags = values[3];
10618     __pyx_v_trailing_whitespace = values[4];
10619   }
10620   goto __pyx_L4_argument_unpacking_done;
10621   __pyx_L5_argtuple_error:;
10622   __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 458, __pyx_L3_error)
10623   __pyx_L3_error:;
10624   __Pyx_AddTraceback("lxml.html.diff.token.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10625   __Pyx_RefNannyFinishContext();
10626   return NULL;
10627   __pyx_L4_argument_unpacking_done:;
10628   __pyx_r = __pyx_pf_4lxml_4html_4diff_5token___new__(__pyx_self, __pyx_v_cls, __pyx_v_text, __pyx_v_pre_tags, __pyx_v_post_tags, __pyx_v_trailing_whitespace);
10629
10630   /* function exit code */
10631   __Pyx_RefNannyFinishContext();
10632   return __pyx_r;
10633 }
10634
10635 static PyObject *__pyx_pf_4lxml_4html_4diff_5token___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_text, PyObject *__pyx_v_pre_tags, PyObject *__pyx_v_post_tags, PyObject *__pyx_v_trailing_whitespace) {
10636   PyObject *__pyx_v_obj = NULL;
10637   PyObject *__pyx_r = NULL;
10638   __Pyx_RefNannyDeclarations
10639   PyObject *__pyx_t_1 = NULL;
10640   PyObject *__pyx_t_2 = NULL;
10641   PyObject *__pyx_t_3 = NULL;
10642   int __pyx_t_4;
10643   PyObject *__pyx_t_5 = NULL;
10644   int __pyx_t_6;
10645   int __pyx_t_7;
10646   int __pyx_lineno = 0;
10647   const char *__pyx_filename = NULL;
10648   int __pyx_clineno = 0;
10649   __Pyx_RefNannySetupContext("__new__", 0);
10650
10651   /* "lxml/html/diff.py":459
10652  * 
10653  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):
10654  *         obj = _unicode.__new__(cls, text)             # <<<<<<<<<<<<<<
10655  * 
10656  *         if pre_tags is not None:
10657  */
10658   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
10659   __Pyx_GOTREF(__pyx_t_2);
10660   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_new); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 459, __pyx_L1_error)
10661   __Pyx_GOTREF(__pyx_t_3);
10662   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10663   __pyx_t_2 = NULL;
10664   __pyx_t_4 = 0;
10665   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
10666     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
10667     if (likely(__pyx_t_2)) {
10668       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
10669       __Pyx_INCREF(__pyx_t_2);
10670       __Pyx_INCREF(function);
10671       __Pyx_DECREF_SET(__pyx_t_3, function);
10672       __pyx_t_4 = 1;
10673     }
10674   }
10675   #if CYTHON_FAST_PYCALL
10676   if (PyFunction_Check(__pyx_t_3)) {
10677     PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_cls, __pyx_v_text};
10678     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
10679     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
10680     __Pyx_GOTREF(__pyx_t_1);
10681   } else
10682   #endif
10683   #if CYTHON_FAST_PYCCALL
10684   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
10685     PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_cls, __pyx_v_text};
10686     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
10687     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
10688     __Pyx_GOTREF(__pyx_t_1);
10689   } else
10690   #endif
10691   {
10692     __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 459, __pyx_L1_error)
10693     __Pyx_GOTREF(__pyx_t_5);
10694     if (__pyx_t_2) {
10695       __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
10696     }
10697     __Pyx_INCREF(__pyx_v_cls);
10698     __Pyx_GIVEREF(__pyx_v_cls);
10699     PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_cls);
10700     __Pyx_INCREF(__pyx_v_text);
10701     __Pyx_GIVEREF(__pyx_v_text);
10702     PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_text);
10703     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
10704     __Pyx_GOTREF(__pyx_t_1);
10705     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10706   }
10707   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10708   __pyx_v_obj = __pyx_t_1;
10709   __pyx_t_1 = 0;
10710
10711   /* "lxml/html/diff.py":461
10712  *         obj = _unicode.__new__(cls, text)
10713  * 
10714  *         if pre_tags is not None:             # <<<<<<<<<<<<<<
10715  *             obj.pre_tags = pre_tags
10716  *         else:
10717  */
10718   __pyx_t_6 = (__pyx_v_pre_tags != Py_None);
10719   __pyx_t_7 = (__pyx_t_6 != 0);
10720   if (__pyx_t_7) {
10721
10722     /* "lxml/html/diff.py":462
10723  * 
10724  *         if pre_tags is not None:
10725  *             obj.pre_tags = pre_tags             # <<<<<<<<<<<<<<
10726  *         else:
10727  *             obj.pre_tags = []
10728  */
10729     if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_pre_tags, __pyx_v_pre_tags) < 0) __PYX_ERR(0, 462, __pyx_L1_error)
10730
10731     /* "lxml/html/diff.py":461
10732  *         obj = _unicode.__new__(cls, text)
10733  * 
10734  *         if pre_tags is not None:             # <<<<<<<<<<<<<<
10735  *             obj.pre_tags = pre_tags
10736  *         else:
10737  */
10738     goto __pyx_L3;
10739   }
10740
10741   /* "lxml/html/diff.py":464
10742  *             obj.pre_tags = pre_tags
10743  *         else:
10744  *             obj.pre_tags = []             # <<<<<<<<<<<<<<
10745  * 
10746  *         if post_tags is not None:
10747  */
10748   /*else*/ {
10749     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
10750     __Pyx_GOTREF(__pyx_t_1);
10751     if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_pre_tags, __pyx_t_1) < 0) __PYX_ERR(0, 464, __pyx_L1_error)
10752     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10753   }
10754   __pyx_L3:;
10755
10756   /* "lxml/html/diff.py":466
10757  *             obj.pre_tags = []
10758  * 
10759  *         if post_tags is not None:             # <<<<<<<<<<<<<<
10760  *             obj.post_tags = post_tags
10761  *         else:
10762  */
10763   __pyx_t_7 = (__pyx_v_post_tags != Py_None);
10764   __pyx_t_6 = (__pyx_t_7 != 0);
10765   if (__pyx_t_6) {
10766
10767     /* "lxml/html/diff.py":467
10768  * 
10769  *         if post_tags is not None:
10770  *             obj.post_tags = post_tags             # <<<<<<<<<<<<<<
10771  *         else:
10772  *             obj.post_tags = []
10773  */
10774     if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_post_tags, __pyx_v_post_tags) < 0) __PYX_ERR(0, 467, __pyx_L1_error)
10775
10776     /* "lxml/html/diff.py":466
10777  *             obj.pre_tags = []
10778  * 
10779  *         if post_tags is not None:             # <<<<<<<<<<<<<<
10780  *             obj.post_tags = post_tags
10781  *         else:
10782  */
10783     goto __pyx_L4;
10784   }
10785
10786   /* "lxml/html/diff.py":469
10787  *             obj.post_tags = post_tags
10788  *         else:
10789  *             obj.post_tags = []             # <<<<<<<<<<<<<<
10790  * 
10791  *         obj.trailing_whitespace = trailing_whitespace
10792  */
10793   /*else*/ {
10794     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
10795     __Pyx_GOTREF(__pyx_t_1);
10796     if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_post_tags, __pyx_t_1) < 0) __PYX_ERR(0, 469, __pyx_L1_error)
10797     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10798   }
10799   __pyx_L4:;
10800
10801   /* "lxml/html/diff.py":471
10802  *             obj.post_tags = []
10803  * 
10804  *         obj.trailing_whitespace = trailing_whitespace             # <<<<<<<<<<<<<<
10805  * 
10806  *         return obj
10807  */
10808   if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_trailing_whitespace, __pyx_v_trailing_whitespace) < 0) __PYX_ERR(0, 471, __pyx_L1_error)
10809
10810   /* "lxml/html/diff.py":473
10811  *         obj.trailing_whitespace = trailing_whitespace
10812  * 
10813  *         return obj             # <<<<<<<<<<<<<<
10814  * 
10815  *     def __repr__(self):
10816  */
10817   __Pyx_XDECREF(__pyx_r);
10818   __Pyx_INCREF(__pyx_v_obj);
10819   __pyx_r = __pyx_v_obj;
10820   goto __pyx_L0;
10821
10822   /* "lxml/html/diff.py":458
10823  *     hide_when_equal = False
10824  * 
10825  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):             # <<<<<<<<<<<<<<
10826  *         obj = _unicode.__new__(cls, text)
10827  * 
10828  */
10829
10830   /* function exit code */
10831   __pyx_L1_error:;
10832   __Pyx_XDECREF(__pyx_t_1);
10833   __Pyx_XDECREF(__pyx_t_2);
10834   __Pyx_XDECREF(__pyx_t_3);
10835   __Pyx_XDECREF(__pyx_t_5);
10836   __Pyx_AddTraceback("lxml.html.diff.token.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10837   __pyx_r = NULL;
10838   __pyx_L0:;
10839   __Pyx_XDECREF(__pyx_v_obj);
10840   __Pyx_XGIVEREF(__pyx_r);
10841   __Pyx_RefNannyFinishContext();
10842   return __pyx_r;
10843 }
10844
10845 /* "lxml/html/diff.py":475
10846  *         return obj
10847  * 
10848  *     def __repr__(self):             # <<<<<<<<<<<<<<
10849  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
10850  *                                           self.post_tags, self.trailing_whitespace)
10851  */
10852
10853 /* Python wrapper */
10854 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
10855 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_5token_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_4lxml_4html_4diff_5token_3__repr__, METH_O, 0};
10856 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
10857   PyObject *__pyx_r = 0;
10858   __Pyx_RefNannyDeclarations
10859   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
10860   __pyx_r = __pyx_pf_4lxml_4html_4diff_5token_2__repr__(__pyx_self, ((PyObject *)__pyx_v_self));
10861
10862   /* function exit code */
10863   __Pyx_RefNannyFinishContext();
10864   return __pyx_r;
10865 }
10866
10867 static PyObject *__pyx_pf_4lxml_4html_4diff_5token_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
10868   PyObject *__pyx_r = NULL;
10869   __Pyx_RefNannyDeclarations
10870   PyObject *__pyx_t_1 = NULL;
10871   Py_ssize_t __pyx_t_2;
10872   Py_UCS4 __pyx_t_3;
10873   PyObject *__pyx_t_4 = NULL;
10874   PyObject *__pyx_t_5 = NULL;
10875   PyObject *__pyx_t_6 = NULL;
10876   int __pyx_lineno = 0;
10877   const char *__pyx_filename = NULL;
10878   int __pyx_clineno = 0;
10879   __Pyx_RefNannySetupContext("__repr__", 0);
10880
10881   /* "lxml/html/diff.py":476
10882  * 
10883  *     def __repr__(self):
10884  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,             # <<<<<<<<<<<<<<
10885  *                                           self.post_tags, self.trailing_whitespace)
10886  * 
10887  */
10888   __Pyx_XDECREF(__pyx_r);
10889   __pyx_t_1 = PyTuple_New(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
10890   __Pyx_GOTREF(__pyx_t_1);
10891   __pyx_t_2 = 0;
10892   __pyx_t_3 = 127;
10893   __Pyx_INCREF(__pyx_kp_u_token_2);
10894   __pyx_t_2 += 6;
10895   __Pyx_GIVEREF(__pyx_kp_u_token_2);
10896   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_token_2);
10897   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error)
10898   __Pyx_GOTREF(__pyx_t_5);
10899   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_repr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error)
10900   __Pyx_GOTREF(__pyx_t_6);
10901   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10902   __pyx_t_5 = NULL;
10903   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
10904     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
10905     if (likely(__pyx_t_5)) {
10906       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
10907       __Pyx_INCREF(__pyx_t_5);
10908       __Pyx_INCREF(function);
10909       __Pyx_DECREF_SET(__pyx_t_6, function);
10910     }
10911   }
10912   __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self);
10913   __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10914   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
10915   __Pyx_GOTREF(__pyx_t_4);
10916   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10917   __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error)
10918   __Pyx_GOTREF(__pyx_t_6);
10919   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10920   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_3;
10921   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
10922   __Pyx_GIVEREF(__pyx_t_6);
10923   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
10924   __pyx_t_6 = 0;
10925   __Pyx_INCREF(__pyx_kp_u__13);
10926   __pyx_t_2 += 2;
10927   __Pyx_GIVEREF(__pyx_kp_u__13);
10928   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__13);
10929   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error)
10930   __Pyx_GOTREF(__pyx_t_6);
10931   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_6), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
10932   __Pyx_GOTREF(__pyx_t_4);
10933   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10934   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
10935   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
10936   __Pyx_GIVEREF(__pyx_t_4);
10937   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
10938   __pyx_t_4 = 0;
10939   __Pyx_INCREF(__pyx_kp_u__13);
10940   __pyx_t_2 += 2;
10941   __Pyx_GIVEREF(__pyx_kp_u__13);
10942   PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u__13);
10943
10944   /* "lxml/html/diff.py":477
10945  *     def __repr__(self):
10946  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
10947  *                                           self.post_tags, self.trailing_whitespace)             # <<<<<<<<<<<<<<
10948  * 
10949  *     def html(self):
10950  */
10951   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error)
10952   __Pyx_GOTREF(__pyx_t_4);
10953   __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 477, __pyx_L1_error)
10954   __Pyx_GOTREF(__pyx_t_6);
10955   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10956   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_3;
10957   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
10958   __Pyx_GIVEREF(__pyx_t_6);
10959   PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_6);
10960   __pyx_t_6 = 0;
10961   __Pyx_INCREF(__pyx_kp_u__13);
10962   __pyx_t_2 += 2;
10963   __Pyx_GIVEREF(__pyx_kp_u__13);
10964   PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u__13);
10965   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 477, __pyx_L1_error)
10966   __Pyx_GOTREF(__pyx_t_6);
10967   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_6), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error)
10968   __Pyx_GOTREF(__pyx_t_4);
10969   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10970   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
10971   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
10972   __Pyx_GIVEREF(__pyx_t_4);
10973   PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_t_4);
10974   __pyx_t_4 = 0;
10975   __Pyx_INCREF(__pyx_kp_u__14);
10976   __pyx_t_2 += 1;
10977   __Pyx_GIVEREF(__pyx_kp_u__14);
10978   PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_kp_u__14);
10979
10980   /* "lxml/html/diff.py":476
10981  * 
10982  *     def __repr__(self):
10983  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,             # <<<<<<<<<<<<<<
10984  *                                           self.post_tags, self.trailing_whitespace)
10985  * 
10986  */
10987   __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 9, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
10988   __Pyx_GOTREF(__pyx_t_4);
10989   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10990   __pyx_r = __pyx_t_4;
10991   __pyx_t_4 = 0;
10992   goto __pyx_L0;
10993
10994   /* "lxml/html/diff.py":475
10995  *         return obj
10996  * 
10997  *     def __repr__(self):             # <<<<<<<<<<<<<<
10998  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
10999  *                                           self.post_tags, self.trailing_whitespace)
11000  */
11001
11002   /* function exit code */
11003   __pyx_L1_error:;
11004   __Pyx_XDECREF(__pyx_t_1);
11005   __Pyx_XDECREF(__pyx_t_4);
11006   __Pyx_XDECREF(__pyx_t_5);
11007   __Pyx_XDECREF(__pyx_t_6);
11008   __Pyx_AddTraceback("lxml.html.diff.token.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11009   __pyx_r = NULL;
11010   __pyx_L0:;
11011   __Pyx_XGIVEREF(__pyx_r);
11012   __Pyx_RefNannyFinishContext();
11013   return __pyx_r;
11014 }
11015
11016 /* "lxml/html/diff.py":479
11017  *                                           self.post_tags, self.trailing_whitespace)
11018  * 
11019  *     def html(self):             # <<<<<<<<<<<<<<
11020  *         return _unicode(self)
11021  * 
11022  */
11023
11024 /* Python wrapper */
11025 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_5html(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
11026 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_5token_5html = {"html", (PyCFunction)__pyx_pw_4lxml_4html_4diff_5token_5html, METH_O, 0};
11027 static PyObject *__pyx_pw_4lxml_4html_4diff_5token_5html(PyObject *__pyx_self, PyObject *__pyx_v_self) {
11028   PyObject *__pyx_r = 0;
11029   __Pyx_RefNannyDeclarations
11030   __Pyx_RefNannySetupContext("html (wrapper)", 0);
11031   __pyx_r = __pyx_pf_4lxml_4html_4diff_5token_4html(__pyx_self, ((PyObject *)__pyx_v_self));
11032
11033   /* function exit code */
11034   __Pyx_RefNannyFinishContext();
11035   return __pyx_r;
11036 }
11037
11038 static PyObject *__pyx_pf_4lxml_4html_4diff_5token_4html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
11039   PyObject *__pyx_r = NULL;
11040   __Pyx_RefNannyDeclarations
11041   PyObject *__pyx_t_1 = NULL;
11042   PyObject *__pyx_t_2 = NULL;
11043   PyObject *__pyx_t_3 = NULL;
11044   int __pyx_lineno = 0;
11045   const char *__pyx_filename = NULL;
11046   int __pyx_clineno = 0;
11047   __Pyx_RefNannySetupContext("html", 0);
11048
11049   /* "lxml/html/diff.py":480
11050  * 
11051  *     def html(self):
11052  *         return _unicode(self)             # <<<<<<<<<<<<<<
11053  * 
11054  * class tag_token(token):
11055  */
11056   __Pyx_XDECREF(__pyx_r);
11057   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 480, __pyx_L1_error)
11058   __Pyx_GOTREF(__pyx_t_2);
11059   __pyx_t_3 = NULL;
11060   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
11061     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
11062     if (likely(__pyx_t_3)) {
11063       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
11064       __Pyx_INCREF(__pyx_t_3);
11065       __Pyx_INCREF(function);
11066       __Pyx_DECREF_SET(__pyx_t_2, function);
11067     }
11068   }
11069   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self);
11070   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
11071   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
11072   __Pyx_GOTREF(__pyx_t_1);
11073   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11074   __pyx_r = __pyx_t_1;
11075   __pyx_t_1 = 0;
11076   goto __pyx_L0;
11077
11078   /* "lxml/html/diff.py":479
11079  *                                           self.post_tags, self.trailing_whitespace)
11080  * 
11081  *     def html(self):             # <<<<<<<<<<<<<<
11082  *         return _unicode(self)
11083  * 
11084  */
11085
11086   /* function exit code */
11087   __pyx_L1_error:;
11088   __Pyx_XDECREF(__pyx_t_1);
11089   __Pyx_XDECREF(__pyx_t_2);
11090   __Pyx_XDECREF(__pyx_t_3);
11091   __Pyx_AddTraceback("lxml.html.diff.token.html", __pyx_clineno, __pyx_lineno, __pyx_filename);
11092   __pyx_r = NULL;
11093   __pyx_L0:;
11094   __Pyx_XGIVEREF(__pyx_r);
11095   __Pyx_RefNannyFinishContext();
11096   return __pyx_r;
11097 }
11098
11099 /* "lxml/html/diff.py":488
11100  *     is only represented in a document by a tag.  """
11101  * 
11102  *     def __new__(cls, tag, data, html_repr, pre_tags=None,             # <<<<<<<<<<<<<<
11103  *                 post_tags=None, trailing_whitespace=""):
11104  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11105  */
11106
11107 /* Python wrapper */
11108 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
11109 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_9tag_token_1__new__ = {"__new__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_9tag_token_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
11110 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11111   PyObject *__pyx_v_cls = 0;
11112   PyObject *__pyx_v_tag = 0;
11113   PyObject *__pyx_v_data = 0;
11114   PyObject *__pyx_v_html_repr = 0;
11115   PyObject *__pyx_v_pre_tags = 0;
11116   PyObject *__pyx_v_post_tags = 0;
11117   PyObject *__pyx_v_trailing_whitespace = 0;
11118   int __pyx_lineno = 0;
11119   const char *__pyx_filename = NULL;
11120   int __pyx_clineno = 0;
11121   PyObject *__pyx_r = 0;
11122   __Pyx_RefNannyDeclarations
11123   __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
11124   {
11125     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_tag,&__pyx_n_s_data,&__pyx_n_s_html_repr,&__pyx_n_s_pre_tags,&__pyx_n_s_post_tags,&__pyx_n_s_trailing_whitespace,0};
11126     PyObject* values[7] = {0,0,0,0,0,0,0};
11127     values[4] = ((PyObject *)((PyObject *)Py_None));
11128
11129     /* "lxml/html/diff.py":489
11130  * 
11131  *     def __new__(cls, tag, data, html_repr, pre_tags=None,
11132  *                 post_tags=None, trailing_whitespace=""):             # <<<<<<<<<<<<<<
11133  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11134  *                             pre_tags=pre_tags,
11135  */
11136     values[5] = ((PyObject *)((PyObject *)Py_None));
11137     values[6] = ((PyObject *)((PyObject*)__pyx_kp_u__2));
11138     if (unlikely(__pyx_kwds)) {
11139       Py_ssize_t kw_args;
11140       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11141       switch (pos_args) {
11142         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
11143         CYTHON_FALLTHROUGH;
11144         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
11145         CYTHON_FALLTHROUGH;
11146         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
11147         CYTHON_FALLTHROUGH;
11148         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11149         CYTHON_FALLTHROUGH;
11150         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11151         CYTHON_FALLTHROUGH;
11152         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11153         CYTHON_FALLTHROUGH;
11154         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11155         CYTHON_FALLTHROUGH;
11156         case  0: break;
11157         default: goto __pyx_L5_argtuple_error;
11158       }
11159       kw_args = PyDict_Size(__pyx_kwds);
11160       switch (pos_args) {
11161         case  0:
11162         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
11163         else goto __pyx_L5_argtuple_error;
11164         CYTHON_FALLTHROUGH;
11165         case  1:
11166         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tag)) != 0)) kw_args--;
11167         else {
11168           __Pyx_RaiseArgtupleInvalid("__new__", 0, 4, 7, 1); __PYX_ERR(0, 488, __pyx_L3_error)
11169         }
11170         CYTHON_FALLTHROUGH;
11171         case  2:
11172         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
11173         else {
11174           __Pyx_RaiseArgtupleInvalid("__new__", 0, 4, 7, 2); __PYX_ERR(0, 488, __pyx_L3_error)
11175         }
11176         CYTHON_FALLTHROUGH;
11177         case  3:
11178         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_html_repr)) != 0)) kw_args--;
11179         else {
11180           __Pyx_RaiseArgtupleInvalid("__new__", 0, 4, 7, 3); __PYX_ERR(0, 488, __pyx_L3_error)
11181         }
11182         CYTHON_FALLTHROUGH;
11183         case  4:
11184         if (kw_args > 0) {
11185           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pre_tags);
11186           if (value) { values[4] = value; kw_args--; }
11187         }
11188         CYTHON_FALLTHROUGH;
11189         case  5:
11190         if (kw_args > 0) {
11191           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_tags);
11192           if (value) { values[5] = value; kw_args--; }
11193         }
11194         CYTHON_FALLTHROUGH;
11195         case  6:
11196         if (kw_args > 0) {
11197           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_trailing_whitespace);
11198           if (value) { values[6] = value; kw_args--; }
11199         }
11200       }
11201       if (unlikely(kw_args > 0)) {
11202         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 488, __pyx_L3_error)
11203       }
11204     } else {
11205       switch (PyTuple_GET_SIZE(__pyx_args)) {
11206         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
11207         CYTHON_FALLTHROUGH;
11208         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
11209         CYTHON_FALLTHROUGH;
11210         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
11211         CYTHON_FALLTHROUGH;
11212         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11213         values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11214         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11215         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11216         break;
11217         default: goto __pyx_L5_argtuple_error;
11218       }
11219     }
11220     __pyx_v_cls = values[0];
11221     __pyx_v_tag = values[1];
11222     __pyx_v_data = values[2];
11223     __pyx_v_html_repr = values[3];
11224     __pyx_v_pre_tags = values[4];
11225     __pyx_v_post_tags = values[5];
11226     __pyx_v_trailing_whitespace = values[6];
11227   }
11228   goto __pyx_L4_argument_unpacking_done;
11229   __pyx_L5_argtuple_error:;
11230   __Pyx_RaiseArgtupleInvalid("__new__", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 488, __pyx_L3_error)
11231   __pyx_L3_error:;
11232   __Pyx_AddTraceback("lxml.html.diff.tag_token.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11233   __Pyx_RefNannyFinishContext();
11234   return NULL;
11235   __pyx_L4_argument_unpacking_done:;
11236   __pyx_r = __pyx_pf_4lxml_4html_4diff_9tag_token___new__(__pyx_self, __pyx_v_cls, __pyx_v_tag, __pyx_v_data, __pyx_v_html_repr, __pyx_v_pre_tags, __pyx_v_post_tags, __pyx_v_trailing_whitespace);
11237
11238   /* "lxml/html/diff.py":488
11239  *     is only represented in a document by a tag.  """
11240  * 
11241  *     def __new__(cls, tag, data, html_repr, pre_tags=None,             # <<<<<<<<<<<<<<
11242  *                 post_tags=None, trailing_whitespace=""):
11243  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11244  */
11245
11246   /* function exit code */
11247   __Pyx_RefNannyFinishContext();
11248   return __pyx_r;
11249 }
11250
11251 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_tag, PyObject *__pyx_v_data, PyObject *__pyx_v_html_repr, PyObject *__pyx_v_pre_tags, PyObject *__pyx_v_post_tags, PyObject *__pyx_v_trailing_whitespace) {
11252   PyObject *__pyx_v_obj = NULL;
11253   PyObject *__pyx_r = NULL;
11254   __Pyx_RefNannyDeclarations
11255   PyObject *__pyx_t_1 = NULL;
11256   PyObject *__pyx_t_2 = NULL;
11257   Py_ssize_t __pyx_t_3;
11258   Py_UCS4 __pyx_t_4;
11259   PyObject *__pyx_t_5 = NULL;
11260   PyObject *__pyx_t_6 = NULL;
11261   int __pyx_lineno = 0;
11262   const char *__pyx_filename = NULL;
11263   int __pyx_clineno = 0;
11264   __Pyx_RefNannySetupContext("__new__", 0);
11265
11266   /* "lxml/html/diff.py":490
11267  *     def __new__(cls, tag, data, html_repr, pre_tags=None,
11268  *                 post_tags=None, trailing_whitespace=""):
11269  *         obj = token.__new__(cls, "%s: %s" % (type, data),             # <<<<<<<<<<<<<<
11270  *                             pre_tags=pre_tags,
11271  *                             post_tags=post_tags,
11272  */
11273   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
11274   __Pyx_GOTREF(__pyx_t_1);
11275   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error)
11276   __Pyx_GOTREF(__pyx_t_2);
11277   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11278   __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
11279   __Pyx_GOTREF(__pyx_t_1);
11280   __pyx_t_3 = 0;
11281   __pyx_t_4 = 127;
11282   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(((PyObject *)(&PyType_Type))), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 490, __pyx_L1_error)
11283   __Pyx_GOTREF(__pyx_t_5);
11284   __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_4;
11285   __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
11286   __Pyx_GIVEREF(__pyx_t_5);
11287   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
11288   __pyx_t_5 = 0;
11289   __Pyx_INCREF(__pyx_kp_u__15);
11290   __pyx_t_3 += 2;
11291   __Pyx_GIVEREF(__pyx_kp_u__15);
11292   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__15);
11293   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_data), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 490, __pyx_L1_error)
11294   __Pyx_GOTREF(__pyx_t_5);
11295   __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_4;
11296   __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
11297   __Pyx_GIVEREF(__pyx_t_5);
11298   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
11299   __pyx_t_5 = 0;
11300   __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 490, __pyx_L1_error)
11301   __Pyx_GOTREF(__pyx_t_5);
11302   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11303   __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
11304   __Pyx_GOTREF(__pyx_t_1);
11305   __Pyx_INCREF(__pyx_v_cls);
11306   __Pyx_GIVEREF(__pyx_v_cls);
11307   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cls);
11308   __Pyx_GIVEREF(__pyx_t_5);
11309   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
11310   __pyx_t_5 = 0;
11311
11312   /* "lxml/html/diff.py":491
11313  *                 post_tags=None, trailing_whitespace=""):
11314  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11315  *                             pre_tags=pre_tags,             # <<<<<<<<<<<<<<
11316  *                             post_tags=post_tags,
11317  *                             trailing_whitespace=trailing_whitespace)
11318  */
11319   __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 491, __pyx_L1_error)
11320   __Pyx_GOTREF(__pyx_t_5);
11321   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pre_tags, __pyx_v_pre_tags) < 0) __PYX_ERR(0, 491, __pyx_L1_error)
11322
11323   /* "lxml/html/diff.py":492
11324  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11325  *                             pre_tags=pre_tags,
11326  *                             post_tags=post_tags,             # <<<<<<<<<<<<<<
11327  *                             trailing_whitespace=trailing_whitespace)
11328  *         obj.tag = tag
11329  */
11330   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_post_tags, __pyx_v_post_tags) < 0) __PYX_ERR(0, 491, __pyx_L1_error)
11331
11332   /* "lxml/html/diff.py":493
11333  *                             pre_tags=pre_tags,
11334  *                             post_tags=post_tags,
11335  *                             trailing_whitespace=trailing_whitespace)             # <<<<<<<<<<<<<<
11336  *         obj.tag = tag
11337  *         obj.data = data
11338  */
11339   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_trailing_whitespace, __pyx_v_trailing_whitespace) < 0) __PYX_ERR(0, 491, __pyx_L1_error)
11340
11341   /* "lxml/html/diff.py":490
11342  *     def __new__(cls, tag, data, html_repr, pre_tags=None,
11343  *                 post_tags=None, trailing_whitespace=""):
11344  *         obj = token.__new__(cls, "%s: %s" % (type, data),             # <<<<<<<<<<<<<<
11345  *                             pre_tags=pre_tags,
11346  *                             post_tags=post_tags,
11347  */
11348   __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 490, __pyx_L1_error)
11349   __Pyx_GOTREF(__pyx_t_6);
11350   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11351   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11352   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11353   __pyx_v_obj = __pyx_t_6;
11354   __pyx_t_6 = 0;
11355
11356   /* "lxml/html/diff.py":494
11357  *                             post_tags=post_tags,
11358  *                             trailing_whitespace=trailing_whitespace)
11359  *         obj.tag = tag             # <<<<<<<<<<<<<<
11360  *         obj.data = data
11361  *         obj.html_repr = html_repr
11362  */
11363   if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_tag, __pyx_v_tag) < 0) __PYX_ERR(0, 494, __pyx_L1_error)
11364
11365   /* "lxml/html/diff.py":495
11366  *                             trailing_whitespace=trailing_whitespace)
11367  *         obj.tag = tag
11368  *         obj.data = data             # <<<<<<<<<<<<<<
11369  *         obj.html_repr = html_repr
11370  *         return obj
11371  */
11372   if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_data, __pyx_v_data) < 0) __PYX_ERR(0, 495, __pyx_L1_error)
11373
11374   /* "lxml/html/diff.py":496
11375  *         obj.tag = tag
11376  *         obj.data = data
11377  *         obj.html_repr = html_repr             # <<<<<<<<<<<<<<
11378  *         return obj
11379  * 
11380  */
11381   if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_html_repr, __pyx_v_html_repr) < 0) __PYX_ERR(0, 496, __pyx_L1_error)
11382
11383   /* "lxml/html/diff.py":497
11384  *         obj.data = data
11385  *         obj.html_repr = html_repr
11386  *         return obj             # <<<<<<<<<<<<<<
11387  * 
11388  *     def __repr__(self):
11389  */
11390   __Pyx_XDECREF(__pyx_r);
11391   __Pyx_INCREF(__pyx_v_obj);
11392   __pyx_r = __pyx_v_obj;
11393   goto __pyx_L0;
11394
11395   /* "lxml/html/diff.py":488
11396  *     is only represented in a document by a tag.  """
11397  * 
11398  *     def __new__(cls, tag, data, html_repr, pre_tags=None,             # <<<<<<<<<<<<<<
11399  *                 post_tags=None, trailing_whitespace=""):
11400  *         obj = token.__new__(cls, "%s: %s" % (type, data),
11401  */
11402
11403   /* function exit code */
11404   __pyx_L1_error:;
11405   __Pyx_XDECREF(__pyx_t_1);
11406   __Pyx_XDECREF(__pyx_t_2);
11407   __Pyx_XDECREF(__pyx_t_5);
11408   __Pyx_XDECREF(__pyx_t_6);
11409   __Pyx_AddTraceback("lxml.html.diff.tag_token.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11410   __pyx_r = NULL;
11411   __pyx_L0:;
11412   __Pyx_XDECREF(__pyx_v_obj);
11413   __Pyx_XGIVEREF(__pyx_r);
11414   __Pyx_RefNannyFinishContext();
11415   return __pyx_r;
11416 }
11417
11418 /* "lxml/html/diff.py":499
11419  *         return obj
11420  * 
11421  *     def __repr__(self):             # <<<<<<<<<<<<<<
11422  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
11423  *             self.tag,
11424  */
11425
11426 /* Python wrapper */
11427 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
11428 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_9tag_token_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_4lxml_4html_4diff_9tag_token_3__repr__, METH_O, 0};
11429 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
11430   PyObject *__pyx_r = 0;
11431   __Pyx_RefNannyDeclarations
11432   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
11433   __pyx_r = __pyx_pf_4lxml_4html_4diff_9tag_token_2__repr__(__pyx_self, ((PyObject *)__pyx_v_self));
11434
11435   /* function exit code */
11436   __Pyx_RefNannyFinishContext();
11437   return __pyx_r;
11438 }
11439
11440 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
11441   PyObject *__pyx_r = NULL;
11442   __Pyx_RefNannyDeclarations
11443   PyObject *__pyx_t_1 = NULL;
11444   Py_ssize_t __pyx_t_2;
11445   Py_UCS4 __pyx_t_3;
11446   PyObject *__pyx_t_4 = NULL;
11447   PyObject *__pyx_t_5 = NULL;
11448   int __pyx_lineno = 0;
11449   const char *__pyx_filename = NULL;
11450   int __pyx_clineno = 0;
11451   __Pyx_RefNannySetupContext("__repr__", 0);
11452
11453   /* "lxml/html/diff.py":500
11454  * 
11455  *     def __repr__(self):
11456  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (             # <<<<<<<<<<<<<<
11457  *             self.tag,
11458  *             self.data,
11459  */
11460   __Pyx_XDECREF(__pyx_r);
11461   __pyx_t_1 = PyTuple_New(13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error)
11462   __Pyx_GOTREF(__pyx_t_1);
11463   __pyx_t_2 = 0;
11464   __pyx_t_3 = 127;
11465   __Pyx_INCREF(__pyx_kp_u_tag_token);
11466   __pyx_t_2 += 10;
11467   __Pyx_GIVEREF(__pyx_kp_u_tag_token);
11468   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_tag_token);
11469
11470   /* "lxml/html/diff.py":501
11471  *     def __repr__(self):
11472  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
11473  *             self.tag,             # <<<<<<<<<<<<<<
11474  *             self.data,
11475  *             self.html_repr,
11476  */
11477   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_tag); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
11478   __Pyx_GOTREF(__pyx_t_4);
11479   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 501, __pyx_L1_error)
11480   __Pyx_GOTREF(__pyx_t_5);
11481   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11482   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
11483   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
11484   __Pyx_GIVEREF(__pyx_t_5);
11485   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
11486   __pyx_t_5 = 0;
11487   __Pyx_INCREF(__pyx_kp_u__13);
11488   __pyx_t_2 += 2;
11489   __Pyx_GIVEREF(__pyx_kp_u__13);
11490   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__13);
11491
11492   /* "lxml/html/diff.py":502
11493  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
11494  *             self.tag,
11495  *             self.data,             # <<<<<<<<<<<<<<
11496  *             self.html_repr,
11497  *             self.pre_tags,
11498  */
11499   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 502, __pyx_L1_error)
11500   __Pyx_GOTREF(__pyx_t_5);
11501   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 502, __pyx_L1_error)
11502   __Pyx_GOTREF(__pyx_t_4);
11503   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11504   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
11505   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
11506   __Pyx_GIVEREF(__pyx_t_4);
11507   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
11508   __pyx_t_4 = 0;
11509   __Pyx_INCREF(__pyx_kp_u_html_repr_2);
11510   __pyx_t_2 += 12;
11511   __Pyx_GIVEREF(__pyx_kp_u_html_repr_2);
11512   PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_html_repr_2);
11513
11514   /* "lxml/html/diff.py":503
11515  *             self.tag,
11516  *             self.data,
11517  *             self.html_repr,             # <<<<<<<<<<<<<<
11518  *             self.pre_tags,
11519  *             self.post_tags,
11520  */
11521   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_html_repr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
11522   __Pyx_GOTREF(__pyx_t_4);
11523   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 503, __pyx_L1_error)
11524   __Pyx_GOTREF(__pyx_t_5);
11525   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11526   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
11527   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
11528   __Pyx_GIVEREF(__pyx_t_5);
11529   PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_5);
11530   __pyx_t_5 = 0;
11531   __Pyx_INCREF(__pyx_kp_u_post_tags_2);
11532   __pyx_t_2 += 12;
11533   __Pyx_GIVEREF(__pyx_kp_u_post_tags_2);
11534   PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u_post_tags_2);
11535
11536   /* "lxml/html/diff.py":504
11537  *             self.data,
11538  *             self.html_repr,
11539  *             self.pre_tags,             # <<<<<<<<<<<<<<
11540  *             self.post_tags,
11541  *             self.trailing_whitespace)
11542  */
11543   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pre_tags); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error)
11544   __Pyx_GOTREF(__pyx_t_5);
11545   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
11546   __Pyx_GOTREF(__pyx_t_4);
11547   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11548   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
11549   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
11550   __Pyx_GIVEREF(__pyx_t_4);
11551   PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_t_4);
11552   __pyx_t_4 = 0;
11553   __Pyx_INCREF(__pyx_kp_u_pre_tags_2);
11554   __pyx_t_2 += 11;
11555   __Pyx_GIVEREF(__pyx_kp_u_pre_tags_2);
11556   PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_kp_u_pre_tags_2);
11557
11558   /* "lxml/html/diff.py":505
11559  *             self.html_repr,
11560  *             self.pre_tags,
11561  *             self.post_tags,             # <<<<<<<<<<<<<<
11562  *             self.trailing_whitespace)
11563  *     def html(self):
11564  */
11565   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 505, __pyx_L1_error)
11566   __Pyx_GOTREF(__pyx_t_4);
11567   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 505, __pyx_L1_error)
11568   __Pyx_GOTREF(__pyx_t_5);
11569   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11570   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
11571   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
11572   __Pyx_GIVEREF(__pyx_t_5);
11573   PyTuple_SET_ITEM(__pyx_t_1, 9, __pyx_t_5);
11574   __pyx_t_5 = 0;
11575   __Pyx_INCREF(__pyx_kp_u_trailing_whitespace_2);
11576   __pyx_t_2 += 22;
11577   __Pyx_GIVEREF(__pyx_kp_u_trailing_whitespace_2);
11578   PyTuple_SET_ITEM(__pyx_t_1, 10, __pyx_kp_u_trailing_whitespace_2);
11579
11580   /* "lxml/html/diff.py":506
11581  *             self.pre_tags,
11582  *             self.post_tags,
11583  *             self.trailing_whitespace)             # <<<<<<<<<<<<<<
11584  *     def html(self):
11585  *         return self.html_repr
11586  */
11587   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trailing_whitespace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 506, __pyx_L1_error)
11588   __Pyx_GOTREF(__pyx_t_5);
11589   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 506, __pyx_L1_error)
11590   __Pyx_GOTREF(__pyx_t_4);
11591   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11592   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
11593   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
11594   __Pyx_GIVEREF(__pyx_t_4);
11595   PyTuple_SET_ITEM(__pyx_t_1, 11, __pyx_t_4);
11596   __pyx_t_4 = 0;
11597   __Pyx_INCREF(__pyx_kp_u__14);
11598   __pyx_t_2 += 1;
11599   __Pyx_GIVEREF(__pyx_kp_u__14);
11600   PyTuple_SET_ITEM(__pyx_t_1, 12, __pyx_kp_u__14);
11601
11602   /* "lxml/html/diff.py":500
11603  * 
11604  *     def __repr__(self):
11605  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (             # <<<<<<<<<<<<<<
11606  *             self.tag,
11607  *             self.data,
11608  */
11609   __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 13, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 500, __pyx_L1_error)
11610   __Pyx_GOTREF(__pyx_t_4);
11611   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11612   __pyx_r = __pyx_t_4;
11613   __pyx_t_4 = 0;
11614   goto __pyx_L0;
11615
11616   /* "lxml/html/diff.py":499
11617  *         return obj
11618  * 
11619  *     def __repr__(self):             # <<<<<<<<<<<<<<
11620  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
11621  *             self.tag,
11622  */
11623
11624   /* function exit code */
11625   __pyx_L1_error:;
11626   __Pyx_XDECREF(__pyx_t_1);
11627   __Pyx_XDECREF(__pyx_t_4);
11628   __Pyx_XDECREF(__pyx_t_5);
11629   __Pyx_AddTraceback("lxml.html.diff.tag_token.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11630   __pyx_r = NULL;
11631   __pyx_L0:;
11632   __Pyx_XGIVEREF(__pyx_r);
11633   __Pyx_RefNannyFinishContext();
11634   return __pyx_r;
11635 }
11636
11637 /* "lxml/html/diff.py":507
11638  *             self.post_tags,
11639  *             self.trailing_whitespace)
11640  *     def html(self):             # <<<<<<<<<<<<<<
11641  *         return self.html_repr
11642  * 
11643  */
11644
11645 /* Python wrapper */
11646 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_5html(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
11647 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_9tag_token_5html = {"html", (PyCFunction)__pyx_pw_4lxml_4html_4diff_9tag_token_5html, METH_O, 0};
11648 static PyObject *__pyx_pw_4lxml_4html_4diff_9tag_token_5html(PyObject *__pyx_self, PyObject *__pyx_v_self) {
11649   PyObject *__pyx_r = 0;
11650   __Pyx_RefNannyDeclarations
11651   __Pyx_RefNannySetupContext("html (wrapper)", 0);
11652   __pyx_r = __pyx_pf_4lxml_4html_4diff_9tag_token_4html(__pyx_self, ((PyObject *)__pyx_v_self));
11653
11654   /* function exit code */
11655   __Pyx_RefNannyFinishContext();
11656   return __pyx_r;
11657 }
11658
11659 static PyObject *__pyx_pf_4lxml_4html_4diff_9tag_token_4html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
11660   PyObject *__pyx_r = NULL;
11661   __Pyx_RefNannyDeclarations
11662   PyObject *__pyx_t_1 = NULL;
11663   int __pyx_lineno = 0;
11664   const char *__pyx_filename = NULL;
11665   int __pyx_clineno = 0;
11666   __Pyx_RefNannySetupContext("html", 0);
11667
11668   /* "lxml/html/diff.py":508
11669  *             self.trailing_whitespace)
11670  *     def html(self):
11671  *         return self.html_repr             # <<<<<<<<<<<<<<
11672  * 
11673  * class href_token(token):
11674  */
11675   __Pyx_XDECREF(__pyx_r);
11676   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_html_repr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 508, __pyx_L1_error)
11677   __Pyx_GOTREF(__pyx_t_1);
11678   __pyx_r = __pyx_t_1;
11679   __pyx_t_1 = 0;
11680   goto __pyx_L0;
11681
11682   /* "lxml/html/diff.py":507
11683  *             self.post_tags,
11684  *             self.trailing_whitespace)
11685  *     def html(self):             # <<<<<<<<<<<<<<
11686  *         return self.html_repr
11687  * 
11688  */
11689
11690   /* function exit code */
11691   __pyx_L1_error:;
11692   __Pyx_XDECREF(__pyx_t_1);
11693   __Pyx_AddTraceback("lxml.html.diff.tag_token.html", __pyx_clineno, __pyx_lineno, __pyx_filename);
11694   __pyx_r = NULL;
11695   __pyx_L0:;
11696   __Pyx_XGIVEREF(__pyx_r);
11697   __Pyx_RefNannyFinishContext();
11698   return __pyx_r;
11699 }
11700
11701 /* "lxml/html/diff.py":517
11702  *     hide_when_equal = True
11703  * 
11704  *     def html(self):             # <<<<<<<<<<<<<<
11705  *         return ' Link: %s' % self
11706  * 
11707  */
11708
11709 /* Python wrapper */
11710 static PyObject *__pyx_pw_4lxml_4html_4diff_10href_token_1html(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
11711 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_10href_token_1html = {"html", (PyCFunction)__pyx_pw_4lxml_4html_4diff_10href_token_1html, METH_O, 0};
11712 static PyObject *__pyx_pw_4lxml_4html_4diff_10href_token_1html(PyObject *__pyx_self, PyObject *__pyx_v_self) {
11713   PyObject *__pyx_r = 0;
11714   __Pyx_RefNannyDeclarations
11715   __Pyx_RefNannySetupContext("html (wrapper)", 0);
11716   __pyx_r = __pyx_pf_4lxml_4html_4diff_10href_token_html(__pyx_self, ((PyObject *)__pyx_v_self));
11717
11718   /* function exit code */
11719   __Pyx_RefNannyFinishContext();
11720   return __pyx_r;
11721 }
11722
11723 static PyObject *__pyx_pf_4lxml_4html_4diff_10href_token_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
11724   PyObject *__pyx_r = NULL;
11725   __Pyx_RefNannyDeclarations
11726   PyObject *__pyx_t_1 = NULL;
11727   int __pyx_lineno = 0;
11728   const char *__pyx_filename = NULL;
11729   int __pyx_clineno = 0;
11730   __Pyx_RefNannySetupContext("html", 0);
11731
11732   /* "lxml/html/diff.py":518
11733  * 
11734  *     def html(self):
11735  *         return ' Link: %s' % self             # <<<<<<<<<<<<<<
11736  * 
11737  * def tokenize(html, include_hrefs=True):
11738  */
11739   __Pyx_XDECREF(__pyx_r);
11740   __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Link_s, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
11741   __Pyx_GOTREF(__pyx_t_1);
11742   __pyx_r = __pyx_t_1;
11743   __pyx_t_1 = 0;
11744   goto __pyx_L0;
11745
11746   /* "lxml/html/diff.py":517
11747  *     hide_when_equal = True
11748  * 
11749  *     def html(self):             # <<<<<<<<<<<<<<
11750  *         return ' Link: %s' % self
11751  * 
11752  */
11753
11754   /* function exit code */
11755   __pyx_L1_error:;
11756   __Pyx_XDECREF(__pyx_t_1);
11757   __Pyx_AddTraceback("lxml.html.diff.href_token.html", __pyx_clineno, __pyx_lineno, __pyx_filename);
11758   __pyx_r = NULL;
11759   __pyx_L0:;
11760   __Pyx_XGIVEREF(__pyx_r);
11761   __Pyx_RefNannyFinishContext();
11762   return __pyx_r;
11763 }
11764
11765 /* "lxml/html/diff.py":520
11766  *         return ' Link: %s' % self
11767  * 
11768  * def tokenize(html, include_hrefs=True):             # <<<<<<<<<<<<<<
11769  *     """
11770  *     Parse the given HTML and returns token objects (words with attached tags).
11771  */
11772
11773 /* Python wrapper */
11774 static PyObject *__pyx_pw_4lxml_4html_4diff_39tokenize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
11775 static char __pyx_doc_4lxml_4html_4diff_38tokenize[] = "\n    Parse the given HTML and returns token objects (words with attached tags).\n\n    This parses only the content of a page; anything in the head is\n    ignored, and the <head> and <body> elements are themselves\n    optional.  The content is then parsed by lxml, which ensures the\n    validity of the resulting parsed document (though lxml may make\n    incorrect guesses when the markup is particular bad).\n\n    <ins> and <del> tags are also eliminated from the document, as\n    that gets confusing.\n\n    If include_hrefs is true, then the href attribute of <a> tags is\n    included as a special kind of diffable token.";
11776 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_39tokenize = {"tokenize", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_39tokenize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_38tokenize};
11777 static PyObject *__pyx_pw_4lxml_4html_4diff_39tokenize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11778   PyObject *__pyx_v_html = 0;
11779   PyObject *__pyx_v_include_hrefs = 0;
11780   int __pyx_lineno = 0;
11781   const char *__pyx_filename = NULL;
11782   int __pyx_clineno = 0;
11783   PyObject *__pyx_r = 0;
11784   __Pyx_RefNannyDeclarations
11785   __Pyx_RefNannySetupContext("tokenize (wrapper)", 0);
11786   {
11787     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_html,&__pyx_n_s_include_hrefs,0};
11788     PyObject* values[2] = {0,0};
11789     values[1] = ((PyObject *)((PyObject *)Py_True));
11790     if (unlikely(__pyx_kwds)) {
11791       Py_ssize_t kw_args;
11792       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11793       switch (pos_args) {
11794         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11795         CYTHON_FALLTHROUGH;
11796         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11797         CYTHON_FALLTHROUGH;
11798         case  0: break;
11799         default: goto __pyx_L5_argtuple_error;
11800       }
11801       kw_args = PyDict_Size(__pyx_kwds);
11802       switch (pos_args) {
11803         case  0:
11804         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_html)) != 0)) kw_args--;
11805         else goto __pyx_L5_argtuple_error;
11806         CYTHON_FALLTHROUGH;
11807         case  1:
11808         if (kw_args > 0) {
11809           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_include_hrefs);
11810           if (value) { values[1] = value; kw_args--; }
11811         }
11812       }
11813       if (unlikely(kw_args > 0)) {
11814         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tokenize") < 0)) __PYX_ERR(0, 520, __pyx_L3_error)
11815       }
11816     } else {
11817       switch (PyTuple_GET_SIZE(__pyx_args)) {
11818         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11819         CYTHON_FALLTHROUGH;
11820         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11821         break;
11822         default: goto __pyx_L5_argtuple_error;
11823       }
11824     }
11825     __pyx_v_html = values[0];
11826     __pyx_v_include_hrefs = values[1];
11827   }
11828   goto __pyx_L4_argument_unpacking_done;
11829   __pyx_L5_argtuple_error:;
11830   __Pyx_RaiseArgtupleInvalid("tokenize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 520, __pyx_L3_error)
11831   __pyx_L3_error:;
11832   __Pyx_AddTraceback("lxml.html.diff.tokenize", __pyx_clineno, __pyx_lineno, __pyx_filename);
11833   __Pyx_RefNannyFinishContext();
11834   return NULL;
11835   __pyx_L4_argument_unpacking_done:;
11836   __pyx_r = __pyx_pf_4lxml_4html_4diff_38tokenize(__pyx_self, __pyx_v_html, __pyx_v_include_hrefs);
11837
11838   /* function exit code */
11839   __Pyx_RefNannyFinishContext();
11840   return __pyx_r;
11841 }
11842
11843 static PyObject *__pyx_pf_4lxml_4html_4diff_38tokenize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html, PyObject *__pyx_v_include_hrefs) {
11844   PyObject *__pyx_v_body_el = NULL;
11845   PyObject *__pyx_v_chunks = NULL;
11846   PyObject *__pyx_r = NULL;
11847   __Pyx_RefNannyDeclarations
11848   PyObject *__pyx_t_1 = NULL;
11849   PyObject *__pyx_t_2 = NULL;
11850   PyObject *__pyx_t_3 = NULL;
11851   int __pyx_t_4;
11852   PyObject *__pyx_t_5 = NULL;
11853   int __pyx_lineno = 0;
11854   const char *__pyx_filename = NULL;
11855   int __pyx_clineno = 0;
11856   __Pyx_RefNannySetupContext("tokenize", 0);
11857
11858   /* "lxml/html/diff.py":535
11859  *     If include_hrefs is true, then the href attribute of <a> tags is
11860  *     included as a special kind of diffable token."""
11861  *     if etree.iselement(html):             # <<<<<<<<<<<<<<
11862  *         body_el = html
11863  *     else:
11864  */
11865   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_etree); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
11866   __Pyx_GOTREF(__pyx_t_2);
11867   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iselement); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
11868   __Pyx_GOTREF(__pyx_t_3);
11869   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11870   __pyx_t_2 = NULL;
11871   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
11872     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
11873     if (likely(__pyx_t_2)) {
11874       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11875       __Pyx_INCREF(__pyx_t_2);
11876       __Pyx_INCREF(function);
11877       __Pyx_DECREF_SET(__pyx_t_3, function);
11878     }
11879   }
11880   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_html) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_html);
11881   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
11882   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
11883   __Pyx_GOTREF(__pyx_t_1);
11884   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11885   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 535, __pyx_L1_error)
11886   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11887   if (__pyx_t_4) {
11888
11889     /* "lxml/html/diff.py":536
11890  *     included as a special kind of diffable token."""
11891  *     if etree.iselement(html):
11892  *         body_el = html             # <<<<<<<<<<<<<<
11893  *     else:
11894  *         body_el = parse_html(html, cleanup=True)
11895  */
11896     __Pyx_INCREF(__pyx_v_html);
11897     __pyx_v_body_el = __pyx_v_html;
11898
11899     /* "lxml/html/diff.py":535
11900  *     If include_hrefs is true, then the href attribute of <a> tags is
11901  *     included as a special kind of diffable token."""
11902  *     if etree.iselement(html):             # <<<<<<<<<<<<<<
11903  *         body_el = html
11904  *     else:
11905  */
11906     goto __pyx_L3;
11907   }
11908
11909   /* "lxml/html/diff.py":538
11910  *         body_el = html
11911  *     else:
11912  *         body_el = parse_html(html, cleanup=True)             # <<<<<<<<<<<<<<
11913  *     # Then we split the document into text chunks for each tag, word, and end tag:
11914  *     chunks = flatten_el(body_el, skip_tag=True, include_hrefs=include_hrefs)
11915  */
11916   /*else*/ {
11917     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_parse_html); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
11918     __Pyx_GOTREF(__pyx_t_1);
11919     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 538, __pyx_L1_error)
11920     __Pyx_GOTREF(__pyx_t_3);
11921     __Pyx_INCREF(__pyx_v_html);
11922     __Pyx_GIVEREF(__pyx_v_html);
11923     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_html);
11924     __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
11925     __Pyx_GOTREF(__pyx_t_2);
11926     if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_cleanup, Py_True) < 0) __PYX_ERR(0, 538, __pyx_L1_error)
11927     __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
11928     __Pyx_GOTREF(__pyx_t_5);
11929     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11930     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11931     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11932     __pyx_v_body_el = __pyx_t_5;
11933     __pyx_t_5 = 0;
11934   }
11935   __pyx_L3:;
11936
11937   /* "lxml/html/diff.py":540
11938  *         body_el = parse_html(html, cleanup=True)
11939  *     # Then we split the document into text chunks for each tag, word, and end tag:
11940  *     chunks = flatten_el(body_el, skip_tag=True, include_hrefs=include_hrefs)             # <<<<<<<<<<<<<<
11941  *     # Finally re-joining them into token objects:
11942  *     return fixup_chunks(chunks)
11943  */
11944   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_flatten_el); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 540, __pyx_L1_error)
11945   __Pyx_GOTREF(__pyx_t_5);
11946   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
11947   __Pyx_GOTREF(__pyx_t_2);
11948   __Pyx_INCREF(__pyx_v_body_el);
11949   __Pyx_GIVEREF(__pyx_v_body_el);
11950   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_body_el);
11951   __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 540, __pyx_L1_error)
11952   __Pyx_GOTREF(__pyx_t_3);
11953   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_skip_tag, Py_True) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
11954   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_include_hrefs, __pyx_v_include_hrefs) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
11955   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
11956   __Pyx_GOTREF(__pyx_t_1);
11957   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11958   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11959   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11960   __pyx_v_chunks = __pyx_t_1;
11961   __pyx_t_1 = 0;
11962
11963   /* "lxml/html/diff.py":542
11964  *     chunks = flatten_el(body_el, skip_tag=True, include_hrefs=include_hrefs)
11965  *     # Finally re-joining them into token objects:
11966  *     return fixup_chunks(chunks)             # <<<<<<<<<<<<<<
11967  * 
11968  * def parse_html(html, cleanup=True):
11969  */
11970   __Pyx_XDECREF(__pyx_r);
11971   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_fixup_chunks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
11972   __Pyx_GOTREF(__pyx_t_3);
11973   __pyx_t_2 = NULL;
11974   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
11975     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
11976     if (likely(__pyx_t_2)) {
11977       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11978       __Pyx_INCREF(__pyx_t_2);
11979       __Pyx_INCREF(function);
11980       __Pyx_DECREF_SET(__pyx_t_3, function);
11981     }
11982   }
11983   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_chunks) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_chunks);
11984   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
11985   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
11986   __Pyx_GOTREF(__pyx_t_1);
11987   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11988   __pyx_r = __pyx_t_1;
11989   __pyx_t_1 = 0;
11990   goto __pyx_L0;
11991
11992   /* "lxml/html/diff.py":520
11993  *         return ' Link: %s' % self
11994  * 
11995  * def tokenize(html, include_hrefs=True):             # <<<<<<<<<<<<<<
11996  *     """
11997  *     Parse the given HTML and returns token objects (words with attached tags).
11998  */
11999
12000   /* function exit code */
12001   __pyx_L1_error:;
12002   __Pyx_XDECREF(__pyx_t_1);
12003   __Pyx_XDECREF(__pyx_t_2);
12004   __Pyx_XDECREF(__pyx_t_3);
12005   __Pyx_XDECREF(__pyx_t_5);
12006   __Pyx_AddTraceback("lxml.html.diff.tokenize", __pyx_clineno, __pyx_lineno, __pyx_filename);
12007   __pyx_r = NULL;
12008   __pyx_L0:;
12009   __Pyx_XDECREF(__pyx_v_body_el);
12010   __Pyx_XDECREF(__pyx_v_chunks);
12011   __Pyx_XGIVEREF(__pyx_r);
12012   __Pyx_RefNannyFinishContext();
12013   return __pyx_r;
12014 }
12015
12016 /* "lxml/html/diff.py":544
12017  *     return fixup_chunks(chunks)
12018  * 
12019  * def parse_html(html, cleanup=True):             # <<<<<<<<<<<<<<
12020  *     """
12021  *     Parses an HTML fragment, returning an lxml element.  Note that the HTML will be
12022  */
12023
12024 /* Python wrapper */
12025 static PyObject *__pyx_pw_4lxml_4html_4diff_41parse_html(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
12026 static char __pyx_doc_4lxml_4html_4diff_40parse_html[] = "\n    Parses an HTML fragment, returning an lxml element.  Note that the HTML will be\n    wrapped in a <div> tag that was not in the original document.\n\n    If cleanup is true, make sure there's no <head> or <body>, and get\n    rid of any <ins> and <del> tags.\n    ";
12027 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_41parse_html = {"parse_html", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_41parse_html, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_40parse_html};
12028 static PyObject *__pyx_pw_4lxml_4html_4diff_41parse_html(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12029   PyObject *__pyx_v_html = 0;
12030   PyObject *__pyx_v_cleanup = 0;
12031   int __pyx_lineno = 0;
12032   const char *__pyx_filename = NULL;
12033   int __pyx_clineno = 0;
12034   PyObject *__pyx_r = 0;
12035   __Pyx_RefNannyDeclarations
12036   __Pyx_RefNannySetupContext("parse_html (wrapper)", 0);
12037   {
12038     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_html,&__pyx_n_s_cleanup,0};
12039     PyObject* values[2] = {0,0};
12040     values[1] = ((PyObject *)((PyObject *)Py_True));
12041     if (unlikely(__pyx_kwds)) {
12042       Py_ssize_t kw_args;
12043       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12044       switch (pos_args) {
12045         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12046         CYTHON_FALLTHROUGH;
12047         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12048         CYTHON_FALLTHROUGH;
12049         case  0: break;
12050         default: goto __pyx_L5_argtuple_error;
12051       }
12052       kw_args = PyDict_Size(__pyx_kwds);
12053       switch (pos_args) {
12054         case  0:
12055         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_html)) != 0)) kw_args--;
12056         else goto __pyx_L5_argtuple_error;
12057         CYTHON_FALLTHROUGH;
12058         case  1:
12059         if (kw_args > 0) {
12060           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cleanup);
12061           if (value) { values[1] = value; kw_args--; }
12062         }
12063       }
12064       if (unlikely(kw_args > 0)) {
12065         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "parse_html") < 0)) __PYX_ERR(0, 544, __pyx_L3_error)
12066       }
12067     } else {
12068       switch (PyTuple_GET_SIZE(__pyx_args)) {
12069         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12070         CYTHON_FALLTHROUGH;
12071         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12072         break;
12073         default: goto __pyx_L5_argtuple_error;
12074       }
12075     }
12076     __pyx_v_html = values[0];
12077     __pyx_v_cleanup = values[1];
12078   }
12079   goto __pyx_L4_argument_unpacking_done;
12080   __pyx_L5_argtuple_error:;
12081   __Pyx_RaiseArgtupleInvalid("parse_html", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 544, __pyx_L3_error)
12082   __pyx_L3_error:;
12083   __Pyx_AddTraceback("lxml.html.diff.parse_html", __pyx_clineno, __pyx_lineno, __pyx_filename);
12084   __Pyx_RefNannyFinishContext();
12085   return NULL;
12086   __pyx_L4_argument_unpacking_done:;
12087   __pyx_r = __pyx_pf_4lxml_4html_4diff_40parse_html(__pyx_self, __pyx_v_html, __pyx_v_cleanup);
12088
12089   /* function exit code */
12090   __Pyx_RefNannyFinishContext();
12091   return __pyx_r;
12092 }
12093
12094 static PyObject *__pyx_pf_4lxml_4html_4diff_40parse_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html, PyObject *__pyx_v_cleanup) {
12095   PyObject *__pyx_r = NULL;
12096   __Pyx_RefNannyDeclarations
12097   int __pyx_t_1;
12098   PyObject *__pyx_t_2 = NULL;
12099   PyObject *__pyx_t_3 = NULL;
12100   PyObject *__pyx_t_4 = NULL;
12101   PyObject *__pyx_t_5 = NULL;
12102   int __pyx_lineno = 0;
12103   const char *__pyx_filename = NULL;
12104   int __pyx_clineno = 0;
12105   __Pyx_RefNannySetupContext("parse_html", 0);
12106   __Pyx_INCREF(__pyx_v_html);
12107
12108   /* "lxml/html/diff.py":552
12109  *     rid of any <ins> and <del> tags.
12110  *     """
12111  *     if cleanup:             # <<<<<<<<<<<<<<
12112  *         # This removes any extra markup or structure like <head>:
12113  *         html = cleanup_html(html)
12114  */
12115   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_cleanup); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 552, __pyx_L1_error)
12116   if (__pyx_t_1) {
12117
12118     /* "lxml/html/diff.py":554
12119  *     if cleanup:
12120  *         # This removes any extra markup or structure like <head>:
12121  *         html = cleanup_html(html)             # <<<<<<<<<<<<<<
12122  *     return fragment_fromstring(html, create_parent=True)
12123  * 
12124  */
12125     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cleanup_html); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 554, __pyx_L1_error)
12126     __Pyx_GOTREF(__pyx_t_3);
12127     __pyx_t_4 = NULL;
12128     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
12129       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
12130       if (likely(__pyx_t_4)) {
12131         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12132         __Pyx_INCREF(__pyx_t_4);
12133         __Pyx_INCREF(function);
12134         __Pyx_DECREF_SET(__pyx_t_3, function);
12135       }
12136     }
12137     __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_html) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_html);
12138     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
12139     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 554, __pyx_L1_error)
12140     __Pyx_GOTREF(__pyx_t_2);
12141     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12142     __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_2);
12143     __pyx_t_2 = 0;
12144
12145     /* "lxml/html/diff.py":552
12146  *     rid of any <ins> and <del> tags.
12147  *     """
12148  *     if cleanup:             # <<<<<<<<<<<<<<
12149  *         # This removes any extra markup or structure like <head>:
12150  *         html = cleanup_html(html)
12151  */
12152   }
12153
12154   /* "lxml/html/diff.py":555
12155  *         # This removes any extra markup or structure like <head>:
12156  *         html = cleanup_html(html)
12157  *     return fragment_fromstring(html, create_parent=True)             # <<<<<<<<<<<<<<
12158  * 
12159  * _body_re = re.compile(r'<body.*?>', re.I|re.S)
12160  */
12161   __Pyx_XDECREF(__pyx_r);
12162   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_fragment_fromstring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 555, __pyx_L1_error)
12163   __Pyx_GOTREF(__pyx_t_2);
12164   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
12165   __Pyx_GOTREF(__pyx_t_3);
12166   __Pyx_INCREF(__pyx_v_html);
12167   __Pyx_GIVEREF(__pyx_v_html);
12168   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_html);
12169   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 555, __pyx_L1_error)
12170   __Pyx_GOTREF(__pyx_t_4);
12171   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_create_parent, Py_True) < 0) __PYX_ERR(0, 555, __pyx_L1_error)
12172   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 555, __pyx_L1_error)
12173   __Pyx_GOTREF(__pyx_t_5);
12174   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12175   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12176   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12177   __pyx_r = __pyx_t_5;
12178   __pyx_t_5 = 0;
12179   goto __pyx_L0;
12180
12181   /* "lxml/html/diff.py":544
12182  *     return fixup_chunks(chunks)
12183  * 
12184  * def parse_html(html, cleanup=True):             # <<<<<<<<<<<<<<
12185  *     """
12186  *     Parses an HTML fragment, returning an lxml element.  Note that the HTML will be
12187  */
12188
12189   /* function exit code */
12190   __pyx_L1_error:;
12191   __Pyx_XDECREF(__pyx_t_2);
12192   __Pyx_XDECREF(__pyx_t_3);
12193   __Pyx_XDECREF(__pyx_t_4);
12194   __Pyx_XDECREF(__pyx_t_5);
12195   __Pyx_AddTraceback("lxml.html.diff.parse_html", __pyx_clineno, __pyx_lineno, __pyx_filename);
12196   __pyx_r = NULL;
12197   __pyx_L0:;
12198   __Pyx_XDECREF(__pyx_v_html);
12199   __Pyx_XGIVEREF(__pyx_r);
12200   __Pyx_RefNannyFinishContext();
12201   return __pyx_r;
12202 }
12203
12204 /* "lxml/html/diff.py":561
12205  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
12206  * 
12207  * def cleanup_html(html):             # <<<<<<<<<<<<<<
12208  *     """ This 'cleans' the HTML, meaning that any page structure is removed
12209  *     (only the contents of <body> are used, if there is any <body).
12210  */
12211
12212 /* Python wrapper */
12213 static PyObject *__pyx_pw_4lxml_4html_4diff_43cleanup_html(PyObject *__pyx_self, PyObject *__pyx_v_html); /*proto*/
12214 static char __pyx_doc_4lxml_4html_4diff_42cleanup_html[] = " This 'cleans' the HTML, meaning that any page structure is removed\n    (only the contents of <body> are used, if there is any <body).\n    Also <ins> and <del> tags are removed.  ";
12215 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_43cleanup_html = {"cleanup_html", (PyCFunction)__pyx_pw_4lxml_4html_4diff_43cleanup_html, METH_O, __pyx_doc_4lxml_4html_4diff_42cleanup_html};
12216 static PyObject *__pyx_pw_4lxml_4html_4diff_43cleanup_html(PyObject *__pyx_self, PyObject *__pyx_v_html) {
12217   PyObject *__pyx_r = 0;
12218   __Pyx_RefNannyDeclarations
12219   __Pyx_RefNannySetupContext("cleanup_html (wrapper)", 0);
12220   __pyx_r = __pyx_pf_4lxml_4html_4diff_42cleanup_html(__pyx_self, ((PyObject *)__pyx_v_html));
12221
12222   /* function exit code */
12223   __Pyx_RefNannyFinishContext();
12224   return __pyx_r;
12225 }
12226
12227 static PyObject *__pyx_pf_4lxml_4html_4diff_42cleanup_html(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html) {
12228   PyObject *__pyx_v_match = NULL;
12229   PyObject *__pyx_r = NULL;
12230   __Pyx_RefNannyDeclarations
12231   PyObject *__pyx_t_1 = NULL;
12232   PyObject *__pyx_t_2 = NULL;
12233   PyObject *__pyx_t_3 = NULL;
12234   int __pyx_t_4;
12235   int __pyx_t_5;
12236   PyObject *__pyx_t_6 = NULL;
12237   int __pyx_lineno = 0;
12238   const char *__pyx_filename = NULL;
12239   int __pyx_clineno = 0;
12240   __Pyx_RefNannySetupContext("cleanup_html", 0);
12241   __Pyx_INCREF(__pyx_v_html);
12242
12243   /* "lxml/html/diff.py":565
12244  *     (only the contents of <body> are used, if there is any <body).
12245  *     Also <ins> and <del> tags are removed.  """
12246  *     match = _body_re.search(html)             # <<<<<<<<<<<<<<
12247  *     if match:
12248  *         html = html[match.end():]
12249  */
12250   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_body_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 565, __pyx_L1_error)
12251   __Pyx_GOTREF(__pyx_t_2);
12252   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_search); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 565, __pyx_L1_error)
12253   __Pyx_GOTREF(__pyx_t_3);
12254   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12255   __pyx_t_2 = NULL;
12256   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
12257     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
12258     if (likely(__pyx_t_2)) {
12259       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12260       __Pyx_INCREF(__pyx_t_2);
12261       __Pyx_INCREF(function);
12262       __Pyx_DECREF_SET(__pyx_t_3, function);
12263     }
12264   }
12265   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_html) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_html);
12266   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
12267   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L1_error)
12268   __Pyx_GOTREF(__pyx_t_1);
12269   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12270   __pyx_v_match = __pyx_t_1;
12271   __pyx_t_1 = 0;
12272
12273   /* "lxml/html/diff.py":566
12274  *     Also <ins> and <del> tags are removed.  """
12275  *     match = _body_re.search(html)
12276  *     if match:             # <<<<<<<<<<<<<<
12277  *         html = html[match.end():]
12278  *     match = _end_body_re.search(html)
12279  */
12280   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_match); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 566, __pyx_L1_error)
12281   if (__pyx_t_4) {
12282
12283     /* "lxml/html/diff.py":567
12284  *     match = _body_re.search(html)
12285  *     if match:
12286  *         html = html[match.end():]             # <<<<<<<<<<<<<<
12287  *     match = _end_body_re.search(html)
12288  *     if match:
12289  */
12290     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_match, __pyx_n_s_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 567, __pyx_L1_error)
12291     __Pyx_GOTREF(__pyx_t_3);
12292     __pyx_t_2 = NULL;
12293     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
12294       __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
12295       if (likely(__pyx_t_2)) {
12296         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12297         __Pyx_INCREF(__pyx_t_2);
12298         __Pyx_INCREF(function);
12299         __Pyx_DECREF_SET(__pyx_t_3, function);
12300       }
12301     }
12302     __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
12303     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
12304     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L1_error)
12305     __Pyx_GOTREF(__pyx_t_1);
12306     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12307     __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_html, 0, 0, &__pyx_t_1, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 567, __pyx_L1_error)
12308     __Pyx_GOTREF(__pyx_t_3);
12309     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12310     __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_3);
12311     __pyx_t_3 = 0;
12312
12313     /* "lxml/html/diff.py":566
12314  *     Also <ins> and <del> tags are removed.  """
12315  *     match = _body_re.search(html)
12316  *     if match:             # <<<<<<<<<<<<<<
12317  *         html = html[match.end():]
12318  *     match = _end_body_re.search(html)
12319  */
12320   }
12321
12322   /* "lxml/html/diff.py":568
12323  *     if match:
12324  *         html = html[match.end():]
12325  *     match = _end_body_re.search(html)             # <<<<<<<<<<<<<<
12326  *     if match:
12327  *         html = html[:match.start()]
12328  */
12329   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_end_body_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 568, __pyx_L1_error)
12330   __Pyx_GOTREF(__pyx_t_1);
12331   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_search); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error)
12332   __Pyx_GOTREF(__pyx_t_2);
12333   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12334   __pyx_t_1 = NULL;
12335   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
12336     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
12337     if (likely(__pyx_t_1)) {
12338       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
12339       __Pyx_INCREF(__pyx_t_1);
12340       __Pyx_INCREF(function);
12341       __Pyx_DECREF_SET(__pyx_t_2, function);
12342     }
12343   }
12344   __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_html) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_html);
12345   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
12346   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error)
12347   __Pyx_GOTREF(__pyx_t_3);
12348   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12349   __Pyx_DECREF_SET(__pyx_v_match, __pyx_t_3);
12350   __pyx_t_3 = 0;
12351
12352   /* "lxml/html/diff.py":569
12353  *         html = html[match.end():]
12354  *     match = _end_body_re.search(html)
12355  *     if match:             # <<<<<<<<<<<<<<
12356  *         html = html[:match.start()]
12357  *     html = _ins_del_re.sub('', html)
12358  */
12359   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_match); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 569, __pyx_L1_error)
12360   if (__pyx_t_4) {
12361
12362     /* "lxml/html/diff.py":570
12363  *     match = _end_body_re.search(html)
12364  *     if match:
12365  *         html = html[:match.start()]             # <<<<<<<<<<<<<<
12366  *     html = _ins_del_re.sub('', html)
12367  *     return html
12368  */
12369     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_match, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __pyx_L1_error)
12370     __Pyx_GOTREF(__pyx_t_2);
12371     __pyx_t_1 = NULL;
12372     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
12373       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
12374       if (likely(__pyx_t_1)) {
12375         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
12376         __Pyx_INCREF(__pyx_t_1);
12377         __Pyx_INCREF(function);
12378         __Pyx_DECREF_SET(__pyx_t_2, function);
12379       }
12380     }
12381     __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
12382     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
12383     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
12384     __Pyx_GOTREF(__pyx_t_3);
12385     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12386     __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_html, 0, 0, NULL, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __pyx_L1_error)
12387     __Pyx_GOTREF(__pyx_t_2);
12388     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12389     __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_2);
12390     __pyx_t_2 = 0;
12391
12392     /* "lxml/html/diff.py":569
12393  *         html = html[match.end():]
12394  *     match = _end_body_re.search(html)
12395  *     if match:             # <<<<<<<<<<<<<<
12396  *         html = html[:match.start()]
12397  *     html = _ins_del_re.sub('', html)
12398  */
12399   }
12400
12401   /* "lxml/html/diff.py":571
12402  *     if match:
12403  *         html = html[:match.start()]
12404  *     html = _ins_del_re.sub('', html)             # <<<<<<<<<<<<<<
12405  *     return html
12406  * 
12407  */
12408   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ins_del_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 571, __pyx_L1_error)
12409   __Pyx_GOTREF(__pyx_t_3);
12410   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 571, __pyx_L1_error)
12411   __Pyx_GOTREF(__pyx_t_1);
12412   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12413   __pyx_t_3 = NULL;
12414   __pyx_t_5 = 0;
12415   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
12416     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
12417     if (likely(__pyx_t_3)) {
12418       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
12419       __Pyx_INCREF(__pyx_t_3);
12420       __Pyx_INCREF(function);
12421       __Pyx_DECREF_SET(__pyx_t_1, function);
12422       __pyx_t_5 = 1;
12423     }
12424   }
12425   #if CYTHON_FAST_PYCALL
12426   if (PyFunction_Check(__pyx_t_1)) {
12427     PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u__2, __pyx_v_html};
12428     __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 571, __pyx_L1_error)
12429     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12430     __Pyx_GOTREF(__pyx_t_2);
12431   } else
12432   #endif
12433   #if CYTHON_FAST_PYCCALL
12434   if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
12435     PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u__2, __pyx_v_html};
12436     __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 571, __pyx_L1_error)
12437     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12438     __Pyx_GOTREF(__pyx_t_2);
12439   } else
12440   #endif
12441   {
12442     __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L1_error)
12443     __Pyx_GOTREF(__pyx_t_6);
12444     if (__pyx_t_3) {
12445       __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
12446     }
12447     __Pyx_INCREF(__pyx_kp_u__2);
12448     __Pyx_GIVEREF(__pyx_kp_u__2);
12449     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_u__2);
12450     __Pyx_INCREF(__pyx_v_html);
12451     __Pyx_GIVEREF(__pyx_v_html);
12452     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_html);
12453     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 571, __pyx_L1_error)
12454     __Pyx_GOTREF(__pyx_t_2);
12455     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12456   }
12457   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12458   __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_2);
12459   __pyx_t_2 = 0;
12460
12461   /* "lxml/html/diff.py":572
12462  *         html = html[:match.start()]
12463  *     html = _ins_del_re.sub('', html)
12464  *     return html             # <<<<<<<<<<<<<<
12465  * 
12466  * 
12467  */
12468   __Pyx_XDECREF(__pyx_r);
12469   __Pyx_INCREF(__pyx_v_html);
12470   __pyx_r = __pyx_v_html;
12471   goto __pyx_L0;
12472
12473   /* "lxml/html/diff.py":561
12474  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
12475  * 
12476  * def cleanup_html(html):             # <<<<<<<<<<<<<<
12477  *     """ This 'cleans' the HTML, meaning that any page structure is removed
12478  *     (only the contents of <body> are used, if there is any <body).
12479  */
12480
12481   /* function exit code */
12482   __pyx_L1_error:;
12483   __Pyx_XDECREF(__pyx_t_1);
12484   __Pyx_XDECREF(__pyx_t_2);
12485   __Pyx_XDECREF(__pyx_t_3);
12486   __Pyx_XDECREF(__pyx_t_6);
12487   __Pyx_AddTraceback("lxml.html.diff.cleanup_html", __pyx_clineno, __pyx_lineno, __pyx_filename);
12488   __pyx_r = NULL;
12489   __pyx_L0:;
12490   __Pyx_XDECREF(__pyx_v_match);
12491   __Pyx_XDECREF(__pyx_v_html);
12492   __Pyx_XGIVEREF(__pyx_r);
12493   __Pyx_RefNannyFinishContext();
12494   return __pyx_r;
12495 }
12496
12497 /* "lxml/html/diff.py":577
12498  * end_whitespace_re = re.compile(r'[ \t\n\r]$')
12499  * 
12500  * def split_trailing_whitespace(word):             # <<<<<<<<<<<<<<
12501  *     """
12502  *     This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
12503  */
12504
12505 /* Python wrapper */
12506 static PyObject *__pyx_pw_4lxml_4html_4diff_45split_trailing_whitespace(PyObject *__pyx_self, PyObject *__pyx_v_word); /*proto*/
12507 static char __pyx_doc_4lxml_4html_4diff_44split_trailing_whitespace[] = "\n    This function takes a word, such as 'test\n\n' and returns ('test','\n\n')\n    ";
12508 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_45split_trailing_whitespace = {"split_trailing_whitespace", (PyCFunction)__pyx_pw_4lxml_4html_4diff_45split_trailing_whitespace, METH_O, __pyx_doc_4lxml_4html_4diff_44split_trailing_whitespace};
12509 static PyObject *__pyx_pw_4lxml_4html_4diff_45split_trailing_whitespace(PyObject *__pyx_self, PyObject *__pyx_v_word) {
12510   PyObject *__pyx_r = 0;
12511   __Pyx_RefNannyDeclarations
12512   __Pyx_RefNannySetupContext("split_trailing_whitespace (wrapper)", 0);
12513   __pyx_r = __pyx_pf_4lxml_4html_4diff_44split_trailing_whitespace(__pyx_self, ((PyObject *)__pyx_v_word));
12514
12515   /* function exit code */
12516   __Pyx_RefNannyFinishContext();
12517   return __pyx_r;
12518 }
12519
12520 static PyObject *__pyx_pf_4lxml_4html_4diff_44split_trailing_whitespace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word) {
12521   Py_ssize_t __pyx_v_stripped_length;
12522   PyObject *__pyx_r = NULL;
12523   __Pyx_RefNannyDeclarations
12524   PyObject *__pyx_t_1 = NULL;
12525   PyObject *__pyx_t_2 = NULL;
12526   PyObject *__pyx_t_3 = NULL;
12527   Py_ssize_t __pyx_t_4;
12528   int __pyx_lineno = 0;
12529   const char *__pyx_filename = NULL;
12530   int __pyx_clineno = 0;
12531   __Pyx_RefNannySetupContext("split_trailing_whitespace", 0);
12532
12533   /* "lxml/html/diff.py":581
12534  *     This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
12535  *     """
12536  *     stripped_length = len(word.rstrip())             # <<<<<<<<<<<<<<
12537  *     return word[0:stripped_length], word[stripped_length:]
12538  * 
12539  */
12540   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_word, __pyx_n_s_rstrip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 581, __pyx_L1_error)
12541   __Pyx_GOTREF(__pyx_t_2);
12542   __pyx_t_3 = NULL;
12543   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
12544     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
12545     if (likely(__pyx_t_3)) {
12546       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
12547       __Pyx_INCREF(__pyx_t_3);
12548       __Pyx_INCREF(function);
12549       __Pyx_DECREF_SET(__pyx_t_2, function);
12550     }
12551   }
12552   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
12553   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12554   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 581, __pyx_L1_error)
12555   __Pyx_GOTREF(__pyx_t_1);
12556   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12557   __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 581, __pyx_L1_error)
12558   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12559   __pyx_v_stripped_length = __pyx_t_4;
12560
12561   /* "lxml/html/diff.py":582
12562  *     """
12563  *     stripped_length = len(word.rstrip())
12564  *     return word[0:stripped_length], word[stripped_length:]             # <<<<<<<<<<<<<<
12565  * 
12566  * 
12567  */
12568   __Pyx_XDECREF(__pyx_r);
12569   __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_word, 0, __pyx_v_stripped_length, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __pyx_L1_error)
12570   __Pyx_GOTREF(__pyx_t_1);
12571   __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_word, __pyx_v_stripped_length, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error)
12572   __Pyx_GOTREF(__pyx_t_2);
12573   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 582, __pyx_L1_error)
12574   __Pyx_GOTREF(__pyx_t_3);
12575   __Pyx_GIVEREF(__pyx_t_1);
12576   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
12577   __Pyx_GIVEREF(__pyx_t_2);
12578   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
12579   __pyx_t_1 = 0;
12580   __pyx_t_2 = 0;
12581   __pyx_r = __pyx_t_3;
12582   __pyx_t_3 = 0;
12583   goto __pyx_L0;
12584
12585   /* "lxml/html/diff.py":577
12586  * end_whitespace_re = re.compile(r'[ \t\n\r]$')
12587  * 
12588  * def split_trailing_whitespace(word):             # <<<<<<<<<<<<<<
12589  *     """
12590  *     This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
12591  */
12592
12593   /* function exit code */
12594   __pyx_L1_error:;
12595   __Pyx_XDECREF(__pyx_t_1);
12596   __Pyx_XDECREF(__pyx_t_2);
12597   __Pyx_XDECREF(__pyx_t_3);
12598   __Pyx_AddTraceback("lxml.html.diff.split_trailing_whitespace", __pyx_clineno, __pyx_lineno, __pyx_filename);
12599   __pyx_r = NULL;
12600   __pyx_L0:;
12601   __Pyx_XGIVEREF(__pyx_r);
12602   __Pyx_RefNannyFinishContext();
12603   return __pyx_r;
12604 }
12605
12606 /* "lxml/html/diff.py":585
12607  * 
12608  * 
12609  * def fixup_chunks(chunks):             # <<<<<<<<<<<<<<
12610  *     """
12611  *     This function takes a list of chunks and produces a list of tokens.
12612  */
12613
12614 /* Python wrapper */
12615 static PyObject *__pyx_pw_4lxml_4html_4diff_47fixup_chunks(PyObject *__pyx_self, PyObject *__pyx_v_chunks); /*proto*/
12616 static char __pyx_doc_4lxml_4html_4diff_46fixup_chunks[] = "\n    This function takes a list of chunks and produces a list of tokens.\n    ";
12617 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_47fixup_chunks = {"fixup_chunks", (PyCFunction)__pyx_pw_4lxml_4html_4diff_47fixup_chunks, METH_O, __pyx_doc_4lxml_4html_4diff_46fixup_chunks};
12618 static PyObject *__pyx_pw_4lxml_4html_4diff_47fixup_chunks(PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
12619   PyObject *__pyx_r = 0;
12620   __Pyx_RefNannyDeclarations
12621   __Pyx_RefNannySetupContext("fixup_chunks (wrapper)", 0);
12622   __pyx_r = __pyx_pf_4lxml_4html_4diff_46fixup_chunks(__pyx_self, ((PyObject *)__pyx_v_chunks));
12623
12624   /* function exit code */
12625   __Pyx_RefNannyFinishContext();
12626   return __pyx_r;
12627 }
12628
12629 static PyObject *__pyx_pf_4lxml_4html_4diff_46fixup_chunks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chunks) {
12630   PyObject *__pyx_v_tag_accum = NULL;
12631   PyObject *__pyx_v_cur_word = NULL;
12632   PyObject *__pyx_v_result = NULL;
12633   PyObject *__pyx_v_chunk = NULL;
12634   PyObject *__pyx_v_src = NULL;
12635   PyObject *__pyx_v_tag = NULL;
12636   PyObject *__pyx_v_trailing_whitespace = NULL;
12637   PyObject *__pyx_v_href = NULL;
12638   PyObject *__pyx_r = NULL;
12639   __Pyx_RefNannyDeclarations
12640   PyObject *__pyx_t_1 = NULL;
12641   Py_ssize_t __pyx_t_2;
12642   PyObject *(*__pyx_t_3)(PyObject *);
12643   PyObject *__pyx_t_4 = NULL;
12644   int __pyx_t_5;
12645   int __pyx_t_6;
12646   PyObject *__pyx_t_7 = NULL;
12647   PyObject *__pyx_t_8 = NULL;
12648   PyObject *__pyx_t_9 = NULL;
12649   PyObject *(*__pyx_t_10)(PyObject *);
12650   int __pyx_t_11;
12651   Py_ssize_t __pyx_t_12;
12652   Py_UCS4 __pyx_t_13;
12653   int __pyx_lineno = 0;
12654   const char *__pyx_filename = NULL;
12655   int __pyx_clineno = 0;
12656   __Pyx_RefNannySetupContext("fixup_chunks", 0);
12657
12658   /* "lxml/html/diff.py":589
12659  *     This function takes a list of chunks and produces a list of tokens.
12660  *     """
12661  *     tag_accum = []             # <<<<<<<<<<<<<<
12662  *     cur_word = None
12663  *     result = []
12664  */
12665   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error)
12666   __Pyx_GOTREF(__pyx_t_1);
12667   __pyx_v_tag_accum = ((PyObject*)__pyx_t_1);
12668   __pyx_t_1 = 0;
12669
12670   /* "lxml/html/diff.py":590
12671  *     """
12672  *     tag_accum = []
12673  *     cur_word = None             # <<<<<<<<<<<<<<
12674  *     result = []
12675  *     for chunk in chunks:
12676  */
12677   __Pyx_INCREF(Py_None);
12678   __pyx_v_cur_word = Py_None;
12679
12680   /* "lxml/html/diff.py":591
12681  *     tag_accum = []
12682  *     cur_word = None
12683  *     result = []             # <<<<<<<<<<<<<<
12684  *     for chunk in chunks:
12685  *         if isinstance(chunk, tuple):
12686  */
12687   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
12688   __Pyx_GOTREF(__pyx_t_1);
12689   __pyx_v_result = ((PyObject*)__pyx_t_1);
12690   __pyx_t_1 = 0;
12691
12692   /* "lxml/html/diff.py":592
12693  *     cur_word = None
12694  *     result = []
12695  *     for chunk in chunks:             # <<<<<<<<<<<<<<
12696  *         if isinstance(chunk, tuple):
12697  *             if chunk[0] == 'img':
12698  */
12699   if (likely(PyList_CheckExact(__pyx_v_chunks)) || PyTuple_CheckExact(__pyx_v_chunks)) {
12700     __pyx_t_1 = __pyx_v_chunks; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
12701     __pyx_t_3 = NULL;
12702   } else {
12703     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chunks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
12704     __Pyx_GOTREF(__pyx_t_1);
12705     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
12706   }
12707   for (;;) {
12708     if (likely(!__pyx_t_3)) {
12709       if (likely(PyList_CheckExact(__pyx_t_1))) {
12710         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
12711         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12712         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 592, __pyx_L1_error)
12713         #else
12714         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
12715         __Pyx_GOTREF(__pyx_t_4);
12716         #endif
12717       } else {
12718         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
12719         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12720         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 592, __pyx_L1_error)
12721         #else
12722         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
12723         __Pyx_GOTREF(__pyx_t_4);
12724         #endif
12725       }
12726     } else {
12727       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
12728       if (unlikely(!__pyx_t_4)) {
12729         PyObject* exc_type = PyErr_Occurred();
12730         if (exc_type) {
12731           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12732           else __PYX_ERR(0, 592, __pyx_L1_error)
12733         }
12734         break;
12735       }
12736       __Pyx_GOTREF(__pyx_t_4);
12737     }
12738     __Pyx_XDECREF_SET(__pyx_v_chunk, __pyx_t_4);
12739     __pyx_t_4 = 0;
12740
12741     /* "lxml/html/diff.py":593
12742  *     result = []
12743  *     for chunk in chunks:
12744  *         if isinstance(chunk, tuple):             # <<<<<<<<<<<<<<
12745  *             if chunk[0] == 'img':
12746  *                 src = chunk[1]
12747  */
12748     __pyx_t_5 = PyTuple_Check(__pyx_v_chunk); 
12749     __pyx_t_6 = (__pyx_t_5 != 0);
12750     if (__pyx_t_6) {
12751
12752       /* "lxml/html/diff.py":594
12753  *     for chunk in chunks:
12754  *         if isinstance(chunk, tuple):
12755  *             if chunk[0] == 'img':             # <<<<<<<<<<<<<<
12756  *                 src = chunk[1]
12757  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12758  */
12759       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_chunk, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
12760       __Pyx_GOTREF(__pyx_t_4);
12761       __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_img, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 594, __pyx_L1_error)
12762       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12763       if (__pyx_t_6) {
12764
12765         /* "lxml/html/diff.py":595
12766  *         if isinstance(chunk, tuple):
12767  *             if chunk[0] == 'img':
12768  *                 src = chunk[1]             # <<<<<<<<<<<<<<
12769  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12770  *                 cur_word = tag_token('img', src, html_repr=tag,
12771  */
12772         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_chunk, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 595, __pyx_L1_error)
12773         __Pyx_GOTREF(__pyx_t_4);
12774         __Pyx_XDECREF_SET(__pyx_v_src, __pyx_t_4);
12775         __pyx_t_4 = 0;
12776
12777         /* "lxml/html/diff.py":596
12778  *             if chunk[0] == 'img':
12779  *                 src = chunk[1]
12780  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])             # <<<<<<<<<<<<<<
12781  *                 cur_word = tag_token('img', src, html_repr=tag,
12782  *                                      pre_tags=tag_accum,
12783  */
12784         __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_split_trailing_whitespace); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 596, __pyx_L1_error)
12785         __Pyx_GOTREF(__pyx_t_7);
12786         __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_chunk, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 596, __pyx_L1_error)
12787         __Pyx_GOTREF(__pyx_t_8);
12788         __pyx_t_9 = NULL;
12789         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
12790           __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
12791           if (likely(__pyx_t_9)) {
12792             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
12793             __Pyx_INCREF(__pyx_t_9);
12794             __Pyx_INCREF(function);
12795             __Pyx_DECREF_SET(__pyx_t_7, function);
12796           }
12797         }
12798         __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
12799         __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
12800         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
12801         if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 596, __pyx_L1_error)
12802         __Pyx_GOTREF(__pyx_t_4);
12803         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
12804         if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
12805           PyObject* sequence = __pyx_t_4;
12806           Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
12807           if (unlikely(size != 2)) {
12808             if (size > 2) __Pyx_RaiseTooManyValuesError(2);
12809             else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
12810             __PYX_ERR(0, 596, __pyx_L1_error)
12811           }
12812           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12813           if (likely(PyTuple_CheckExact(sequence))) {
12814             __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
12815             __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
12816           } else {
12817             __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
12818             __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
12819           }
12820           __Pyx_INCREF(__pyx_t_7);
12821           __Pyx_INCREF(__pyx_t_8);
12822           #else
12823           __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 596, __pyx_L1_error)
12824           __Pyx_GOTREF(__pyx_t_7);
12825           __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 596, __pyx_L1_error)
12826           __Pyx_GOTREF(__pyx_t_8);
12827           #endif
12828           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12829         } else {
12830           Py_ssize_t index = -1;
12831           __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 596, __pyx_L1_error)
12832           __Pyx_GOTREF(__pyx_t_9);
12833           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12834           __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
12835           index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
12836           __Pyx_GOTREF(__pyx_t_7);
12837           index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed;
12838           __Pyx_GOTREF(__pyx_t_8);
12839           if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 596, __pyx_L1_error)
12840           __pyx_t_10 = NULL;
12841           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12842           goto __pyx_L8_unpacking_done;
12843           __pyx_L7_unpacking_failed:;
12844           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12845           __pyx_t_10 = NULL;
12846           if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
12847           __PYX_ERR(0, 596, __pyx_L1_error)
12848           __pyx_L8_unpacking_done:;
12849         }
12850         __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_7);
12851         __pyx_t_7 = 0;
12852         __Pyx_XDECREF_SET(__pyx_v_trailing_whitespace, __pyx_t_8);
12853         __pyx_t_8 = 0;
12854
12855         /* "lxml/html/diff.py":597
12856  *                 src = chunk[1]
12857  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12858  *                 cur_word = tag_token('img', src, html_repr=tag,             # <<<<<<<<<<<<<<
12859  *                                      pre_tags=tag_accum,
12860  *                                      trailing_whitespace=trailing_whitespace)
12861  */
12862         __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_tag_token_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __pyx_L1_error)
12863         __Pyx_GOTREF(__pyx_t_4);
12864         __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 597, __pyx_L1_error)
12865         __Pyx_GOTREF(__pyx_t_8);
12866         __Pyx_INCREF(__pyx_n_u_img);
12867         __Pyx_GIVEREF(__pyx_n_u_img);
12868         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_n_u_img);
12869         __Pyx_INCREF(__pyx_v_src);
12870         __Pyx_GIVEREF(__pyx_v_src);
12871         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_src);
12872         __pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 597, __pyx_L1_error)
12873         __Pyx_GOTREF(__pyx_t_7);
12874         if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_html_repr, __pyx_v_tag) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
12875
12876         /* "lxml/html/diff.py":598
12877  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12878  *                 cur_word = tag_token('img', src, html_repr=tag,
12879  *                                      pre_tags=tag_accum,             # <<<<<<<<<<<<<<
12880  *                                      trailing_whitespace=trailing_whitespace)
12881  *                 tag_accum = []
12882  */
12883         if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_pre_tags, __pyx_v_tag_accum) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
12884
12885         /* "lxml/html/diff.py":599
12886  *                 cur_word = tag_token('img', src, html_repr=tag,
12887  *                                      pre_tags=tag_accum,
12888  *                                      trailing_whitespace=trailing_whitespace)             # <<<<<<<<<<<<<<
12889  *                 tag_accum = []
12890  *                 result.append(cur_word)
12891  */
12892         if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_trailing_whitespace, __pyx_v_trailing_whitespace) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
12893
12894         /* "lxml/html/diff.py":597
12895  *                 src = chunk[1]
12896  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12897  *                 cur_word = tag_token('img', src, html_repr=tag,             # <<<<<<<<<<<<<<
12898  *                                      pre_tags=tag_accum,
12899  *                                      trailing_whitespace=trailing_whitespace)
12900  */
12901         __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 597, __pyx_L1_error)
12902         __Pyx_GOTREF(__pyx_t_9);
12903         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12904         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
12905         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
12906         __Pyx_DECREF_SET(__pyx_v_cur_word, __pyx_t_9);
12907         __pyx_t_9 = 0;
12908
12909         /* "lxml/html/diff.py":600
12910  *                                      pre_tags=tag_accum,
12911  *                                      trailing_whitespace=trailing_whitespace)
12912  *                 tag_accum = []             # <<<<<<<<<<<<<<
12913  *                 result.append(cur_word)
12914  * 
12915  */
12916         __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 600, __pyx_L1_error)
12917         __Pyx_GOTREF(__pyx_t_9);
12918         __Pyx_DECREF_SET(__pyx_v_tag_accum, ((PyObject*)__pyx_t_9));
12919         __pyx_t_9 = 0;
12920
12921         /* "lxml/html/diff.py":601
12922  *                                      trailing_whitespace=trailing_whitespace)
12923  *                 tag_accum = []
12924  *                 result.append(cur_word)             # <<<<<<<<<<<<<<
12925  * 
12926  *             elif chunk[0] == 'href':
12927  */
12928         __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_cur_word); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 601, __pyx_L1_error)
12929
12930         /* "lxml/html/diff.py":594
12931  *     for chunk in chunks:
12932  *         if isinstance(chunk, tuple):
12933  *             if chunk[0] == 'img':             # <<<<<<<<<<<<<<
12934  *                 src = chunk[1]
12935  *                 tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
12936  */
12937         goto __pyx_L6;
12938       }
12939
12940       /* "lxml/html/diff.py":603
12941  *                 result.append(cur_word)
12942  * 
12943  *             elif chunk[0] == 'href':             # <<<<<<<<<<<<<<
12944  *                 href = chunk[1]
12945  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
12946  */
12947       __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_chunk, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 603, __pyx_L1_error)
12948       __Pyx_GOTREF(__pyx_t_9);
12949       __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_href, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 603, __pyx_L1_error)
12950       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12951       if (__pyx_t_6) {
12952
12953         /* "lxml/html/diff.py":604
12954  * 
12955  *             elif chunk[0] == 'href':
12956  *                 href = chunk[1]             # <<<<<<<<<<<<<<
12957  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
12958  *                 tag_accum = []
12959  */
12960         __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_chunk, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 604, __pyx_L1_error)
12961         __Pyx_GOTREF(__pyx_t_9);
12962         __Pyx_XDECREF_SET(__pyx_v_href, __pyx_t_9);
12963         __pyx_t_9 = 0;
12964
12965         /* "lxml/html/diff.py":605
12966  *             elif chunk[0] == 'href':
12967  *                 href = chunk[1]
12968  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")             # <<<<<<<<<<<<<<
12969  *                 tag_accum = []
12970  *                 result.append(cur_word)
12971  */
12972         __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_href_token); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error)
12973         __Pyx_GOTREF(__pyx_t_9);
12974         __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 605, __pyx_L1_error)
12975         __Pyx_GOTREF(__pyx_t_7);
12976         __Pyx_INCREF(__pyx_v_href);
12977         __Pyx_GIVEREF(__pyx_v_href);
12978         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_href);
12979         __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 605, __pyx_L1_error)
12980         __Pyx_GOTREF(__pyx_t_8);
12981         if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_pre_tags, __pyx_v_tag_accum) < 0) __PYX_ERR(0, 605, __pyx_L1_error)
12982         if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_trailing_whitespace, __pyx_kp_u__6) < 0) __PYX_ERR(0, 605, __pyx_L1_error)
12983         __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 605, __pyx_L1_error)
12984         __Pyx_GOTREF(__pyx_t_4);
12985         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12986         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
12987         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
12988         __Pyx_DECREF_SET(__pyx_v_cur_word, __pyx_t_4);
12989         __pyx_t_4 = 0;
12990
12991         /* "lxml/html/diff.py":606
12992  *                 href = chunk[1]
12993  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
12994  *                 tag_accum = []             # <<<<<<<<<<<<<<
12995  *                 result.append(cur_word)
12996  *             continue
12997  */
12998         __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 606, __pyx_L1_error)
12999         __Pyx_GOTREF(__pyx_t_4);
13000         __Pyx_DECREF_SET(__pyx_v_tag_accum, ((PyObject*)__pyx_t_4));
13001         __pyx_t_4 = 0;
13002
13003         /* "lxml/html/diff.py":607
13004  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
13005  *                 tag_accum = []
13006  *                 result.append(cur_word)             # <<<<<<<<<<<<<<
13007  *             continue
13008  * 
13009  */
13010         __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_cur_word); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 607, __pyx_L1_error)
13011
13012         /* "lxml/html/diff.py":603
13013  *                 result.append(cur_word)
13014  * 
13015  *             elif chunk[0] == 'href':             # <<<<<<<<<<<<<<
13016  *                 href = chunk[1]
13017  *                 cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
13018  */
13019       }
13020       __pyx_L6:;
13021
13022       /* "lxml/html/diff.py":608
13023  *                 tag_accum = []
13024  *                 result.append(cur_word)
13025  *             continue             # <<<<<<<<<<<<<<
13026  * 
13027  *         if is_word(chunk):
13028  */
13029       goto __pyx_L3_continue;
13030
13031       /* "lxml/html/diff.py":593
13032  *     result = []
13033  *     for chunk in chunks:
13034  *         if isinstance(chunk, tuple):             # <<<<<<<<<<<<<<
13035  *             if chunk[0] == 'img':
13036  *                 src = chunk[1]
13037  */
13038     }
13039
13040     /* "lxml/html/diff.py":610
13041  *             continue
13042  * 
13043  *         if is_word(chunk):             # <<<<<<<<<<<<<<
13044  *             chunk, trailing_whitespace = split_trailing_whitespace(chunk)
13045  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
13046  */
13047     __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_word); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 610, __pyx_L1_error)
13048     __Pyx_GOTREF(__pyx_t_8);
13049     __pyx_t_7 = NULL;
13050     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
13051       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
13052       if (likely(__pyx_t_7)) {
13053         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
13054         __Pyx_INCREF(__pyx_t_7);
13055         __Pyx_INCREF(function);
13056         __Pyx_DECREF_SET(__pyx_t_8, function);
13057       }
13058     }
13059     __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_chunk) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_chunk);
13060     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
13061     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
13062     __Pyx_GOTREF(__pyx_t_4);
13063     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13064     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 610, __pyx_L1_error)
13065     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13066     if (__pyx_t_6) {
13067
13068       /* "lxml/html/diff.py":611
13069  * 
13070  *         if is_word(chunk):
13071  *             chunk, trailing_whitespace = split_trailing_whitespace(chunk)             # <<<<<<<<<<<<<<
13072  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
13073  *             tag_accum = []
13074  */
13075       __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_split_trailing_whitespace); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
13076       __Pyx_GOTREF(__pyx_t_8);
13077       __pyx_t_7 = NULL;
13078       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
13079         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
13080         if (likely(__pyx_t_7)) {
13081           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
13082           __Pyx_INCREF(__pyx_t_7);
13083           __Pyx_INCREF(function);
13084           __Pyx_DECREF_SET(__pyx_t_8, function);
13085         }
13086       }
13087       __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_chunk) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_chunk);
13088       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
13089       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
13090       __Pyx_GOTREF(__pyx_t_4);
13091       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13092       if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
13093         PyObject* sequence = __pyx_t_4;
13094         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
13095         if (unlikely(size != 2)) {
13096           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
13097           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
13098           __PYX_ERR(0, 611, __pyx_L1_error)
13099         }
13100         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13101         if (likely(PyTuple_CheckExact(sequence))) {
13102           __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
13103           __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
13104         } else {
13105           __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
13106           __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
13107         }
13108         __Pyx_INCREF(__pyx_t_8);
13109         __Pyx_INCREF(__pyx_t_7);
13110         #else
13111         __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
13112         __Pyx_GOTREF(__pyx_t_8);
13113         __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 611, __pyx_L1_error)
13114         __Pyx_GOTREF(__pyx_t_7);
13115         #endif
13116         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13117       } else {
13118         Py_ssize_t index = -1;
13119         __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 611, __pyx_L1_error)
13120         __Pyx_GOTREF(__pyx_t_9);
13121         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13122         __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
13123         index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L10_unpacking_failed;
13124         __Pyx_GOTREF(__pyx_t_8);
13125         index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L10_unpacking_failed;
13126         __Pyx_GOTREF(__pyx_t_7);
13127         if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 611, __pyx_L1_error)
13128         __pyx_t_10 = NULL;
13129         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13130         goto __pyx_L11_unpacking_done;
13131         __pyx_L10_unpacking_failed:;
13132         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13133         __pyx_t_10 = NULL;
13134         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
13135         __PYX_ERR(0, 611, __pyx_L1_error)
13136         __pyx_L11_unpacking_done:;
13137       }
13138       __Pyx_DECREF_SET(__pyx_v_chunk, __pyx_t_8);
13139       __pyx_t_8 = 0;
13140       __Pyx_XDECREF_SET(__pyx_v_trailing_whitespace, __pyx_t_7);
13141       __pyx_t_7 = 0;
13142
13143       /* "lxml/html/diff.py":612
13144  *         if is_word(chunk):
13145  *             chunk, trailing_whitespace = split_trailing_whitespace(chunk)
13146  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)             # <<<<<<<<<<<<<<
13147  *             tag_accum = []
13148  *             result.append(cur_word)
13149  */
13150       __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_token); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
13151       __Pyx_GOTREF(__pyx_t_4);
13152       __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 612, __pyx_L1_error)
13153       __Pyx_GOTREF(__pyx_t_7);
13154       __Pyx_INCREF(__pyx_v_chunk);
13155       __Pyx_GIVEREF(__pyx_v_chunk);
13156       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chunk);
13157       __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 612, __pyx_L1_error)
13158       __Pyx_GOTREF(__pyx_t_8);
13159       if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_pre_tags, __pyx_v_tag_accum) < 0) __PYX_ERR(0, 612, __pyx_L1_error)
13160       if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_trailing_whitespace, __pyx_v_trailing_whitespace) < 0) __PYX_ERR(0, 612, __pyx_L1_error)
13161       __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error)
13162       __Pyx_GOTREF(__pyx_t_9);
13163       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13164       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
13165       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13166       __Pyx_DECREF_SET(__pyx_v_cur_word, __pyx_t_9);
13167       __pyx_t_9 = 0;
13168
13169       /* "lxml/html/diff.py":613
13170  *             chunk, trailing_whitespace = split_trailing_whitespace(chunk)
13171  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
13172  *             tag_accum = []             # <<<<<<<<<<<<<<
13173  *             result.append(cur_word)
13174  * 
13175  */
13176       __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 613, __pyx_L1_error)
13177       __Pyx_GOTREF(__pyx_t_9);
13178       __Pyx_DECREF_SET(__pyx_v_tag_accum, ((PyObject*)__pyx_t_9));
13179       __pyx_t_9 = 0;
13180
13181       /* "lxml/html/diff.py":614
13182  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
13183  *             tag_accum = []
13184  *             result.append(cur_word)             # <<<<<<<<<<<<<<
13185  * 
13186  *         elif is_start_tag(chunk):
13187  */
13188       __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_cur_word); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 614, __pyx_L1_error)
13189
13190       /* "lxml/html/diff.py":610
13191  *             continue
13192  * 
13193  *         if is_word(chunk):             # <<<<<<<<<<<<<<
13194  *             chunk, trailing_whitespace = split_trailing_whitespace(chunk)
13195  *             cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
13196  */
13197       goto __pyx_L9;
13198     }
13199
13200     /* "lxml/html/diff.py":616
13201  *             result.append(cur_word)
13202  * 
13203  *         elif is_start_tag(chunk):             # <<<<<<<<<<<<<<
13204  *             tag_accum.append(chunk)
13205  * 
13206  */
13207     __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_start_tag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 616, __pyx_L1_error)
13208     __Pyx_GOTREF(__pyx_t_8);
13209     __pyx_t_7 = NULL;
13210     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
13211       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
13212       if (likely(__pyx_t_7)) {
13213         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
13214         __Pyx_INCREF(__pyx_t_7);
13215         __Pyx_INCREF(function);
13216         __Pyx_DECREF_SET(__pyx_t_8, function);
13217       }
13218     }
13219     __pyx_t_9 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_chunk) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_chunk);
13220     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
13221     if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 616, __pyx_L1_error)
13222     __Pyx_GOTREF(__pyx_t_9);
13223     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13224     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 616, __pyx_L1_error)
13225     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13226     if (__pyx_t_6) {
13227
13228       /* "lxml/html/diff.py":617
13229  * 
13230  *         elif is_start_tag(chunk):
13231  *             tag_accum.append(chunk)             # <<<<<<<<<<<<<<
13232  * 
13233  *         elif is_end_tag(chunk):
13234  */
13235       __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_tag_accum, __pyx_v_chunk); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 617, __pyx_L1_error)
13236
13237       /* "lxml/html/diff.py":616
13238  *             result.append(cur_word)
13239  * 
13240  *         elif is_start_tag(chunk):             # <<<<<<<<<<<<<<
13241  *             tag_accum.append(chunk)
13242  * 
13243  */
13244       goto __pyx_L9;
13245     }
13246
13247     /* "lxml/html/diff.py":619
13248  *             tag_accum.append(chunk)
13249  * 
13250  *         elif is_end_tag(chunk):             # <<<<<<<<<<<<<<
13251  *             if tag_accum:
13252  *                 tag_accum.append(chunk)
13253  */
13254     __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_end_tag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 619, __pyx_L1_error)
13255     __Pyx_GOTREF(__pyx_t_8);
13256     __pyx_t_7 = NULL;
13257     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
13258       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
13259       if (likely(__pyx_t_7)) {
13260         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
13261         __Pyx_INCREF(__pyx_t_7);
13262         __Pyx_INCREF(function);
13263         __Pyx_DECREF_SET(__pyx_t_8, function);
13264       }
13265     }
13266     __pyx_t_9 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_chunk) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_chunk);
13267     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
13268     if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L1_error)
13269     __Pyx_GOTREF(__pyx_t_9);
13270     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13271     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
13272     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13273     if (__pyx_t_6) {
13274
13275       /* "lxml/html/diff.py":620
13276  * 
13277  *         elif is_end_tag(chunk):
13278  *             if tag_accum:             # <<<<<<<<<<<<<<
13279  *                 tag_accum.append(chunk)
13280  *             else:
13281  */
13282       __pyx_t_6 = (PyList_GET_SIZE(__pyx_v_tag_accum) != 0);
13283       if (__pyx_t_6) {
13284
13285         /* "lxml/html/diff.py":621
13286  *         elif is_end_tag(chunk):
13287  *             if tag_accum:
13288  *                 tag_accum.append(chunk)             # <<<<<<<<<<<<<<
13289  *             else:
13290  *                 assert cur_word, (
13291  */
13292         __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_tag_accum, __pyx_v_chunk); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 621, __pyx_L1_error)
13293
13294         /* "lxml/html/diff.py":620
13295  * 
13296  *         elif is_end_tag(chunk):
13297  *             if tag_accum:             # <<<<<<<<<<<<<<
13298  *                 tag_accum.append(chunk)
13299  *             else:
13300  */
13301         goto __pyx_L12;
13302       }
13303
13304       /* "lxml/html/diff.py":623
13305  *                 tag_accum.append(chunk)
13306  *             else:
13307  *                 assert cur_word, (             # <<<<<<<<<<<<<<
13308  *                     "Weird state, cur_word=%r, result=%r, chunks=%r of %r"
13309  *                     % (cur_word, result, chunk, chunks))
13310  */
13311       /*else*/ {
13312         #ifndef CYTHON_WITHOUT_ASSERTIONS
13313         if (unlikely(!Py_OptimizeFlag)) {
13314           __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_cur_word); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 623, __pyx_L1_error)
13315           if (unlikely(!__pyx_t_6)) {
13316
13317             /* "lxml/html/diff.py":624
13318  *             else:
13319  *                 assert cur_word, (
13320  *                     "Weird state, cur_word=%r, result=%r, chunks=%r of %r"             # <<<<<<<<<<<<<<
13321  *                     % (cur_word, result, chunk, chunks))
13322  *                 cur_word.post_tags.append(chunk)
13323  */
13324             __pyx_t_9 = PyTuple_New(8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error)
13325             __Pyx_GOTREF(__pyx_t_9);
13326             __pyx_t_12 = 0;
13327             __pyx_t_13 = 127;
13328             __Pyx_INCREF(__pyx_kp_u_Weird_state_cur_word);
13329             __pyx_t_12 += 22;
13330             __Pyx_GIVEREF(__pyx_kp_u_Weird_state_cur_word);
13331             PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Weird_state_cur_word);
13332
13333             /* "lxml/html/diff.py":625
13334  *                 assert cur_word, (
13335  *                     "Weird state, cur_word=%r, result=%r, chunks=%r of %r"
13336  *                     % (cur_word, result, chunk, chunks))             # <<<<<<<<<<<<<<
13337  *                 cur_word.post_tags.append(chunk)
13338  *         else:
13339  */
13340             __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_cur_word), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
13341             __Pyx_GOTREF(__pyx_t_8);
13342             __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_13;
13343             __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
13344             __Pyx_GIVEREF(__pyx_t_8);
13345             PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
13346             __pyx_t_8 = 0;
13347             __Pyx_INCREF(__pyx_kp_u_result);
13348             __pyx_t_12 += 9;
13349             __Pyx_GIVEREF(__pyx_kp_u_result);
13350             PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_result);
13351             __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_result), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
13352             __Pyx_GOTREF(__pyx_t_8);
13353             __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_13;
13354             __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
13355             __Pyx_GIVEREF(__pyx_t_8);
13356             PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_8);
13357             __pyx_t_8 = 0;
13358             __Pyx_INCREF(__pyx_kp_u_chunks);
13359             __pyx_t_12 += 9;
13360             __Pyx_GIVEREF(__pyx_kp_u_chunks);
13361             PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u_chunks);
13362             __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_chunk), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
13363             __Pyx_GOTREF(__pyx_t_8);
13364             __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_13;
13365             __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
13366             __Pyx_GIVEREF(__pyx_t_8);
13367             PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_8);
13368             __pyx_t_8 = 0;
13369             __Pyx_INCREF(__pyx_kp_u_of);
13370             __pyx_t_12 += 4;
13371             __Pyx_GIVEREF(__pyx_kp_u_of);
13372             PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_kp_u_of);
13373             __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_chunks), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
13374             __Pyx_GOTREF(__pyx_t_8);
13375             __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_13;
13376             __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
13377             __Pyx_GIVEREF(__pyx_t_8);
13378             PyTuple_SET_ITEM(__pyx_t_9, 7, __pyx_t_8);
13379             __pyx_t_8 = 0;
13380
13381             /* "lxml/html/diff.py":624
13382  *             else:
13383  *                 assert cur_word, (
13384  *                     "Weird state, cur_word=%r, result=%r, chunks=%r of %r"             # <<<<<<<<<<<<<<
13385  *                     % (cur_word, result, chunk, chunks))
13386  *                 cur_word.post_tags.append(chunk)
13387  */
13388             __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_9, 8, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 624, __pyx_L1_error)
13389             __Pyx_GOTREF(__pyx_t_8);
13390             __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13391             PyErr_SetObject(PyExc_AssertionError, __pyx_t_8);
13392             __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13393             __PYX_ERR(0, 623, __pyx_L1_error)
13394           }
13395         }
13396         #endif
13397
13398         /* "lxml/html/diff.py":626
13399  *                     "Weird state, cur_word=%r, result=%r, chunks=%r of %r"
13400  *                     % (cur_word, result, chunk, chunks))
13401  *                 cur_word.post_tags.append(chunk)             # <<<<<<<<<<<<<<
13402  *         else:
13403  *             assert False
13404  */
13405         __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_cur_word, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 626, __pyx_L1_error)
13406         __Pyx_GOTREF(__pyx_t_8);
13407         __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_8, __pyx_v_chunk); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 626, __pyx_L1_error)
13408         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13409       }
13410       __pyx_L12:;
13411
13412       /* "lxml/html/diff.py":619
13413  *             tag_accum.append(chunk)
13414  * 
13415  *         elif is_end_tag(chunk):             # <<<<<<<<<<<<<<
13416  *             if tag_accum:
13417  *                 tag_accum.append(chunk)
13418  */
13419       goto __pyx_L9;
13420     }
13421
13422     /* "lxml/html/diff.py":628
13423  *                 cur_word.post_tags.append(chunk)
13424  *         else:
13425  *             assert False             # <<<<<<<<<<<<<<
13426  * 
13427  *     if not result:
13428  */
13429     /*else*/ {
13430       #ifndef CYTHON_WITHOUT_ASSERTIONS
13431       if (unlikely(!Py_OptimizeFlag)) {
13432         if (unlikely(!0)) {
13433           PyErr_SetNone(PyExc_AssertionError);
13434           __PYX_ERR(0, 628, __pyx_L1_error)
13435         }
13436       }
13437       #endif
13438     }
13439     __pyx_L9:;
13440
13441     /* "lxml/html/diff.py":592
13442  *     cur_word = None
13443  *     result = []
13444  *     for chunk in chunks:             # <<<<<<<<<<<<<<
13445  *         if isinstance(chunk, tuple):
13446  *             if chunk[0] == 'img':
13447  */
13448     __pyx_L3_continue:;
13449   }
13450   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13451
13452   /* "lxml/html/diff.py":630
13453  *             assert False
13454  * 
13455  *     if not result:             # <<<<<<<<<<<<<<
13456  *         return [token('', pre_tags=tag_accum)]
13457  *     else:
13458  */
13459   __pyx_t_6 = (PyList_GET_SIZE(__pyx_v_result) != 0);
13460   __pyx_t_5 = ((!__pyx_t_6) != 0);
13461   if (__pyx_t_5) {
13462
13463     /* "lxml/html/diff.py":631
13464  * 
13465  *     if not result:
13466  *         return [token('', pre_tags=tag_accum)]             # <<<<<<<<<<<<<<
13467  *     else:
13468  *         result[-1].post_tags.extend(tag_accum)
13469  */
13470     __Pyx_XDECREF(__pyx_r);
13471     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error)
13472     __Pyx_GOTREF(__pyx_t_1);
13473     __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 631, __pyx_L1_error)
13474     __Pyx_GOTREF(__pyx_t_8);
13475     if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_pre_tags, __pyx_v_tag_accum) < 0) __PYX_ERR(0, 631, __pyx_L1_error)
13476     __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__16, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 631, __pyx_L1_error)
13477     __Pyx_GOTREF(__pyx_t_9);
13478     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13479     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13480     __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 631, __pyx_L1_error)
13481     __Pyx_GOTREF(__pyx_t_8);
13482     __Pyx_GIVEREF(__pyx_t_9);
13483     PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
13484     __pyx_t_9 = 0;
13485     __pyx_r = __pyx_t_8;
13486     __pyx_t_8 = 0;
13487     goto __pyx_L0;
13488
13489     /* "lxml/html/diff.py":630
13490  *             assert False
13491  * 
13492  *     if not result:             # <<<<<<<<<<<<<<
13493  *         return [token('', pre_tags=tag_accum)]
13494  *     else:
13495  */
13496   }
13497
13498   /* "lxml/html/diff.py":633
13499  *         return [token('', pre_tags=tag_accum)]
13500  *     else:
13501  *         result[-1].post_tags.extend(tag_accum)             # <<<<<<<<<<<<<<
13502  * 
13503  *     return result
13504  */
13505   /*else*/ {
13506     __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_result, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L1_error)
13507     __Pyx_GOTREF(__pyx_t_9);
13508     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_post_tags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
13509     __Pyx_GOTREF(__pyx_t_1);
13510     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13511     __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_extend); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 633, __pyx_L1_error)
13512     __Pyx_GOTREF(__pyx_t_9);
13513     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13514     __pyx_t_1 = NULL;
13515     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
13516       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
13517       if (likely(__pyx_t_1)) {
13518         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
13519         __Pyx_INCREF(__pyx_t_1);
13520         __Pyx_INCREF(function);
13521         __Pyx_DECREF_SET(__pyx_t_9, function);
13522       }
13523     }
13524     __pyx_t_8 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_1, __pyx_v_tag_accum) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_tag_accum);
13525     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
13526     if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 633, __pyx_L1_error)
13527     __Pyx_GOTREF(__pyx_t_8);
13528     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
13529     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13530   }
13531
13532   /* "lxml/html/diff.py":635
13533  *         result[-1].post_tags.extend(tag_accum)
13534  * 
13535  *     return result             # <<<<<<<<<<<<<<
13536  * 
13537  * 
13538  */
13539   __Pyx_XDECREF(__pyx_r);
13540   __Pyx_INCREF(__pyx_v_result);
13541   __pyx_r = __pyx_v_result;
13542   goto __pyx_L0;
13543
13544   /* "lxml/html/diff.py":585
13545  * 
13546  * 
13547  * def fixup_chunks(chunks):             # <<<<<<<<<<<<<<
13548  *     """
13549  *     This function takes a list of chunks and produces a list of tokens.
13550  */
13551
13552   /* function exit code */
13553   __pyx_L1_error:;
13554   __Pyx_XDECREF(__pyx_t_1);
13555   __Pyx_XDECREF(__pyx_t_4);
13556   __Pyx_XDECREF(__pyx_t_7);
13557   __Pyx_XDECREF(__pyx_t_8);
13558   __Pyx_XDECREF(__pyx_t_9);
13559   __Pyx_AddTraceback("lxml.html.diff.fixup_chunks", __pyx_clineno, __pyx_lineno, __pyx_filename);
13560   __pyx_r = NULL;
13561   __pyx_L0:;
13562   __Pyx_XDECREF(__pyx_v_tag_accum);
13563   __Pyx_XDECREF(__pyx_v_cur_word);
13564   __Pyx_XDECREF(__pyx_v_result);
13565   __Pyx_XDECREF(__pyx_v_chunk);
13566   __Pyx_XDECREF(__pyx_v_src);
13567   __Pyx_XDECREF(__pyx_v_tag);
13568   __Pyx_XDECREF(__pyx_v_trailing_whitespace);
13569   __Pyx_XDECREF(__pyx_v_href);
13570   __Pyx_XGIVEREF(__pyx_r);
13571   __Pyx_RefNannyFinishContext();
13572   return __pyx_r;
13573 }
13574 static PyObject *__pyx_gb_4lxml_4html_4diff_50generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
13575
13576 /* "lxml/html/diff.py":684
13577  * 
13578  * 
13579  * def flatten_el(el, include_hrefs, skip_tag=False):             # <<<<<<<<<<<<<<
13580  *     """ Takes an lxml element el, and generates all the text chunks for
13581  *     that tag.  Each start tag is a chunk, each word is a chunk, and each
13582  */
13583
13584 /* Python wrapper */
13585 static PyObject *__pyx_pw_4lxml_4html_4diff_49flatten_el(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
13586 static char __pyx_doc_4lxml_4html_4diff_48flatten_el[] = " Takes an lxml element el, and generates all the text chunks for\n    that tag.  Each start tag is a chunk, each word is a chunk, and each\n    end tag is a chunk.\n\n    If skip_tag is true, then the outermost container tag is\n    not returned (just its contents).";
13587 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_49flatten_el = {"flatten_el", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_49flatten_el, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_48flatten_el};
13588 static PyObject *__pyx_pw_4lxml_4html_4diff_49flatten_el(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
13589   PyObject *__pyx_v_el = 0;
13590   PyObject *__pyx_v_include_hrefs = 0;
13591   PyObject *__pyx_v_skip_tag = 0;
13592   int __pyx_lineno = 0;
13593   const char *__pyx_filename = NULL;
13594   int __pyx_clineno = 0;
13595   PyObject *__pyx_r = 0;
13596   __Pyx_RefNannyDeclarations
13597   __Pyx_RefNannySetupContext("flatten_el (wrapper)", 0);
13598   {
13599     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_el,&__pyx_n_s_include_hrefs,&__pyx_n_s_skip_tag,0};
13600     PyObject* values[3] = {0,0,0};
13601     values[2] = ((PyObject *)((PyObject *)Py_False));
13602     if (unlikely(__pyx_kwds)) {
13603       Py_ssize_t kw_args;
13604       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
13605       switch (pos_args) {
13606         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13607         CYTHON_FALLTHROUGH;
13608         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13609         CYTHON_FALLTHROUGH;
13610         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13611         CYTHON_FALLTHROUGH;
13612         case  0: break;
13613         default: goto __pyx_L5_argtuple_error;
13614       }
13615       kw_args = PyDict_Size(__pyx_kwds);
13616       switch (pos_args) {
13617         case  0:
13618         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_el)) != 0)) kw_args--;
13619         else goto __pyx_L5_argtuple_error;
13620         CYTHON_FALLTHROUGH;
13621         case  1:
13622         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_include_hrefs)) != 0)) kw_args--;
13623         else {
13624           __Pyx_RaiseArgtupleInvalid("flatten_el", 0, 2, 3, 1); __PYX_ERR(0, 684, __pyx_L3_error)
13625         }
13626         CYTHON_FALLTHROUGH;
13627         case  2:
13628         if (kw_args > 0) {
13629           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_skip_tag);
13630           if (value) { values[2] = value; kw_args--; }
13631         }
13632       }
13633       if (unlikely(kw_args > 0)) {
13634         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "flatten_el") < 0)) __PYX_ERR(0, 684, __pyx_L3_error)
13635       }
13636     } else {
13637       switch (PyTuple_GET_SIZE(__pyx_args)) {
13638         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13639         CYTHON_FALLTHROUGH;
13640         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13641         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13642         break;
13643         default: goto __pyx_L5_argtuple_error;
13644       }
13645     }
13646     __pyx_v_el = values[0];
13647     __pyx_v_include_hrefs = values[1];
13648     __pyx_v_skip_tag = values[2];
13649   }
13650   goto __pyx_L4_argument_unpacking_done;
13651   __pyx_L5_argtuple_error:;
13652   __Pyx_RaiseArgtupleInvalid("flatten_el", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 684, __pyx_L3_error)
13653   __pyx_L3_error:;
13654   __Pyx_AddTraceback("lxml.html.diff.flatten_el", __pyx_clineno, __pyx_lineno, __pyx_filename);
13655   __Pyx_RefNannyFinishContext();
13656   return NULL;
13657   __pyx_L4_argument_unpacking_done:;
13658   __pyx_r = __pyx_pf_4lxml_4html_4diff_48flatten_el(__pyx_self, __pyx_v_el, __pyx_v_include_hrefs, __pyx_v_skip_tag);
13659
13660   /* function exit code */
13661   __Pyx_RefNannyFinishContext();
13662   return __pyx_r;
13663 }
13664
13665 static PyObject *__pyx_pf_4lxml_4html_4diff_48flatten_el(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_include_hrefs, PyObject *__pyx_v_skip_tag) {
13666   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *__pyx_cur_scope;
13667   PyObject *__pyx_r = NULL;
13668   __Pyx_RefNannyDeclarations
13669   int __pyx_lineno = 0;
13670   const char *__pyx_filename = NULL;
13671   int __pyx_clineno = 0;
13672   __Pyx_RefNannySetupContext("flatten_el", 0);
13673   __pyx_cur_scope = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el(__pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el, __pyx_empty_tuple, NULL);
13674   if (unlikely(!__pyx_cur_scope)) {
13675     __pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)Py_None);
13676     __Pyx_INCREF(Py_None);
13677     __PYX_ERR(0, 684, __pyx_L1_error)
13678   } else {
13679     __Pyx_GOTREF(__pyx_cur_scope);
13680   }
13681   __pyx_cur_scope->__pyx_v_el = __pyx_v_el;
13682   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_el);
13683   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_el);
13684   __pyx_cur_scope->__pyx_v_include_hrefs = __pyx_v_include_hrefs;
13685   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_include_hrefs);
13686   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_include_hrefs);
13687   __pyx_cur_scope->__pyx_v_skip_tag = __pyx_v_skip_tag;
13688   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_skip_tag);
13689   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_skip_tag);
13690   {
13691     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4lxml_4html_4diff_50generator2, __pyx_codeobj__17, (PyObject *) __pyx_cur_scope, __pyx_n_s_flatten_el, __pyx_n_s_flatten_el, __pyx_n_s_lxml_html_diff); if (unlikely(!gen)) __PYX_ERR(0, 684, __pyx_L1_error)
13692     __Pyx_DECREF(__pyx_cur_scope);
13693     __Pyx_RefNannyFinishContext();
13694     return (PyObject *) gen;
13695   }
13696
13697   /* function exit code */
13698   __pyx_L1_error:;
13699   __Pyx_AddTraceback("lxml.html.diff.flatten_el", __pyx_clineno, __pyx_lineno, __pyx_filename);
13700   __pyx_r = NULL;
13701   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
13702   __Pyx_XGIVEREF(__pyx_r);
13703   __Pyx_RefNannyFinishContext();
13704   return __pyx_r;
13705 }
13706
13707 static PyObject *__pyx_gb_4lxml_4html_4diff_50generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
13708 {
13709   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *__pyx_cur_scope = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)__pyx_generator->closure);
13710   PyObject *__pyx_r = NULL;
13711   int __pyx_t_1;
13712   int __pyx_t_2;
13713   PyObject *__pyx_t_3 = NULL;
13714   PyObject *__pyx_t_4 = NULL;
13715   PyObject *__pyx_t_5 = NULL;
13716   PyObject *__pyx_t_6 = NULL;
13717   int __pyx_t_7;
13718   Py_ssize_t __pyx_t_8;
13719   PyObject *(*__pyx_t_9)(PyObject *);
13720   PyObject *__pyx_t_10 = NULL;
13721   Py_ssize_t __pyx_t_11;
13722   PyObject *(*__pyx_t_12)(PyObject *);
13723   int __pyx_lineno = 0;
13724   const char *__pyx_filename = NULL;
13725   int __pyx_clineno = 0;
13726   __Pyx_RefNannyDeclarations
13727   __Pyx_RefNannySetupContext("flatten_el", 0);
13728   switch (__pyx_generator->resume_label) {
13729     case 0: goto __pyx_L3_first_run;
13730     case 1: goto __pyx_L6_resume_from_yield;
13731     case 2: goto __pyx_L7_resume_from_yield;
13732     case 3: goto __pyx_L15_resume_from_yield;
13733     case 4: goto __pyx_L20_resume_from_yield;
13734     case 5: goto __pyx_L25_resume_from_yield;
13735     case 6: goto __pyx_L27_resume_from_yield;
13736     case 7: goto __pyx_L30_resume_from_yield;
13737     default: /* CPython raises the right error here */
13738     __Pyx_RefNannyFinishContext();
13739     return NULL;
13740   }
13741   __pyx_L3_first_run:;
13742   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 684, __pyx_L1_error)
13743
13744   /* "lxml/html/diff.py":691
13745  *     If skip_tag is true, then the outermost container tag is
13746  *     not returned (just its contents)."""
13747  *     if not skip_tag:             # <<<<<<<<<<<<<<
13748  *         if el.tag == 'img':
13749  *             yield ('img', el.get('src'), start_tag(el))
13750  */
13751   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_skip_tag); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 691, __pyx_L1_error)
13752   __pyx_t_2 = ((!__pyx_t_1) != 0);
13753   if (__pyx_t_2) {
13754
13755     /* "lxml/html/diff.py":692
13756  *     not returned (just its contents)."""
13757  *     if not skip_tag:
13758  *         if el.tag == 'img':             # <<<<<<<<<<<<<<
13759  *             yield ('img', el.get('src'), start_tag(el))
13760  *         else:
13761  */
13762     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error)
13763     __Pyx_GOTREF(__pyx_t_3);
13764     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_img, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 692, __pyx_L1_error)
13765     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13766     if (__pyx_t_2) {
13767
13768       /* "lxml/html/diff.py":693
13769  *     if not skip_tag:
13770  *         if el.tag == 'img':
13771  *             yield ('img', el.get('src'), start_tag(el))             # <<<<<<<<<<<<<<
13772  *         else:
13773  *             yield start_tag(el)
13774  */
13775       __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
13776       __Pyx_GOTREF(__pyx_t_4);
13777       __pyx_t_5 = NULL;
13778       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
13779         __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
13780         if (likely(__pyx_t_5)) {
13781           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
13782           __Pyx_INCREF(__pyx_t_5);
13783           __Pyx_INCREF(function);
13784           __Pyx_DECREF_SET(__pyx_t_4, function);
13785         }
13786       }
13787       __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_n_u_src) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_n_u_src);
13788       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
13789       if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 693, __pyx_L1_error)
13790       __Pyx_GOTREF(__pyx_t_3);
13791       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13792       __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_start_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error)
13793       __Pyx_GOTREF(__pyx_t_5);
13794       __pyx_t_6 = NULL;
13795       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
13796         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
13797         if (likely(__pyx_t_6)) {
13798           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
13799           __Pyx_INCREF(__pyx_t_6);
13800           __Pyx_INCREF(function);
13801           __Pyx_DECREF_SET(__pyx_t_5, function);
13802         }
13803       }
13804       __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_cur_scope->__pyx_v_el) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_cur_scope->__pyx_v_el);
13805       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
13806       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
13807       __Pyx_GOTREF(__pyx_t_4);
13808       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13809       __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error)
13810       __Pyx_GOTREF(__pyx_t_5);
13811       __Pyx_INCREF(__pyx_n_u_img);
13812       __Pyx_GIVEREF(__pyx_n_u_img);
13813       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_img);
13814       __Pyx_GIVEREF(__pyx_t_3);
13815       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
13816       __Pyx_GIVEREF(__pyx_t_4);
13817       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
13818       __pyx_t_3 = 0;
13819       __pyx_t_4 = 0;
13820       __pyx_r = __pyx_t_5;
13821       __pyx_t_5 = 0;
13822       __Pyx_XGIVEREF(__pyx_r);
13823       __Pyx_RefNannyFinishContext();
13824       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
13825       /* return from generator, yielding value */
13826       __pyx_generator->resume_label = 1;
13827       return __pyx_r;
13828       __pyx_L6_resume_from_yield:;
13829       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 693, __pyx_L1_error)
13830
13831       /* "lxml/html/diff.py":692
13832  *     not returned (just its contents)."""
13833  *     if not skip_tag:
13834  *         if el.tag == 'img':             # <<<<<<<<<<<<<<
13835  *             yield ('img', el.get('src'), start_tag(el))
13836  *         else:
13837  */
13838       goto __pyx_L5;
13839     }
13840
13841     /* "lxml/html/diff.py":695
13842  *             yield ('img', el.get('src'), start_tag(el))
13843  *         else:
13844  *             yield start_tag(el)             # <<<<<<<<<<<<<<
13845  *     if el.tag in empty_tags and not el.text and not len(el) and not el.tail:
13846  *         return
13847  */
13848     /*else*/ {
13849       __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_start_tag); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 695, __pyx_L1_error)
13850       __Pyx_GOTREF(__pyx_t_4);
13851       __pyx_t_3 = NULL;
13852       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
13853         __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
13854         if (likely(__pyx_t_3)) {
13855           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
13856           __Pyx_INCREF(__pyx_t_3);
13857           __Pyx_INCREF(function);
13858           __Pyx_DECREF_SET(__pyx_t_4, function);
13859         }
13860       }
13861       __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_el) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_el);
13862       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13863       if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error)
13864       __Pyx_GOTREF(__pyx_t_5);
13865       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13866       __pyx_r = __pyx_t_5;
13867       __pyx_t_5 = 0;
13868       __Pyx_XGIVEREF(__pyx_r);
13869       __Pyx_RefNannyFinishContext();
13870       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
13871       /* return from generator, yielding value */
13872       __pyx_generator->resume_label = 2;
13873       return __pyx_r;
13874       __pyx_L7_resume_from_yield:;
13875       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 695, __pyx_L1_error)
13876     }
13877     __pyx_L5:;
13878
13879     /* "lxml/html/diff.py":691
13880  *     If skip_tag is true, then the outermost container tag is
13881  *     not returned (just its contents)."""
13882  *     if not skip_tag:             # <<<<<<<<<<<<<<
13883  *         if el.tag == 'img':
13884  *             yield ('img', el.get('src'), start_tag(el))
13885  */
13886   }
13887
13888   /* "lxml/html/diff.py":696
13889  *         else:
13890  *             yield start_tag(el)
13891  *     if el.tag in empty_tags and not el.text and not len(el) and not el.tail:             # <<<<<<<<<<<<<<
13892  *         return
13893  *     start_words = split_words(el.text)
13894  */
13895   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error)
13896   __Pyx_GOTREF(__pyx_t_5);
13897   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_empty_tags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error)
13898   __Pyx_GOTREF(__pyx_t_4);
13899   __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_5, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 696, __pyx_L1_error)
13900   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13901   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13902   __pyx_t_7 = (__pyx_t_1 != 0);
13903   if (__pyx_t_7) {
13904   } else {
13905     __pyx_t_2 = __pyx_t_7;
13906     goto __pyx_L9_bool_binop_done;
13907   }
13908   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error)
13909   __Pyx_GOTREF(__pyx_t_4);
13910   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 696, __pyx_L1_error)
13911   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13912   __pyx_t_1 = ((!__pyx_t_7) != 0);
13913   if (__pyx_t_1) {
13914   } else {
13915     __pyx_t_2 = __pyx_t_1;
13916     goto __pyx_L9_bool_binop_done;
13917   }
13918   __pyx_t_8 = PyObject_Length(__pyx_cur_scope->__pyx_v_el); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 696, __pyx_L1_error)
13919   __pyx_t_1 = ((!(__pyx_t_8 != 0)) != 0);
13920   if (__pyx_t_1) {
13921   } else {
13922     __pyx_t_2 = __pyx_t_1;
13923     goto __pyx_L9_bool_binop_done;
13924   }
13925   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error)
13926   __Pyx_GOTREF(__pyx_t_4);
13927   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 696, __pyx_L1_error)
13928   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13929   __pyx_t_7 = ((!__pyx_t_1) != 0);
13930   __pyx_t_2 = __pyx_t_7;
13931   __pyx_L9_bool_binop_done:;
13932   if (__pyx_t_2) {
13933
13934     /* "lxml/html/diff.py":697
13935  *             yield start_tag(el)
13936  *     if el.tag in empty_tags and not el.text and not len(el) and not el.tail:
13937  *         return             # <<<<<<<<<<<<<<
13938  *     start_words = split_words(el.text)
13939  *     for word in start_words:
13940  */
13941     __Pyx_XDECREF(__pyx_r);
13942     __pyx_r = NULL;
13943     goto __pyx_L0;
13944
13945     /* "lxml/html/diff.py":696
13946  *         else:
13947  *             yield start_tag(el)
13948  *     if el.tag in empty_tags and not el.text and not len(el) and not el.tail:             # <<<<<<<<<<<<<<
13949  *         return
13950  *     start_words = split_words(el.text)
13951  */
13952   }
13953
13954   /* "lxml/html/diff.py":698
13955  *     if el.tag in empty_tags and not el.text and not len(el) and not el.tail:
13956  *         return
13957  *     start_words = split_words(el.text)             # <<<<<<<<<<<<<<
13958  *     for word in start_words:
13959  *         yield html_escape(word)
13960  */
13961   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_split_words); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 698, __pyx_L1_error)
13962   __Pyx_GOTREF(__pyx_t_5);
13963   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 698, __pyx_L1_error)
13964   __Pyx_GOTREF(__pyx_t_3);
13965   __pyx_t_6 = NULL;
13966   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
13967     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
13968     if (likely(__pyx_t_6)) {
13969       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
13970       __Pyx_INCREF(__pyx_t_6);
13971       __Pyx_INCREF(function);
13972       __Pyx_DECREF_SET(__pyx_t_5, function);
13973     }
13974   }
13975   __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
13976   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
13977   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13978   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 698, __pyx_L1_error)
13979   __Pyx_GOTREF(__pyx_t_4);
13980   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13981   __Pyx_GIVEREF(__pyx_t_4);
13982   __pyx_cur_scope->__pyx_v_start_words = __pyx_t_4;
13983   __pyx_t_4 = 0;
13984
13985   /* "lxml/html/diff.py":699
13986  *         return
13987  *     start_words = split_words(el.text)
13988  *     for word in start_words:             # <<<<<<<<<<<<<<
13989  *         yield html_escape(word)
13990  *     for child in el:
13991  */
13992   if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_start_words)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_start_words)) {
13993     __pyx_t_4 = __pyx_cur_scope->__pyx_v_start_words; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
13994     __pyx_t_9 = NULL;
13995   } else {
13996     __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_start_words); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 699, __pyx_L1_error)
13997     __Pyx_GOTREF(__pyx_t_4);
13998     __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 699, __pyx_L1_error)
13999   }
14000   for (;;) {
14001     if (likely(!__pyx_t_9)) {
14002       if (likely(PyList_CheckExact(__pyx_t_4))) {
14003         if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
14004         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14005         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 699, __pyx_L1_error)
14006         #else
14007         __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 699, __pyx_L1_error)
14008         __Pyx_GOTREF(__pyx_t_5);
14009         #endif
14010       } else {
14011         if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
14012         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14013         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 699, __pyx_L1_error)
14014         #else
14015         __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 699, __pyx_L1_error)
14016         __Pyx_GOTREF(__pyx_t_5);
14017         #endif
14018       }
14019     } else {
14020       __pyx_t_5 = __pyx_t_9(__pyx_t_4);
14021       if (unlikely(!__pyx_t_5)) {
14022         PyObject* exc_type = PyErr_Occurred();
14023         if (exc_type) {
14024           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
14025           else __PYX_ERR(0, 699, __pyx_L1_error)
14026         }
14027         break;
14028       }
14029       __Pyx_GOTREF(__pyx_t_5);
14030     }
14031     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_word);
14032     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_word, __pyx_t_5);
14033     __Pyx_GIVEREF(__pyx_t_5);
14034     __pyx_t_5 = 0;
14035
14036     /* "lxml/html/diff.py":700
14037  *     start_words = split_words(el.text)
14038  *     for word in start_words:
14039  *         yield html_escape(word)             # <<<<<<<<<<<<<<
14040  *     for child in el:
14041  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14042  */
14043     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_html_escape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 700, __pyx_L1_error)
14044     __Pyx_GOTREF(__pyx_t_3);
14045     __pyx_t_6 = NULL;
14046     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
14047       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
14048       if (likely(__pyx_t_6)) {
14049         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
14050         __Pyx_INCREF(__pyx_t_6);
14051         __Pyx_INCREF(function);
14052         __Pyx_DECREF_SET(__pyx_t_3, function);
14053       }
14054     }
14055     __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_cur_scope->__pyx_v_word) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_word);
14056     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
14057     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
14058     __Pyx_GOTREF(__pyx_t_5);
14059     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14060     __pyx_r = __pyx_t_5;
14061     __pyx_t_5 = 0;
14062     __Pyx_XGIVEREF(__pyx_t_4);
14063     __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
14064     __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
14065     __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
14066     __Pyx_XGIVEREF(__pyx_r);
14067     __Pyx_RefNannyFinishContext();
14068     __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14069     /* return from generator, yielding value */
14070     __pyx_generator->resume_label = 3;
14071     return __pyx_r;
14072     __pyx_L15_resume_from_yield:;
14073     __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
14074     __pyx_cur_scope->__pyx_t_0 = 0;
14075     __Pyx_XGOTREF(__pyx_t_4);
14076     __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
14077     __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
14078     if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 700, __pyx_L1_error)
14079
14080     /* "lxml/html/diff.py":699
14081  *         return
14082  *     start_words = split_words(el.text)
14083  *     for word in start_words:             # <<<<<<<<<<<<<<
14084  *         yield html_escape(word)
14085  *     for child in el:
14086  */
14087   }
14088   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14089
14090   /* "lxml/html/diff.py":701
14091  *     for word in start_words:
14092  *         yield html_escape(word)
14093  *     for child in el:             # <<<<<<<<<<<<<<
14094  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14095  *             yield item
14096  */
14097   if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_el)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_el)) {
14098     __pyx_t_4 = __pyx_cur_scope->__pyx_v_el; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
14099     __pyx_t_9 = NULL;
14100   } else {
14101     __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_el); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 701, __pyx_L1_error)
14102     __Pyx_GOTREF(__pyx_t_4);
14103     __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 701, __pyx_L1_error)
14104   }
14105   for (;;) {
14106     if (likely(!__pyx_t_9)) {
14107       if (likely(PyList_CheckExact(__pyx_t_4))) {
14108         if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
14109         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14110         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 701, __pyx_L1_error)
14111         #else
14112         __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
14113         __Pyx_GOTREF(__pyx_t_5);
14114         #endif
14115       } else {
14116         if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
14117         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14118         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 701, __pyx_L1_error)
14119         #else
14120         __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
14121         __Pyx_GOTREF(__pyx_t_5);
14122         #endif
14123       }
14124     } else {
14125       __pyx_t_5 = __pyx_t_9(__pyx_t_4);
14126       if (unlikely(!__pyx_t_5)) {
14127         PyObject* exc_type = PyErr_Occurred();
14128         if (exc_type) {
14129           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
14130           else __PYX_ERR(0, 701, __pyx_L1_error)
14131         }
14132         break;
14133       }
14134       __Pyx_GOTREF(__pyx_t_5);
14135     }
14136     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_child);
14137     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_child, __pyx_t_5);
14138     __Pyx_GIVEREF(__pyx_t_5);
14139     __pyx_t_5 = 0;
14140
14141     /* "lxml/html/diff.py":702
14142  *         yield html_escape(word)
14143  *     for child in el:
14144  *         for item in flatten_el(child, include_hrefs=include_hrefs):             # <<<<<<<<<<<<<<
14145  *             yield item
14146  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14147  */
14148     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_flatten_el); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
14149     __Pyx_GOTREF(__pyx_t_5);
14150     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
14151     __Pyx_GOTREF(__pyx_t_3);
14152     __Pyx_INCREF(__pyx_cur_scope->__pyx_v_child);
14153     __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_child);
14154     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_child);
14155     __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 702, __pyx_L1_error)
14156     __Pyx_GOTREF(__pyx_t_6);
14157     if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_include_hrefs, __pyx_cur_scope->__pyx_v_include_hrefs) < 0) __PYX_ERR(0, 702, __pyx_L1_error)
14158     __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 702, __pyx_L1_error)
14159     __Pyx_GOTREF(__pyx_t_10);
14160     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14161     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14162     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14163     if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
14164       __pyx_t_6 = __pyx_t_10; __Pyx_INCREF(__pyx_t_6); __pyx_t_11 = 0;
14165       __pyx_t_12 = NULL;
14166     } else {
14167       __pyx_t_11 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 702, __pyx_L1_error)
14168       __Pyx_GOTREF(__pyx_t_6);
14169       __pyx_t_12 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 702, __pyx_L1_error)
14170     }
14171     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14172     for (;;) {
14173       if (likely(!__pyx_t_12)) {
14174         if (likely(PyList_CheckExact(__pyx_t_6))) {
14175           if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_6)) break;
14176           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14177           __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_11); __Pyx_INCREF(__pyx_t_10); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 702, __pyx_L1_error)
14178           #else
14179           __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 702, __pyx_L1_error)
14180           __Pyx_GOTREF(__pyx_t_10);
14181           #endif
14182         } else {
14183           if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
14184           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14185           __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_11); __Pyx_INCREF(__pyx_t_10); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 702, __pyx_L1_error)
14186           #else
14187           __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 702, __pyx_L1_error)
14188           __Pyx_GOTREF(__pyx_t_10);
14189           #endif
14190         }
14191       } else {
14192         __pyx_t_10 = __pyx_t_12(__pyx_t_6);
14193         if (unlikely(!__pyx_t_10)) {
14194           PyObject* exc_type = PyErr_Occurred();
14195           if (exc_type) {
14196             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
14197             else __PYX_ERR(0, 702, __pyx_L1_error)
14198           }
14199           break;
14200         }
14201         __Pyx_GOTREF(__pyx_t_10);
14202       }
14203       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_item);
14204       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_item, __pyx_t_10);
14205       __Pyx_GIVEREF(__pyx_t_10);
14206       __pyx_t_10 = 0;
14207
14208       /* "lxml/html/diff.py":703
14209  *     for child in el:
14210  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14211  *             yield item             # <<<<<<<<<<<<<<
14212  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14213  *         yield ('href', el.get('href'))
14214  */
14215       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_item);
14216       __pyx_r = __pyx_cur_scope->__pyx_v_item;
14217       __Pyx_XGIVEREF(__pyx_t_4);
14218       __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
14219       __Pyx_XGIVEREF(__pyx_t_6);
14220       __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
14221       __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
14222       __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
14223       __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
14224       __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
14225       __Pyx_XGIVEREF(__pyx_r);
14226       __Pyx_RefNannyFinishContext();
14227       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14228       /* return from generator, yielding value */
14229       __pyx_generator->resume_label = 4;
14230       return __pyx_r;
14231       __pyx_L20_resume_from_yield:;
14232       __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
14233       __pyx_cur_scope->__pyx_t_0 = 0;
14234       __Pyx_XGOTREF(__pyx_t_4);
14235       __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
14236       __pyx_cur_scope->__pyx_t_3 = 0;
14237       __Pyx_XGOTREF(__pyx_t_6);
14238       __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
14239       __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
14240       __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
14241       __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
14242       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 703, __pyx_L1_error)
14243
14244       /* "lxml/html/diff.py":702
14245  *         yield html_escape(word)
14246  *     for child in el:
14247  *         for item in flatten_el(child, include_hrefs=include_hrefs):             # <<<<<<<<<<<<<<
14248  *             yield item
14249  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14250  */
14251     }
14252     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14253
14254     /* "lxml/html/diff.py":701
14255  *     for word in start_words:
14256  *         yield html_escape(word)
14257  *     for child in el:             # <<<<<<<<<<<<<<
14258  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14259  *             yield item
14260  */
14261   }
14262   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14263
14264   /* "lxml/html/diff.py":704
14265  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14266  *             yield item
14267  *     if el.tag == 'a' and el.get('href') and include_hrefs:             # <<<<<<<<<<<<<<
14268  *         yield ('href', el.get('href'))
14269  *     if not skip_tag:
14270  */
14271   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 704, __pyx_L1_error)
14272   __Pyx_GOTREF(__pyx_t_4);
14273   __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_a, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 704, __pyx_L1_error)
14274   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14275   if (__pyx_t_7) {
14276   } else {
14277     __pyx_t_2 = __pyx_t_7;
14278     goto __pyx_L22_bool_binop_done;
14279   }
14280   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 704, __pyx_L1_error)
14281   __Pyx_GOTREF(__pyx_t_6);
14282   __pyx_t_10 = NULL;
14283   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
14284     __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
14285     if (likely(__pyx_t_10)) {
14286       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
14287       __Pyx_INCREF(__pyx_t_10);
14288       __Pyx_INCREF(function);
14289       __Pyx_DECREF_SET(__pyx_t_6, function);
14290     }
14291   }
14292   __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_n_u_href) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_n_u_href);
14293   __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
14294   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 704, __pyx_L1_error)
14295   __Pyx_GOTREF(__pyx_t_4);
14296   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14297   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 704, __pyx_L1_error)
14298   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14299   if (__pyx_t_7) {
14300   } else {
14301     __pyx_t_2 = __pyx_t_7;
14302     goto __pyx_L22_bool_binop_done;
14303   }
14304   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_include_hrefs); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 704, __pyx_L1_error)
14305   __pyx_t_2 = __pyx_t_7;
14306   __pyx_L22_bool_binop_done:;
14307   if (__pyx_t_2) {
14308
14309     /* "lxml/html/diff.py":705
14310  *             yield item
14311  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14312  *         yield ('href', el.get('href'))             # <<<<<<<<<<<<<<
14313  *     if not skip_tag:
14314  *         yield end_tag(el)
14315  */
14316     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 705, __pyx_L1_error)
14317     __Pyx_GOTREF(__pyx_t_6);
14318     __pyx_t_10 = NULL;
14319     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
14320       __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
14321       if (likely(__pyx_t_10)) {
14322         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
14323         __Pyx_INCREF(__pyx_t_10);
14324         __Pyx_INCREF(function);
14325         __Pyx_DECREF_SET(__pyx_t_6, function);
14326       }
14327     }
14328     __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_n_u_href) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_n_u_href);
14329     __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
14330     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 705, __pyx_L1_error)
14331     __Pyx_GOTREF(__pyx_t_4);
14332     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14333     __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 705, __pyx_L1_error)
14334     __Pyx_GOTREF(__pyx_t_6);
14335     __Pyx_INCREF(__pyx_n_u_href);
14336     __Pyx_GIVEREF(__pyx_n_u_href);
14337     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_href);
14338     __Pyx_GIVEREF(__pyx_t_4);
14339     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
14340     __pyx_t_4 = 0;
14341     __pyx_r = __pyx_t_6;
14342     __pyx_t_6 = 0;
14343     __Pyx_XGIVEREF(__pyx_r);
14344     __Pyx_RefNannyFinishContext();
14345     __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14346     /* return from generator, yielding value */
14347     __pyx_generator->resume_label = 5;
14348     return __pyx_r;
14349     __pyx_L25_resume_from_yield:;
14350     if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 705, __pyx_L1_error)
14351
14352     /* "lxml/html/diff.py":704
14353  *         for item in flatten_el(child, include_hrefs=include_hrefs):
14354  *             yield item
14355  *     if el.tag == 'a' and el.get('href') and include_hrefs:             # <<<<<<<<<<<<<<
14356  *         yield ('href', el.get('href'))
14357  *     if not skip_tag:
14358  */
14359   }
14360
14361   /* "lxml/html/diff.py":706
14362  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14363  *         yield ('href', el.get('href'))
14364  *     if not skip_tag:             # <<<<<<<<<<<<<<
14365  *         yield end_tag(el)
14366  *         end_words = split_words(el.tail)
14367  */
14368   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_skip_tag); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 706, __pyx_L1_error)
14369   __pyx_t_7 = ((!__pyx_t_2) != 0);
14370   if (__pyx_t_7) {
14371
14372     /* "lxml/html/diff.py":707
14373  *         yield ('href', el.get('href'))
14374  *     if not skip_tag:
14375  *         yield end_tag(el)             # <<<<<<<<<<<<<<
14376  *         end_words = split_words(el.tail)
14377  *         for word in end_words:
14378  */
14379     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_end_tag); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L1_error)
14380     __Pyx_GOTREF(__pyx_t_4);
14381     __pyx_t_10 = NULL;
14382     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
14383       __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
14384       if (likely(__pyx_t_10)) {
14385         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
14386         __Pyx_INCREF(__pyx_t_10);
14387         __Pyx_INCREF(function);
14388         __Pyx_DECREF_SET(__pyx_t_4, function);
14389       }
14390     }
14391     __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_cur_scope->__pyx_v_el) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_el);
14392     __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
14393     if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 707, __pyx_L1_error)
14394     __Pyx_GOTREF(__pyx_t_6);
14395     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14396     __pyx_r = __pyx_t_6;
14397     __pyx_t_6 = 0;
14398     __Pyx_XGIVEREF(__pyx_r);
14399     __Pyx_RefNannyFinishContext();
14400     __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14401     /* return from generator, yielding value */
14402     __pyx_generator->resume_label = 6;
14403     return __pyx_r;
14404     __pyx_L27_resume_from_yield:;
14405     if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 707, __pyx_L1_error)
14406
14407     /* "lxml/html/diff.py":708
14408  *     if not skip_tag:
14409  *         yield end_tag(el)
14410  *         end_words = split_words(el.tail)             # <<<<<<<<<<<<<<
14411  *         for word in end_words:
14412  *             yield html_escape(word)
14413  */
14414     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_split_words); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 708, __pyx_L1_error)
14415     __Pyx_GOTREF(__pyx_t_4);
14416     __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 708, __pyx_L1_error)
14417     __Pyx_GOTREF(__pyx_t_10);
14418     __pyx_t_3 = NULL;
14419     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
14420       __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
14421       if (likely(__pyx_t_3)) {
14422         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
14423         __Pyx_INCREF(__pyx_t_3);
14424         __Pyx_INCREF(function);
14425         __Pyx_DECREF_SET(__pyx_t_4, function);
14426       }
14427     }
14428     __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10);
14429     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
14430     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14431     if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 708, __pyx_L1_error)
14432     __Pyx_GOTREF(__pyx_t_6);
14433     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14434     __Pyx_GIVEREF(__pyx_t_6);
14435     __pyx_cur_scope->__pyx_v_end_words = __pyx_t_6;
14436     __pyx_t_6 = 0;
14437
14438     /* "lxml/html/diff.py":709
14439  *         yield end_tag(el)
14440  *         end_words = split_words(el.tail)
14441  *         for word in end_words:             # <<<<<<<<<<<<<<
14442  *             yield html_escape(word)
14443  * 
14444  */
14445     if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_end_words)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_end_words)) {
14446       __pyx_t_6 = __pyx_cur_scope->__pyx_v_end_words; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
14447       __pyx_t_9 = NULL;
14448     } else {
14449       __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_end_words); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 709, __pyx_L1_error)
14450       __Pyx_GOTREF(__pyx_t_6);
14451       __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 709, __pyx_L1_error)
14452     }
14453     for (;;) {
14454       if (likely(!__pyx_t_9)) {
14455         if (likely(PyList_CheckExact(__pyx_t_6))) {
14456           if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
14457           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14458           __pyx_t_4 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
14459           #else
14460           __pyx_t_4 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error)
14461           __Pyx_GOTREF(__pyx_t_4);
14462           #endif
14463         } else {
14464           if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
14465           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14466           __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
14467           #else
14468           __pyx_t_4 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error)
14469           __Pyx_GOTREF(__pyx_t_4);
14470           #endif
14471         }
14472       } else {
14473         __pyx_t_4 = __pyx_t_9(__pyx_t_6);
14474         if (unlikely(!__pyx_t_4)) {
14475           PyObject* exc_type = PyErr_Occurred();
14476           if (exc_type) {
14477             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
14478             else __PYX_ERR(0, 709, __pyx_L1_error)
14479           }
14480           break;
14481         }
14482         __Pyx_GOTREF(__pyx_t_4);
14483       }
14484       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_word);
14485       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_word, __pyx_t_4);
14486       __Pyx_GIVEREF(__pyx_t_4);
14487       __pyx_t_4 = 0;
14488
14489       /* "lxml/html/diff.py":710
14490  *         end_words = split_words(el.tail)
14491  *         for word in end_words:
14492  *             yield html_escape(word)             # <<<<<<<<<<<<<<
14493  * 
14494  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
14495  */
14496       __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_html_escape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 710, __pyx_L1_error)
14497       __Pyx_GOTREF(__pyx_t_10);
14498       __pyx_t_3 = NULL;
14499       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
14500         __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
14501         if (likely(__pyx_t_3)) {
14502           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
14503           __Pyx_INCREF(__pyx_t_3);
14504           __Pyx_INCREF(function);
14505           __Pyx_DECREF_SET(__pyx_t_10, function);
14506         }
14507       }
14508       __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_3, __pyx_cur_scope->__pyx_v_word) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_cur_scope->__pyx_v_word);
14509       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
14510       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 710, __pyx_L1_error)
14511       __Pyx_GOTREF(__pyx_t_4);
14512       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14513       __pyx_r = __pyx_t_4;
14514       __pyx_t_4 = 0;
14515       __Pyx_XGIVEREF(__pyx_t_6);
14516       __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
14517       __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
14518       __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
14519       __Pyx_XGIVEREF(__pyx_r);
14520       __Pyx_RefNannyFinishContext();
14521       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14522       /* return from generator, yielding value */
14523       __pyx_generator->resume_label = 7;
14524       return __pyx_r;
14525       __pyx_L30_resume_from_yield:;
14526       __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
14527       __pyx_cur_scope->__pyx_t_0 = 0;
14528       __Pyx_XGOTREF(__pyx_t_6);
14529       __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
14530       __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
14531       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 710, __pyx_L1_error)
14532
14533       /* "lxml/html/diff.py":709
14534  *         yield end_tag(el)
14535  *         end_words = split_words(el.tail)
14536  *         for word in end_words:             # <<<<<<<<<<<<<<
14537  *             yield html_escape(word)
14538  * 
14539  */
14540     }
14541     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14542
14543     /* "lxml/html/diff.py":706
14544  *     if el.tag == 'a' and el.get('href') and include_hrefs:
14545  *         yield ('href', el.get('href'))
14546  *     if not skip_tag:             # <<<<<<<<<<<<<<
14547  *         yield end_tag(el)
14548  *         end_words = split_words(el.tail)
14549  */
14550   }
14551   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
14552
14553   /* "lxml/html/diff.py":684
14554  * 
14555  * 
14556  * def flatten_el(el, include_hrefs, skip_tag=False):             # <<<<<<<<<<<<<<
14557  *     """ Takes an lxml element el, and generates all the text chunks for
14558  *     that tag.  Each start tag is a chunk, each word is a chunk, and each
14559  */
14560
14561   /* function exit code */
14562   PyErr_SetNone(PyExc_StopIteration);
14563   goto __pyx_L0;
14564   __pyx_L1_error:;
14565   __Pyx_XDECREF(__pyx_t_3);
14566   __Pyx_XDECREF(__pyx_t_4);
14567   __Pyx_XDECREF(__pyx_t_5);
14568   __Pyx_XDECREF(__pyx_t_6);
14569   __Pyx_XDECREF(__pyx_t_10);
14570   __Pyx_AddTraceback("flatten_el", __pyx_clineno, __pyx_lineno, __pyx_filename);
14571   __pyx_L0:;
14572   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
14573   #if !CYTHON_USE_EXC_INFO_STACK
14574   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
14575   #endif
14576   __pyx_generator->resume_label = -1;
14577   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
14578   __Pyx_RefNannyFinishContext();
14579   return __pyx_r;
14580 }
14581
14582 /* "lxml/html/diff.py":714
14583  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
14584  * 
14585  * def split_words(text):             # <<<<<<<<<<<<<<
14586  *     """ Splits some text into words. Includes trailing whitespace
14587  *     on each word when appropriate.  """
14588  */
14589
14590 /* Python wrapper */
14591 static PyObject *__pyx_pw_4lxml_4html_4diff_52split_words(PyObject *__pyx_self, PyObject *__pyx_v_text); /*proto*/
14592 static char __pyx_doc_4lxml_4html_4diff_51split_words[] = " Splits some text into words. Includes trailing whitespace\n    on each word when appropriate.  ";
14593 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_52split_words = {"split_words", (PyCFunction)__pyx_pw_4lxml_4html_4diff_52split_words, METH_O, __pyx_doc_4lxml_4html_4diff_51split_words};
14594 static PyObject *__pyx_pw_4lxml_4html_4diff_52split_words(PyObject *__pyx_self, PyObject *__pyx_v_text) {
14595   PyObject *__pyx_r = 0;
14596   __Pyx_RefNannyDeclarations
14597   __Pyx_RefNannySetupContext("split_words (wrapper)", 0);
14598   __pyx_r = __pyx_pf_4lxml_4html_4diff_51split_words(__pyx_self, ((PyObject *)__pyx_v_text));
14599
14600   /* function exit code */
14601   __Pyx_RefNannyFinishContext();
14602   return __pyx_r;
14603 }
14604
14605 static PyObject *__pyx_pf_4lxml_4html_4diff_51split_words(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text) {
14606   PyObject *__pyx_v_words = NULL;
14607   PyObject *__pyx_r = NULL;
14608   __Pyx_RefNannyDeclarations
14609   int __pyx_t_1;
14610   int __pyx_t_2;
14611   int __pyx_t_3;
14612   PyObject *__pyx_t_4 = NULL;
14613   PyObject *__pyx_t_5 = NULL;
14614   PyObject *__pyx_t_6 = NULL;
14615   int __pyx_lineno = 0;
14616   const char *__pyx_filename = NULL;
14617   int __pyx_clineno = 0;
14618   __Pyx_RefNannySetupContext("split_words", 0);
14619
14620   /* "lxml/html/diff.py":717
14621  *     """ Splits some text into words. Includes trailing whitespace
14622  *     on each word when appropriate.  """
14623  *     if not text or not text.strip():             # <<<<<<<<<<<<<<
14624  *         return []
14625  * 
14626  */
14627   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_text); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 717, __pyx_L1_error)
14628   __pyx_t_3 = ((!__pyx_t_2) != 0);
14629   if (!__pyx_t_3) {
14630   } else {
14631     __pyx_t_1 = __pyx_t_3;
14632     goto __pyx_L4_bool_binop_done;
14633   }
14634   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_text, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 717, __pyx_L1_error)
14635   __Pyx_GOTREF(__pyx_t_5);
14636   __pyx_t_6 = NULL;
14637   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
14638     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
14639     if (likely(__pyx_t_6)) {
14640       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
14641       __Pyx_INCREF(__pyx_t_6);
14642       __Pyx_INCREF(function);
14643       __Pyx_DECREF_SET(__pyx_t_5, function);
14644     }
14645   }
14646   __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
14647   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
14648   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 717, __pyx_L1_error)
14649   __Pyx_GOTREF(__pyx_t_4);
14650   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14651   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 717, __pyx_L1_error)
14652   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14653   __pyx_t_2 = ((!__pyx_t_3) != 0);
14654   __pyx_t_1 = __pyx_t_2;
14655   __pyx_L4_bool_binop_done:;
14656   if (__pyx_t_1) {
14657
14658     /* "lxml/html/diff.py":718
14659  *     on each word when appropriate.  """
14660  *     if not text or not text.strip():
14661  *         return []             # <<<<<<<<<<<<<<
14662  * 
14663  *     words = split_words_re.findall(text)
14664  */
14665     __Pyx_XDECREF(__pyx_r);
14666     __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __pyx_L1_error)
14667     __Pyx_GOTREF(__pyx_t_4);
14668     __pyx_r = __pyx_t_4;
14669     __pyx_t_4 = 0;
14670     goto __pyx_L0;
14671
14672     /* "lxml/html/diff.py":717
14673  *     """ Splits some text into words. Includes trailing whitespace
14674  *     on each word when appropriate.  """
14675  *     if not text or not text.strip():             # <<<<<<<<<<<<<<
14676  *         return []
14677  * 
14678  */
14679   }
14680
14681   /* "lxml/html/diff.py":720
14682  *         return []
14683  * 
14684  *     words = split_words_re.findall(text)             # <<<<<<<<<<<<<<
14685  *     return words
14686  * 
14687  */
14688   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_split_words_re); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 720, __pyx_L1_error)
14689   __Pyx_GOTREF(__pyx_t_5);
14690   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_findall); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 720, __pyx_L1_error)
14691   __Pyx_GOTREF(__pyx_t_6);
14692   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14693   __pyx_t_5 = NULL;
14694   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
14695     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
14696     if (likely(__pyx_t_5)) {
14697       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
14698       __Pyx_INCREF(__pyx_t_5);
14699       __Pyx_INCREF(function);
14700       __Pyx_DECREF_SET(__pyx_t_6, function);
14701     }
14702   }
14703   __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_text) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_text);
14704   __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14705   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error)
14706   __Pyx_GOTREF(__pyx_t_4);
14707   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14708   __pyx_v_words = __pyx_t_4;
14709   __pyx_t_4 = 0;
14710
14711   /* "lxml/html/diff.py":721
14712  * 
14713  *     words = split_words_re.findall(text)
14714  *     return words             # <<<<<<<<<<<<<<
14715  * 
14716  * start_whitespace_re = re.compile(r'^[ \t\n\r]')
14717  */
14718   __Pyx_XDECREF(__pyx_r);
14719   __Pyx_INCREF(__pyx_v_words);
14720   __pyx_r = __pyx_v_words;
14721   goto __pyx_L0;
14722
14723   /* "lxml/html/diff.py":714
14724  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
14725  * 
14726  * def split_words(text):             # <<<<<<<<<<<<<<
14727  *     """ Splits some text into words. Includes trailing whitespace
14728  *     on each word when appropriate.  """
14729  */
14730
14731   /* function exit code */
14732   __pyx_L1_error:;
14733   __Pyx_XDECREF(__pyx_t_4);
14734   __Pyx_XDECREF(__pyx_t_5);
14735   __Pyx_XDECREF(__pyx_t_6);
14736   __Pyx_AddTraceback("lxml.html.diff.split_words", __pyx_clineno, __pyx_lineno, __pyx_filename);
14737   __pyx_r = NULL;
14738   __pyx_L0:;
14739   __Pyx_XDECREF(__pyx_v_words);
14740   __Pyx_XGIVEREF(__pyx_r);
14741   __Pyx_RefNannyFinishContext();
14742   return __pyx_r;
14743 }
14744
14745 /* "lxml/html/diff.py":725
14746  * start_whitespace_re = re.compile(r'^[ \t\n\r]')
14747  * 
14748  * def start_tag(el):             # <<<<<<<<<<<<<<
14749  *     """
14750  *     The text representation of the start tag for a tag.
14751  */
14752
14753 /* Python wrapper */
14754 static PyObject *__pyx_pw_4lxml_4html_4diff_54start_tag(PyObject *__pyx_self, PyObject *__pyx_v_el); /*proto*/
14755 static char __pyx_doc_4lxml_4html_4diff_53start_tag[] = "\n    The text representation of the start tag for a tag.\n    ";
14756 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_54start_tag = {"start_tag", (PyCFunction)__pyx_pw_4lxml_4html_4diff_54start_tag, METH_O, __pyx_doc_4lxml_4html_4diff_53start_tag};
14757 static PyObject *__pyx_pw_4lxml_4html_4diff_54start_tag(PyObject *__pyx_self, PyObject *__pyx_v_el) {
14758   PyObject *__pyx_r = 0;
14759   __Pyx_RefNannyDeclarations
14760   __Pyx_RefNannySetupContext("start_tag (wrapper)", 0);
14761   __pyx_r = __pyx_pf_4lxml_4html_4diff_53start_tag(__pyx_self, ((PyObject *)__pyx_v_el));
14762
14763   /* function exit code */
14764   __Pyx_RefNannyFinishContext();
14765   return __pyx_r;
14766 }
14767
14768 static PyObject *__pyx_pf_4lxml_4html_4diff_53start_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el) {
14769   PyObject *__pyx_8genexpr4__pyx_v_name = NULL;
14770   PyObject *__pyx_8genexpr4__pyx_v_value = NULL;
14771   PyObject *__pyx_r = NULL;
14772   __Pyx_RefNannyDeclarations
14773   PyObject *__pyx_t_1 = NULL;
14774   Py_ssize_t __pyx_t_2;
14775   Py_UCS4 __pyx_t_3;
14776   PyObject *__pyx_t_4 = NULL;
14777   PyObject *__pyx_t_5 = NULL;
14778   Py_ssize_t __pyx_t_6;
14779   Py_ssize_t __pyx_t_7;
14780   int __pyx_t_8;
14781   PyObject *__pyx_t_9 = NULL;
14782   PyObject *__pyx_t_10 = NULL;
14783   int __pyx_t_11;
14784   Py_ssize_t __pyx_t_12;
14785   Py_UCS4 __pyx_t_13;
14786   PyObject *__pyx_t_14 = NULL;
14787   PyObject *__pyx_t_15 = NULL;
14788   PyObject *__pyx_t_16 = NULL;
14789   int __pyx_lineno = 0;
14790   const char *__pyx_filename = NULL;
14791   int __pyx_clineno = 0;
14792   __Pyx_RefNannySetupContext("start_tag", 0);
14793
14794   /* "lxml/html/diff.py":729
14795  *     The text representation of the start tag for a tag.
14796  *     """
14797  *     return '<%s%s>' % (             # <<<<<<<<<<<<<<
14798  *         el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))
14799  *                          for name, value in el.attrib.items()]))
14800  */
14801   __Pyx_XDECREF(__pyx_r);
14802   __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L1_error)
14803   __Pyx_GOTREF(__pyx_t_1);
14804   __pyx_t_2 = 0;
14805   __pyx_t_3 = 127;
14806   __Pyx_INCREF(__pyx_kp_u__8);
14807   __pyx_t_2 += 1;
14808   __Pyx_GIVEREF(__pyx_kp_u__8);
14809   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__8);
14810
14811   /* "lxml/html/diff.py":730
14812  *     """
14813  *     return '<%s%s>' % (
14814  *         el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))             # <<<<<<<<<<<<<<
14815  *                          for name, value in el.attrib.items()]))
14816  * 
14817  */
14818   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
14819   __Pyx_GOTREF(__pyx_t_4);
14820   __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __pyx_L1_error)
14821   __Pyx_GOTREF(__pyx_t_5);
14822   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14823   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
14824   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
14825   __Pyx_GIVEREF(__pyx_t_5);
14826   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
14827   __pyx_t_5 = 0;
14828   { /* enter inner scope */
14829     __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __pyx_L5_error)
14830     __Pyx_GOTREF(__pyx_t_5);
14831
14832     /* "lxml/html/diff.py":731
14833  *     return '<%s%s>' % (
14834  *         el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))
14835  *                          for name, value in el.attrib.items()]))             # <<<<<<<<<<<<<<
14836  * 
14837  * def end_tag(el):
14838  */
14839     __pyx_t_6 = 0;
14840     __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_attrib); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 731, __pyx_L5_error)
14841     __Pyx_GOTREF(__pyx_t_9);
14842     if (unlikely(__pyx_t_9 == Py_None)) {
14843       PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
14844       __PYX_ERR(0, 731, __pyx_L5_error)
14845     }
14846     __pyx_t_10 = __Pyx_dict_iterator(__pyx_t_9, 0, __pyx_n_s_items, (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 731, __pyx_L5_error)
14847     __Pyx_GOTREF(__pyx_t_10);
14848     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
14849     __Pyx_XDECREF(__pyx_t_4);
14850     __pyx_t_4 = __pyx_t_10;
14851     __pyx_t_10 = 0;
14852     while (1) {
14853       __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_7, &__pyx_t_6, &__pyx_t_10, &__pyx_t_9, NULL, __pyx_t_8);
14854       if (unlikely(__pyx_t_11 == 0)) break;
14855       if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 731, __pyx_L5_error)
14856       __Pyx_GOTREF(__pyx_t_10);
14857       __Pyx_GOTREF(__pyx_t_9);
14858       __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_name, __pyx_t_10);
14859       __pyx_t_10 = 0;
14860       __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_value, __pyx_t_9);
14861       __pyx_t_9 = 0;
14862
14863       /* "lxml/html/diff.py":730
14864  *     """
14865  *     return '<%s%s>' % (
14866  *         el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))             # <<<<<<<<<<<<<<
14867  *                          for name, value in el.attrib.items()]))
14868  * 
14869  */
14870       __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 730, __pyx_L5_error)
14871       __Pyx_GOTREF(__pyx_t_9);
14872       __pyx_t_12 = 0;
14873       __pyx_t_13 = 127;
14874       __Pyx_INCREF(__pyx_kp_u__6);
14875       __pyx_t_12 += 1;
14876       __Pyx_GIVEREF(__pyx_kp_u__6);
14877       PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u__6);
14878       __pyx_t_10 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_8genexpr4__pyx_v_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 730, __pyx_L5_error)
14879       __Pyx_GOTREF(__pyx_t_10);
14880       __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_13;
14881       __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
14882       __Pyx_GIVEREF(__pyx_t_10);
14883       PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
14884       __pyx_t_10 = 0;
14885       __Pyx_INCREF(__pyx_kp_u__18);
14886       __pyx_t_12 += 2;
14887       __Pyx_GIVEREF(__pyx_kp_u__18);
14888       PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__18);
14889       __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_html_escape); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 730, __pyx_L5_error)
14890       __Pyx_GOTREF(__pyx_t_14);
14891       __pyx_t_15 = NULL;
14892       __pyx_t_11 = 0;
14893       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
14894         __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
14895         if (likely(__pyx_t_15)) {
14896           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
14897           __Pyx_INCREF(__pyx_t_15);
14898           __Pyx_INCREF(function);
14899           __Pyx_DECREF_SET(__pyx_t_14, function);
14900           __pyx_t_11 = 1;
14901         }
14902       }
14903       #if CYTHON_FAST_PYCALL
14904       if (PyFunction_Check(__pyx_t_14)) {
14905         PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_8genexpr4__pyx_v_value, Py_True};
14906         __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 730, __pyx_L5_error)
14907         __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
14908         __Pyx_GOTREF(__pyx_t_10);
14909       } else
14910       #endif
14911       #if CYTHON_FAST_PYCCALL
14912       if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
14913         PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_8genexpr4__pyx_v_value, Py_True};
14914         __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 730, __pyx_L5_error)
14915         __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
14916         __Pyx_GOTREF(__pyx_t_10);
14917       } else
14918       #endif
14919       {
14920         __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 730, __pyx_L5_error)
14921         __Pyx_GOTREF(__pyx_t_16);
14922         if (__pyx_t_15) {
14923           __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
14924         }
14925         __Pyx_INCREF(__pyx_8genexpr4__pyx_v_value);
14926         __Pyx_GIVEREF(__pyx_8genexpr4__pyx_v_value);
14927         PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_8genexpr4__pyx_v_value);
14928         __Pyx_INCREF(Py_True);
14929         __Pyx_GIVEREF(Py_True);
14930         PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, Py_True);
14931         __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_16, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 730, __pyx_L5_error)
14932         __Pyx_GOTREF(__pyx_t_10);
14933         __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
14934       }
14935       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
14936       __pyx_t_14 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_10), __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 730, __pyx_L5_error)
14937       __Pyx_GOTREF(__pyx_t_14);
14938       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14939       __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13;
14940       __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14);
14941       __Pyx_GIVEREF(__pyx_t_14);
14942       PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_14);
14943       __pyx_t_14 = 0;
14944       __Pyx_INCREF(__pyx_kp_u__19);
14945       __pyx_t_12 += 1;
14946       __Pyx_GIVEREF(__pyx_kp_u__19);
14947       PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u__19);
14948       __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_9, 5, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 730, __pyx_L5_error)
14949       __Pyx_GOTREF(__pyx_t_14);
14950       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
14951       if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 730, __pyx_L5_error)
14952       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
14953     }
14954     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14955     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_name); __pyx_8genexpr4__pyx_v_name = 0;
14956     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_value); __pyx_8genexpr4__pyx_v_value = 0;
14957     goto __pyx_L8_exit_scope;
14958     __pyx_L5_error:;
14959     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_name); __pyx_8genexpr4__pyx_v_name = 0;
14960     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_value); __pyx_8genexpr4__pyx_v_value = 0;
14961     goto __pyx_L1_error;
14962     __pyx_L8_exit_scope:;
14963   } /* exit inner scope */
14964   __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
14965   __Pyx_GOTREF(__pyx_t_4);
14966   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14967   __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
14968   __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
14969   __Pyx_GIVEREF(__pyx_t_4);
14970   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
14971   __pyx_t_4 = 0;
14972   __Pyx_INCREF(__pyx_kp_u__20);
14973   __pyx_t_2 += 1;
14974   __Pyx_GIVEREF(__pyx_kp_u__20);
14975   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__20);
14976
14977   /* "lxml/html/diff.py":729
14978  *     The text representation of the start tag for a tag.
14979  *     """
14980  *     return '<%s%s>' % (             # <<<<<<<<<<<<<<
14981  *         el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))
14982  *                          for name, value in el.attrib.items()]))
14983  */
14984   __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
14985   __Pyx_GOTREF(__pyx_t_4);
14986   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14987   __pyx_r = __pyx_t_4;
14988   __pyx_t_4 = 0;
14989   goto __pyx_L0;
14990
14991   /* "lxml/html/diff.py":725
14992  * start_whitespace_re = re.compile(r'^[ \t\n\r]')
14993  * 
14994  * def start_tag(el):             # <<<<<<<<<<<<<<
14995  *     """
14996  *     The text representation of the start tag for a tag.
14997  */
14998
14999   /* function exit code */
15000   __pyx_L1_error:;
15001   __Pyx_XDECREF(__pyx_t_1);
15002   __Pyx_XDECREF(__pyx_t_4);
15003   __Pyx_XDECREF(__pyx_t_5);
15004   __Pyx_XDECREF(__pyx_t_9);
15005   __Pyx_XDECREF(__pyx_t_10);
15006   __Pyx_XDECREF(__pyx_t_14);
15007   __Pyx_XDECREF(__pyx_t_15);
15008   __Pyx_XDECREF(__pyx_t_16);
15009   __Pyx_AddTraceback("lxml.html.diff.start_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
15010   __pyx_r = NULL;
15011   __pyx_L0:;
15012   __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_name);
15013   __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_value);
15014   __Pyx_XGIVEREF(__pyx_r);
15015   __Pyx_RefNannyFinishContext();
15016   return __pyx_r;
15017 }
15018
15019 /* "lxml/html/diff.py":733
15020  *                          for name, value in el.attrib.items()]))
15021  * 
15022  * def end_tag(el):             # <<<<<<<<<<<<<<
15023  *     """ The text representation of an end tag for a tag.  Includes
15024  *     trailing whitespace when appropriate.  """
15025  */
15026
15027 /* Python wrapper */
15028 static PyObject *__pyx_pw_4lxml_4html_4diff_56end_tag(PyObject *__pyx_self, PyObject *__pyx_v_el); /*proto*/
15029 static char __pyx_doc_4lxml_4html_4diff_55end_tag[] = " The text representation of an end tag for a tag.  Includes\n    trailing whitespace when appropriate.  ";
15030 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_56end_tag = {"end_tag", (PyCFunction)__pyx_pw_4lxml_4html_4diff_56end_tag, METH_O, __pyx_doc_4lxml_4html_4diff_55end_tag};
15031 static PyObject *__pyx_pw_4lxml_4html_4diff_56end_tag(PyObject *__pyx_self, PyObject *__pyx_v_el) {
15032   PyObject *__pyx_r = 0;
15033   __Pyx_RefNannyDeclarations
15034   __Pyx_RefNannySetupContext("end_tag (wrapper)", 0);
15035   __pyx_r = __pyx_pf_4lxml_4html_4diff_55end_tag(__pyx_self, ((PyObject *)__pyx_v_el));
15036
15037   /* function exit code */
15038   __Pyx_RefNannyFinishContext();
15039   return __pyx_r;
15040 }
15041
15042 static PyObject *__pyx_pf_4lxml_4html_4diff_55end_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el) {
15043   PyObject *__pyx_v_extra = NULL;
15044   PyObject *__pyx_r = NULL;
15045   __Pyx_RefNannyDeclarations
15046   int __pyx_t_1;
15047   PyObject *__pyx_t_2 = NULL;
15048   int __pyx_t_3;
15049   PyObject *__pyx_t_4 = NULL;
15050   PyObject *__pyx_t_5 = NULL;
15051   PyObject *__pyx_t_6 = NULL;
15052   Py_ssize_t __pyx_t_7;
15053   Py_UCS4 __pyx_t_8;
15054   int __pyx_lineno = 0;
15055   const char *__pyx_filename = NULL;
15056   int __pyx_clineno = 0;
15057   __Pyx_RefNannySetupContext("end_tag", 0);
15058
15059   /* "lxml/html/diff.py":736
15060  *     """ The text representation of an end tag for a tag.  Includes
15061  *     trailing whitespace when appropriate.  """
15062  *     if el.tail and start_whitespace_re.search(el.tail):             # <<<<<<<<<<<<<<
15063  *         extra = ' '
15064  *     else:
15065  */
15066   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L1_error)
15067   __Pyx_GOTREF(__pyx_t_2);
15068   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 736, __pyx_L1_error)
15069   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15070   if (__pyx_t_3) {
15071   } else {
15072     __pyx_t_1 = __pyx_t_3;
15073     goto __pyx_L4_bool_binop_done;
15074   }
15075   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_start_whitespace_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 736, __pyx_L1_error)
15076   __Pyx_GOTREF(__pyx_t_4);
15077   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_search); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 736, __pyx_L1_error)
15078   __Pyx_GOTREF(__pyx_t_5);
15079   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15080   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 736, __pyx_L1_error)
15081   __Pyx_GOTREF(__pyx_t_4);
15082   __pyx_t_6 = NULL;
15083   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
15084     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
15085     if (likely(__pyx_t_6)) {
15086       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
15087       __Pyx_INCREF(__pyx_t_6);
15088       __Pyx_INCREF(function);
15089       __Pyx_DECREF_SET(__pyx_t_5, function);
15090     }
15091   }
15092   __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
15093   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
15094   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15095   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L1_error)
15096   __Pyx_GOTREF(__pyx_t_2);
15097   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15098   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 736, __pyx_L1_error)
15099   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15100   __pyx_t_1 = __pyx_t_3;
15101   __pyx_L4_bool_binop_done:;
15102   if (__pyx_t_1) {
15103
15104     /* "lxml/html/diff.py":737
15105  *     trailing whitespace when appropriate.  """
15106  *     if el.tail and start_whitespace_re.search(el.tail):
15107  *         extra = ' '             # <<<<<<<<<<<<<<
15108  *     else:
15109  *         extra = ''
15110  */
15111     __Pyx_INCREF(__pyx_kp_u__6);
15112     __pyx_v_extra = __pyx_kp_u__6;
15113
15114     /* "lxml/html/diff.py":736
15115  *     """ The text representation of an end tag for a tag.  Includes
15116  *     trailing whitespace when appropriate.  """
15117  *     if el.tail and start_whitespace_re.search(el.tail):             # <<<<<<<<<<<<<<
15118  *         extra = ' '
15119  *     else:
15120  */
15121     goto __pyx_L3;
15122   }
15123
15124   /* "lxml/html/diff.py":739
15125  *         extra = ' '
15126  *     else:
15127  *         extra = ''             # <<<<<<<<<<<<<<
15128  *     return '</%s>%s' % (el.tag, extra)
15129  * 
15130  */
15131   /*else*/ {
15132     __Pyx_INCREF(__pyx_kp_u__2);
15133     __pyx_v_extra = __pyx_kp_u__2;
15134   }
15135   __pyx_L3:;
15136
15137   /* "lxml/html/diff.py":740
15138  *     else:
15139  *         extra = ''
15140  *     return '</%s>%s' % (el.tag, extra)             # <<<<<<<<<<<<<<
15141  * 
15142  * def is_word(tok):
15143  */
15144   __Pyx_XDECREF(__pyx_r);
15145   __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
15146   __Pyx_GOTREF(__pyx_t_2);
15147   __pyx_t_7 = 0;
15148   __pyx_t_8 = 127;
15149   __Pyx_INCREF(__pyx_kp_u__12);
15150   __pyx_t_7 += 2;
15151   __Pyx_GIVEREF(__pyx_kp_u__12);
15152   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u__12);
15153   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 740, __pyx_L1_error)
15154   __Pyx_GOTREF(__pyx_t_5);
15155   __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
15156   __Pyx_GOTREF(__pyx_t_4);
15157   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15158   __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_8;
15159   __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
15160   __Pyx_GIVEREF(__pyx_t_4);
15161   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
15162   __pyx_t_4 = 0;
15163   __Pyx_INCREF(__pyx_kp_u__20);
15164   __pyx_t_7 += 1;
15165   __Pyx_GIVEREF(__pyx_kp_u__20);
15166   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__20);
15167   __Pyx_INCREF(__pyx_v_extra);
15168   __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_extra) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_extra) : __pyx_t_8;
15169   __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_extra);
15170   __Pyx_GIVEREF(__pyx_v_extra);
15171   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_extra);
15172   __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_2, 4, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
15173   __Pyx_GOTREF(__pyx_t_4);
15174   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15175   __pyx_r = __pyx_t_4;
15176   __pyx_t_4 = 0;
15177   goto __pyx_L0;
15178
15179   /* "lxml/html/diff.py":733
15180  *                          for name, value in el.attrib.items()]))
15181  * 
15182  * def end_tag(el):             # <<<<<<<<<<<<<<
15183  *     """ The text representation of an end tag for a tag.  Includes
15184  *     trailing whitespace when appropriate.  """
15185  */
15186
15187   /* function exit code */
15188   __pyx_L1_error:;
15189   __Pyx_XDECREF(__pyx_t_2);
15190   __Pyx_XDECREF(__pyx_t_4);
15191   __Pyx_XDECREF(__pyx_t_5);
15192   __Pyx_XDECREF(__pyx_t_6);
15193   __Pyx_AddTraceback("lxml.html.diff.end_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
15194   __pyx_r = NULL;
15195   __pyx_L0:;
15196   __Pyx_XDECREF(__pyx_v_extra);
15197   __Pyx_XGIVEREF(__pyx_r);
15198   __Pyx_RefNannyFinishContext();
15199   return __pyx_r;
15200 }
15201
15202 /* "lxml/html/diff.py":742
15203  *     return '</%s>%s' % (el.tag, extra)
15204  * 
15205  * def is_word(tok):             # <<<<<<<<<<<<<<
15206  *     return not tok.startswith('<')
15207  * 
15208  */
15209
15210 /* Python wrapper */
15211 static PyObject *__pyx_pw_4lxml_4html_4diff_58is_word(PyObject *__pyx_self, PyObject *__pyx_v_tok); /*proto*/
15212 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_58is_word = {"is_word", (PyCFunction)__pyx_pw_4lxml_4html_4diff_58is_word, METH_O, 0};
15213 static PyObject *__pyx_pw_4lxml_4html_4diff_58is_word(PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15214   PyObject *__pyx_r = 0;
15215   __Pyx_RefNannyDeclarations
15216   __Pyx_RefNannySetupContext("is_word (wrapper)", 0);
15217   __pyx_r = __pyx_pf_4lxml_4html_4diff_57is_word(__pyx_self, ((PyObject *)__pyx_v_tok));
15218
15219   /* function exit code */
15220   __Pyx_RefNannyFinishContext();
15221   return __pyx_r;
15222 }
15223
15224 static PyObject *__pyx_pf_4lxml_4html_4diff_57is_word(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15225   PyObject *__pyx_r = NULL;
15226   __Pyx_RefNannyDeclarations
15227   PyObject *__pyx_t_1 = NULL;
15228   PyObject *__pyx_t_2 = NULL;
15229   PyObject *__pyx_t_3 = NULL;
15230   int __pyx_t_4;
15231   int __pyx_lineno = 0;
15232   const char *__pyx_filename = NULL;
15233   int __pyx_clineno = 0;
15234   __Pyx_RefNannySetupContext("is_word", 0);
15235
15236   /* "lxml/html/diff.py":743
15237  * 
15238  * def is_word(tok):
15239  *     return not tok.startswith('<')             # <<<<<<<<<<<<<<
15240  * 
15241  * def is_end_tag(tok):
15242  */
15243   __Pyx_XDECREF(__pyx_r);
15244   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_startswith); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
15245   __Pyx_GOTREF(__pyx_t_2);
15246   __pyx_t_3 = NULL;
15247   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
15248     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
15249     if (likely(__pyx_t_3)) {
15250       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
15251       __Pyx_INCREF(__pyx_t_3);
15252       __Pyx_INCREF(function);
15253       __Pyx_DECREF_SET(__pyx_t_2, function);
15254     }
15255   }
15256   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__8);
15257   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
15258   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
15259   __Pyx_GOTREF(__pyx_t_1);
15260   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15261   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 743, __pyx_L1_error)
15262   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15263   __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
15264   __Pyx_GOTREF(__pyx_t_1);
15265   __pyx_r = __pyx_t_1;
15266   __pyx_t_1 = 0;
15267   goto __pyx_L0;
15268
15269   /* "lxml/html/diff.py":742
15270  *     return '</%s>%s' % (el.tag, extra)
15271  * 
15272  * def is_word(tok):             # <<<<<<<<<<<<<<
15273  *     return not tok.startswith('<')
15274  * 
15275  */
15276
15277   /* function exit code */
15278   __pyx_L1_error:;
15279   __Pyx_XDECREF(__pyx_t_1);
15280   __Pyx_XDECREF(__pyx_t_2);
15281   __Pyx_XDECREF(__pyx_t_3);
15282   __Pyx_AddTraceback("lxml.html.diff.is_word", __pyx_clineno, __pyx_lineno, __pyx_filename);
15283   __pyx_r = NULL;
15284   __pyx_L0:;
15285   __Pyx_XGIVEREF(__pyx_r);
15286   __Pyx_RefNannyFinishContext();
15287   return __pyx_r;
15288 }
15289
15290 /* "lxml/html/diff.py":745
15291  *     return not tok.startswith('<')
15292  * 
15293  * def is_end_tag(tok):             # <<<<<<<<<<<<<<
15294  *     return tok.startswith('</')
15295  * 
15296  */
15297
15298 /* Python wrapper */
15299 static PyObject *__pyx_pw_4lxml_4html_4diff_60is_end_tag(PyObject *__pyx_self, PyObject *__pyx_v_tok); /*proto*/
15300 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_60is_end_tag = {"is_end_tag", (PyCFunction)__pyx_pw_4lxml_4html_4diff_60is_end_tag, METH_O, 0};
15301 static PyObject *__pyx_pw_4lxml_4html_4diff_60is_end_tag(PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15302   PyObject *__pyx_r = 0;
15303   __Pyx_RefNannyDeclarations
15304   __Pyx_RefNannySetupContext("is_end_tag (wrapper)", 0);
15305   __pyx_r = __pyx_pf_4lxml_4html_4diff_59is_end_tag(__pyx_self, ((PyObject *)__pyx_v_tok));
15306
15307   /* function exit code */
15308   __Pyx_RefNannyFinishContext();
15309   return __pyx_r;
15310 }
15311
15312 static PyObject *__pyx_pf_4lxml_4html_4diff_59is_end_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15313   PyObject *__pyx_r = NULL;
15314   __Pyx_RefNannyDeclarations
15315   PyObject *__pyx_t_1 = NULL;
15316   PyObject *__pyx_t_2 = NULL;
15317   PyObject *__pyx_t_3 = NULL;
15318   int __pyx_lineno = 0;
15319   const char *__pyx_filename = NULL;
15320   int __pyx_clineno = 0;
15321   __Pyx_RefNannySetupContext("is_end_tag", 0);
15322
15323   /* "lxml/html/diff.py":746
15324  * 
15325  * def is_end_tag(tok):
15326  *     return tok.startswith('</')             # <<<<<<<<<<<<<<
15327  * 
15328  * def is_start_tag(tok):
15329  */
15330   __Pyx_XDECREF(__pyx_r);
15331   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_startswith); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
15332   __Pyx_GOTREF(__pyx_t_2);
15333   __pyx_t_3 = NULL;
15334   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
15335     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
15336     if (likely(__pyx_t_3)) {
15337       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
15338       __Pyx_INCREF(__pyx_t_3);
15339       __Pyx_INCREF(function);
15340       __Pyx_DECREF_SET(__pyx_t_2, function);
15341     }
15342   }
15343   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u__12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__12);
15344   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
15345   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
15346   __Pyx_GOTREF(__pyx_t_1);
15347   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15348   __pyx_r = __pyx_t_1;
15349   __pyx_t_1 = 0;
15350   goto __pyx_L0;
15351
15352   /* "lxml/html/diff.py":745
15353  *     return not tok.startswith('<')
15354  * 
15355  * def is_end_tag(tok):             # <<<<<<<<<<<<<<
15356  *     return tok.startswith('</')
15357  * 
15358  */
15359
15360   /* function exit code */
15361   __pyx_L1_error:;
15362   __Pyx_XDECREF(__pyx_t_1);
15363   __Pyx_XDECREF(__pyx_t_2);
15364   __Pyx_XDECREF(__pyx_t_3);
15365   __Pyx_AddTraceback("lxml.html.diff.is_end_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
15366   __pyx_r = NULL;
15367   __pyx_L0:;
15368   __Pyx_XGIVEREF(__pyx_r);
15369   __Pyx_RefNannyFinishContext();
15370   return __pyx_r;
15371 }
15372
15373 /* "lxml/html/diff.py":748
15374  *     return tok.startswith('</')
15375  * 
15376  * def is_start_tag(tok):             # <<<<<<<<<<<<<<
15377  *     return tok.startswith('<') and not tok.startswith('</')
15378  * 
15379  */
15380
15381 /* Python wrapper */
15382 static PyObject *__pyx_pw_4lxml_4html_4diff_62is_start_tag(PyObject *__pyx_self, PyObject *__pyx_v_tok); /*proto*/
15383 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_62is_start_tag = {"is_start_tag", (PyCFunction)__pyx_pw_4lxml_4html_4diff_62is_start_tag, METH_O, 0};
15384 static PyObject *__pyx_pw_4lxml_4html_4diff_62is_start_tag(PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15385   PyObject *__pyx_r = 0;
15386   __Pyx_RefNannyDeclarations
15387   __Pyx_RefNannySetupContext("is_start_tag (wrapper)", 0);
15388   __pyx_r = __pyx_pf_4lxml_4html_4diff_61is_start_tag(__pyx_self, ((PyObject *)__pyx_v_tok));
15389
15390   /* function exit code */
15391   __Pyx_RefNannyFinishContext();
15392   return __pyx_r;
15393 }
15394
15395 static PyObject *__pyx_pf_4lxml_4html_4diff_61is_start_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tok) {
15396   PyObject *__pyx_r = NULL;
15397   __Pyx_RefNannyDeclarations
15398   PyObject *__pyx_t_1 = NULL;
15399   PyObject *__pyx_t_2 = NULL;
15400   PyObject *__pyx_t_3 = NULL;
15401   PyObject *__pyx_t_4 = NULL;
15402   int __pyx_t_5;
15403   int __pyx_t_6;
15404   int __pyx_lineno = 0;
15405   const char *__pyx_filename = NULL;
15406   int __pyx_clineno = 0;
15407   __Pyx_RefNannySetupContext("is_start_tag", 0);
15408
15409   /* "lxml/html/diff.py":749
15410  * 
15411  * def is_start_tag(tok):
15412  *     return tok.startswith('<') and not tok.startswith('</')             # <<<<<<<<<<<<<<
15413  * 
15414  * def fixup_ins_del_tags(html):
15415  */
15416   __Pyx_XDECREF(__pyx_r);
15417   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_startswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
15418   __Pyx_GOTREF(__pyx_t_3);
15419   __pyx_t_4 = NULL;
15420   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
15421     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
15422     if (likely(__pyx_t_4)) {
15423       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
15424       __Pyx_INCREF(__pyx_t_4);
15425       __Pyx_INCREF(function);
15426       __Pyx_DECREF_SET(__pyx_t_3, function);
15427     }
15428   }
15429   __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u__8);
15430   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
15431   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
15432   __Pyx_GOTREF(__pyx_t_2);
15433   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15434   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 749, __pyx_L1_error)
15435   if (__pyx_t_5) {
15436     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15437   } else {
15438     __Pyx_INCREF(__pyx_t_2);
15439     __pyx_t_1 = __pyx_t_2;
15440     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15441     goto __pyx_L3_bool_binop_done;
15442   }
15443   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_tok, __pyx_n_s_startswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
15444   __Pyx_GOTREF(__pyx_t_3);
15445   __pyx_t_4 = NULL;
15446   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
15447     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
15448     if (likely(__pyx_t_4)) {
15449       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
15450       __Pyx_INCREF(__pyx_t_4);
15451       __Pyx_INCREF(function);
15452       __Pyx_DECREF_SET(__pyx_t_3, function);
15453     }
15454   }
15455   __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u__12) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u__12);
15456   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
15457   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
15458   __Pyx_GOTREF(__pyx_t_2);
15459   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15460   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 749, __pyx_L1_error)
15461   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15462   __pyx_t_6 = (!__pyx_t_5);
15463   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
15464   __Pyx_GOTREF(__pyx_t_2);
15465   __pyx_t_1 = __pyx_t_2;
15466   __pyx_t_2 = 0;
15467   __pyx_L3_bool_binop_done:;
15468   __pyx_r = __pyx_t_1;
15469   __pyx_t_1 = 0;
15470   goto __pyx_L0;
15471
15472   /* "lxml/html/diff.py":748
15473  *     return tok.startswith('</')
15474  * 
15475  * def is_start_tag(tok):             # <<<<<<<<<<<<<<
15476  *     return tok.startswith('<') and not tok.startswith('</')
15477  * 
15478  */
15479
15480   /* function exit code */
15481   __pyx_L1_error:;
15482   __Pyx_XDECREF(__pyx_t_1);
15483   __Pyx_XDECREF(__pyx_t_2);
15484   __Pyx_XDECREF(__pyx_t_3);
15485   __Pyx_XDECREF(__pyx_t_4);
15486   __Pyx_AddTraceback("lxml.html.diff.is_start_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
15487   __pyx_r = NULL;
15488   __pyx_L0:;
15489   __Pyx_XGIVEREF(__pyx_r);
15490   __Pyx_RefNannyFinishContext();
15491   return __pyx_r;
15492 }
15493
15494 /* "lxml/html/diff.py":751
15495  *     return tok.startswith('<') and not tok.startswith('</')
15496  * 
15497  * def fixup_ins_del_tags(html):             # <<<<<<<<<<<<<<
15498  *     """ Given an html string, move any <ins> or <del> tags inside of any
15499  *     block-level elements, e.g. transform <ins><p>word</p></ins> to
15500  */
15501
15502 /* Python wrapper */
15503 static PyObject *__pyx_pw_4lxml_4html_4diff_64fixup_ins_del_tags(PyObject *__pyx_self, PyObject *__pyx_v_html); /*proto*/
15504 static char __pyx_doc_4lxml_4html_4diff_63fixup_ins_del_tags[] = " Given an html string, move any <ins> or <del> tags inside of any\n    block-level elements, e.g. transform <ins><p>word</p></ins> to\n    <p><ins>word</ins></p> ";
15505 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_64fixup_ins_del_tags = {"fixup_ins_del_tags", (PyCFunction)__pyx_pw_4lxml_4html_4diff_64fixup_ins_del_tags, METH_O, __pyx_doc_4lxml_4html_4diff_63fixup_ins_del_tags};
15506 static PyObject *__pyx_pw_4lxml_4html_4diff_64fixup_ins_del_tags(PyObject *__pyx_self, PyObject *__pyx_v_html) {
15507   PyObject *__pyx_r = 0;
15508   __Pyx_RefNannyDeclarations
15509   __Pyx_RefNannySetupContext("fixup_ins_del_tags (wrapper)", 0);
15510   __pyx_r = __pyx_pf_4lxml_4html_4diff_63fixup_ins_del_tags(__pyx_self, ((PyObject *)__pyx_v_html));
15511
15512   /* function exit code */
15513   __Pyx_RefNannyFinishContext();
15514   return __pyx_r;
15515 }
15516
15517 static PyObject *__pyx_pf_4lxml_4html_4diff_63fixup_ins_del_tags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_html) {
15518   PyObject *__pyx_v_doc = NULL;
15519   PyObject *__pyx_r = NULL;
15520   __Pyx_RefNannyDeclarations
15521   PyObject *__pyx_t_1 = NULL;
15522   PyObject *__pyx_t_2 = NULL;
15523   PyObject *__pyx_t_3 = NULL;
15524   PyObject *__pyx_t_4 = NULL;
15525   int __pyx_lineno = 0;
15526   const char *__pyx_filename = NULL;
15527   int __pyx_clineno = 0;
15528   __Pyx_RefNannySetupContext("fixup_ins_del_tags", 0);
15529   __Pyx_INCREF(__pyx_v_html);
15530
15531   /* "lxml/html/diff.py":755
15532  *     block-level elements, e.g. transform <ins><p>word</p></ins> to
15533  *     <p><ins>word</ins></p> """
15534  *     doc = parse_html(html, cleanup=False)             # <<<<<<<<<<<<<<
15535  *     _fixup_ins_del_tags(doc)
15536  *     html = serialize_html_fragment(doc, skip_outer=True)
15537  */
15538   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_parse_html); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
15539   __Pyx_GOTREF(__pyx_t_1);
15540   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
15541   __Pyx_GOTREF(__pyx_t_2);
15542   __Pyx_INCREF(__pyx_v_html);
15543   __Pyx_GIVEREF(__pyx_v_html);
15544   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_html);
15545   __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error)
15546   __Pyx_GOTREF(__pyx_t_3);
15547   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_cleanup, Py_False) < 0) __PYX_ERR(0, 755, __pyx_L1_error)
15548   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 755, __pyx_L1_error)
15549   __Pyx_GOTREF(__pyx_t_4);
15550   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15551   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15552   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15553   __pyx_v_doc = __pyx_t_4;
15554   __pyx_t_4 = 0;
15555
15556   /* "lxml/html/diff.py":756
15557  *     <p><ins>word</ins></p> """
15558  *     doc = parse_html(html, cleanup=False)
15559  *     _fixup_ins_del_tags(doc)             # <<<<<<<<<<<<<<
15560  *     html = serialize_html_fragment(doc, skip_outer=True)
15561  *     return html
15562  */
15563   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_fixup_ins_del_tags_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error)
15564   __Pyx_GOTREF(__pyx_t_3);
15565   __pyx_t_2 = NULL;
15566   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
15567     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
15568     if (likely(__pyx_t_2)) {
15569       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
15570       __Pyx_INCREF(__pyx_t_2);
15571       __Pyx_INCREF(function);
15572       __Pyx_DECREF_SET(__pyx_t_3, function);
15573     }
15574   }
15575   __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_doc) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_doc);
15576   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
15577   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 756, __pyx_L1_error)
15578   __Pyx_GOTREF(__pyx_t_4);
15579   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15580   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15581
15582   /* "lxml/html/diff.py":757
15583  *     doc = parse_html(html, cleanup=False)
15584  *     _fixup_ins_del_tags(doc)
15585  *     html = serialize_html_fragment(doc, skip_outer=True)             # <<<<<<<<<<<<<<
15586  *     return html
15587  * 
15588  */
15589   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_serialize_html_fragment); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 757, __pyx_L1_error)
15590   __Pyx_GOTREF(__pyx_t_4);
15591   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
15592   __Pyx_GOTREF(__pyx_t_3);
15593   __Pyx_INCREF(__pyx_v_doc);
15594   __Pyx_GIVEREF(__pyx_v_doc);
15595   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_doc);
15596   __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error)
15597   __Pyx_GOTREF(__pyx_t_2);
15598   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_skip_outer, Py_True) < 0) __PYX_ERR(0, 757, __pyx_L1_error)
15599   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
15600   __Pyx_GOTREF(__pyx_t_1);
15601   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15602   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15603   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15604   __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_1);
15605   __pyx_t_1 = 0;
15606
15607   /* "lxml/html/diff.py":758
15608  *     _fixup_ins_del_tags(doc)
15609  *     html = serialize_html_fragment(doc, skip_outer=True)
15610  *     return html             # <<<<<<<<<<<<<<
15611  * 
15612  * def serialize_html_fragment(el, skip_outer=False):
15613  */
15614   __Pyx_XDECREF(__pyx_r);
15615   __Pyx_INCREF(__pyx_v_html);
15616   __pyx_r = __pyx_v_html;
15617   goto __pyx_L0;
15618
15619   /* "lxml/html/diff.py":751
15620  *     return tok.startswith('<') and not tok.startswith('</')
15621  * 
15622  * def fixup_ins_del_tags(html):             # <<<<<<<<<<<<<<
15623  *     """ Given an html string, move any <ins> or <del> tags inside of any
15624  *     block-level elements, e.g. transform <ins><p>word</p></ins> to
15625  */
15626
15627   /* function exit code */
15628   __pyx_L1_error:;
15629   __Pyx_XDECREF(__pyx_t_1);
15630   __Pyx_XDECREF(__pyx_t_2);
15631   __Pyx_XDECREF(__pyx_t_3);
15632   __Pyx_XDECREF(__pyx_t_4);
15633   __Pyx_AddTraceback("lxml.html.diff.fixup_ins_del_tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
15634   __pyx_r = NULL;
15635   __pyx_L0:;
15636   __Pyx_XDECREF(__pyx_v_doc);
15637   __Pyx_XDECREF(__pyx_v_html);
15638   __Pyx_XGIVEREF(__pyx_r);
15639   __Pyx_RefNannyFinishContext();
15640   return __pyx_r;
15641 }
15642
15643 /* "lxml/html/diff.py":760
15644  *     return html
15645  * 
15646  * def serialize_html_fragment(el, skip_outer=False):             # <<<<<<<<<<<<<<
15647  *     """ Serialize a single lxml element as HTML.  The serialized form
15648  *     includes the elements tail.
15649  */
15650
15651 /* Python wrapper */
15652 static PyObject *__pyx_pw_4lxml_4html_4diff_66serialize_html_fragment(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
15653 static char __pyx_doc_4lxml_4html_4diff_65serialize_html_fragment[] = " Serialize a single lxml element as HTML.  The serialized form\n    includes the elements tail.  \n\n    If skip_outer is true, then don't serialize the outermost tag\n    ";
15654 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_66serialize_html_fragment = {"serialize_html_fragment", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_66serialize_html_fragment, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_65serialize_html_fragment};
15655 static PyObject *__pyx_pw_4lxml_4html_4diff_66serialize_html_fragment(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
15656   PyObject *__pyx_v_el = 0;
15657   PyObject *__pyx_v_skip_outer = 0;
15658   int __pyx_lineno = 0;
15659   const char *__pyx_filename = NULL;
15660   int __pyx_clineno = 0;
15661   PyObject *__pyx_r = 0;
15662   __Pyx_RefNannyDeclarations
15663   __Pyx_RefNannySetupContext("serialize_html_fragment (wrapper)", 0);
15664   {
15665     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_el,&__pyx_n_s_skip_outer,0};
15666     PyObject* values[2] = {0,0};
15667     values[1] = ((PyObject *)((PyObject *)Py_False));
15668     if (unlikely(__pyx_kwds)) {
15669       Py_ssize_t kw_args;
15670       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
15671       switch (pos_args) {
15672         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
15673         CYTHON_FALLTHROUGH;
15674         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15675         CYTHON_FALLTHROUGH;
15676         case  0: break;
15677         default: goto __pyx_L5_argtuple_error;
15678       }
15679       kw_args = PyDict_Size(__pyx_kwds);
15680       switch (pos_args) {
15681         case  0:
15682         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_el)) != 0)) kw_args--;
15683         else goto __pyx_L5_argtuple_error;
15684         CYTHON_FALLTHROUGH;
15685         case  1:
15686         if (kw_args > 0) {
15687           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_skip_outer);
15688           if (value) { values[1] = value; kw_args--; }
15689         }
15690       }
15691       if (unlikely(kw_args > 0)) {
15692         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "serialize_html_fragment") < 0)) __PYX_ERR(0, 760, __pyx_L3_error)
15693       }
15694     } else {
15695       switch (PyTuple_GET_SIZE(__pyx_args)) {
15696         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
15697         CYTHON_FALLTHROUGH;
15698         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15699         break;
15700         default: goto __pyx_L5_argtuple_error;
15701       }
15702     }
15703     __pyx_v_el = values[0];
15704     __pyx_v_skip_outer = values[1];
15705   }
15706   goto __pyx_L4_argument_unpacking_done;
15707   __pyx_L5_argtuple_error:;
15708   __Pyx_RaiseArgtupleInvalid("serialize_html_fragment", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 760, __pyx_L3_error)
15709   __pyx_L3_error:;
15710   __Pyx_AddTraceback("lxml.html.diff.serialize_html_fragment", __pyx_clineno, __pyx_lineno, __pyx_filename);
15711   __Pyx_RefNannyFinishContext();
15712   return NULL;
15713   __pyx_L4_argument_unpacking_done:;
15714   __pyx_r = __pyx_pf_4lxml_4html_4diff_65serialize_html_fragment(__pyx_self, __pyx_v_el, __pyx_v_skip_outer);
15715
15716   /* function exit code */
15717   __Pyx_RefNannyFinishContext();
15718   return __pyx_r;
15719 }
15720
15721 static PyObject *__pyx_pf_4lxml_4html_4diff_65serialize_html_fragment(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_skip_outer) {
15722   PyObject *__pyx_v_html = NULL;
15723   PyObject *__pyx_r = NULL;
15724   __Pyx_RefNannyDeclarations
15725   PyObject *__pyx_t_1 = NULL;
15726   int __pyx_t_2;
15727   PyObject *__pyx_t_3 = NULL;
15728   PyObject *__pyx_t_4 = NULL;
15729   PyObject *__pyx_t_5 = NULL;
15730   int __pyx_lineno = 0;
15731   const char *__pyx_filename = NULL;
15732   int __pyx_clineno = 0;
15733   __Pyx_RefNannySetupContext("serialize_html_fragment", 0);
15734
15735   /* "lxml/html/diff.py":766
15736  *     If skip_outer is true, then don't serialize the outermost tag
15737  *     """
15738  *     assert not isinstance(el, basestring), (             # <<<<<<<<<<<<<<
15739  *         "You should pass in an element, not a string like %r" % el)
15740  *     html = etree.tostring(el, method="html", encoding=_unicode)
15741  */
15742   #ifndef CYTHON_WITHOUT_ASSERTIONS
15743   if (unlikely(!Py_OptimizeFlag)) {
15744     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_basestring); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
15745     __Pyx_GOTREF(__pyx_t_1);
15746     __pyx_t_2 = PyObject_IsInstance(__pyx_v_el, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 766, __pyx_L1_error)
15747     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15748     if (unlikely(!((!(__pyx_t_2 != 0)) != 0))) {
15749
15750       /* "lxml/html/diff.py":767
15751  *     """
15752  *     assert not isinstance(el, basestring), (
15753  *         "You should pass in an element, not a string like %r" % el)             # <<<<<<<<<<<<<<
15754  *     html = etree.tostring(el, method="html", encoding=_unicode)
15755  *     if skip_outer:
15756  */
15757       __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_You_should_pass_in_an_element_no, __pyx_v_el); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
15758       __Pyx_GOTREF(__pyx_t_1);
15759       PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
15760       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15761       __PYX_ERR(0, 766, __pyx_L1_error)
15762     }
15763   }
15764   #endif
15765
15766   /* "lxml/html/diff.py":768
15767  *     assert not isinstance(el, basestring), (
15768  *         "You should pass in an element, not a string like %r" % el)
15769  *     html = etree.tostring(el, method="html", encoding=_unicode)             # <<<<<<<<<<<<<<
15770  *     if skip_outer:
15771  *         # Get rid of the extra starting tag:
15772  */
15773   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_etree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
15774   __Pyx_GOTREF(__pyx_t_1);
15775   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tostring); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error)
15776   __Pyx_GOTREF(__pyx_t_3);
15777   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15778   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
15779   __Pyx_GOTREF(__pyx_t_1);
15780   __Pyx_INCREF(__pyx_v_el);
15781   __Pyx_GIVEREF(__pyx_v_el);
15782   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_el);
15783   __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 768, __pyx_L1_error)
15784   __Pyx_GOTREF(__pyx_t_4);
15785   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_method, __pyx_n_u_html) < 0) __PYX_ERR(0, 768, __pyx_L1_error)
15786   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 768, __pyx_L1_error)
15787   __Pyx_GOTREF(__pyx_t_5);
15788   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_encoding, __pyx_t_5) < 0) __PYX_ERR(0, 768, __pyx_L1_error)
15789   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15790   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 768, __pyx_L1_error)
15791   __Pyx_GOTREF(__pyx_t_5);
15792   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15793   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15794   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15795   __pyx_v_html = __pyx_t_5;
15796   __pyx_t_5 = 0;
15797
15798   /* "lxml/html/diff.py":769
15799  *         "You should pass in an element, not a string like %r" % el)
15800  *     html = etree.tostring(el, method="html", encoding=_unicode)
15801  *     if skip_outer:             # <<<<<<<<<<<<<<
15802  *         # Get rid of the extra starting tag:
15803  *         html = html[html.find('>')+1:]
15804  */
15805   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_skip_outer); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 769, __pyx_L1_error)
15806   if (__pyx_t_2) {
15807
15808     /* "lxml/html/diff.py":771
15809  *     if skip_outer:
15810  *         # Get rid of the extra starting tag:
15811  *         html = html[html.find('>')+1:]             # <<<<<<<<<<<<<<
15812  *         # Get rid of the extra end tag:
15813  *         html = html[:html.rfind('<')]
15814  */
15815     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_html, __pyx_n_s_find); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L1_error)
15816     __Pyx_GOTREF(__pyx_t_4);
15817     __pyx_t_1 = NULL;
15818     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
15819       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
15820       if (likely(__pyx_t_1)) {
15821         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
15822         __Pyx_INCREF(__pyx_t_1);
15823         __Pyx_INCREF(function);
15824         __Pyx_DECREF_SET(__pyx_t_4, function);
15825       }
15826     }
15827     __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_kp_u__20) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__20);
15828     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15829     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 771, __pyx_L1_error)
15830     __Pyx_GOTREF(__pyx_t_5);
15831     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15832     __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L1_error)
15833     __Pyx_GOTREF(__pyx_t_4);
15834     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15835     __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_html, 0, 0, &__pyx_t_4, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 771, __pyx_L1_error)
15836     __Pyx_GOTREF(__pyx_t_5);
15837     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15838     __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_5);
15839     __pyx_t_5 = 0;
15840
15841     /* "lxml/html/diff.py":773
15842  *         html = html[html.find('>')+1:]
15843  *         # Get rid of the extra end tag:
15844  *         html = html[:html.rfind('<')]             # <<<<<<<<<<<<<<
15845  *         return html.strip()
15846  *     else:
15847  */
15848     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_html, __pyx_n_s_rfind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 773, __pyx_L1_error)
15849     __Pyx_GOTREF(__pyx_t_4);
15850     __pyx_t_1 = NULL;
15851     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
15852       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
15853       if (likely(__pyx_t_1)) {
15854         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
15855         __Pyx_INCREF(__pyx_t_1);
15856         __Pyx_INCREF(function);
15857         __Pyx_DECREF_SET(__pyx_t_4, function);
15858       }
15859     }
15860     __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__8);
15861     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15862     if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 773, __pyx_L1_error)
15863     __Pyx_GOTREF(__pyx_t_5);
15864     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15865     __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_html, 0, 0, NULL, &__pyx_t_5, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 773, __pyx_L1_error)
15866     __Pyx_GOTREF(__pyx_t_4);
15867     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15868     __Pyx_DECREF_SET(__pyx_v_html, __pyx_t_4);
15869     __pyx_t_4 = 0;
15870
15871     /* "lxml/html/diff.py":774
15872  *         # Get rid of the extra end tag:
15873  *         html = html[:html.rfind('<')]
15874  *         return html.strip()             # <<<<<<<<<<<<<<
15875  *     else:
15876  *         return html
15877  */
15878     __Pyx_XDECREF(__pyx_r);
15879     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_html, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 774, __pyx_L1_error)
15880     __Pyx_GOTREF(__pyx_t_5);
15881     __pyx_t_1 = NULL;
15882     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
15883       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
15884       if (likely(__pyx_t_1)) {
15885         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
15886         __Pyx_INCREF(__pyx_t_1);
15887         __Pyx_INCREF(function);
15888         __Pyx_DECREF_SET(__pyx_t_5, function);
15889       }
15890     }
15891     __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
15892     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15893     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 774, __pyx_L1_error)
15894     __Pyx_GOTREF(__pyx_t_4);
15895     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15896     __pyx_r = __pyx_t_4;
15897     __pyx_t_4 = 0;
15898     goto __pyx_L0;
15899
15900     /* "lxml/html/diff.py":769
15901  *         "You should pass in an element, not a string like %r" % el)
15902  *     html = etree.tostring(el, method="html", encoding=_unicode)
15903  *     if skip_outer:             # <<<<<<<<<<<<<<
15904  *         # Get rid of the extra starting tag:
15905  *         html = html[html.find('>')+1:]
15906  */
15907   }
15908
15909   /* "lxml/html/diff.py":776
15910  *         return html.strip()
15911  *     else:
15912  *         return html             # <<<<<<<<<<<<<<
15913  * 
15914  * def _fixup_ins_del_tags(doc):
15915  */
15916   /*else*/ {
15917     __Pyx_XDECREF(__pyx_r);
15918     __Pyx_INCREF(__pyx_v_html);
15919     __pyx_r = __pyx_v_html;
15920     goto __pyx_L0;
15921   }
15922
15923   /* "lxml/html/diff.py":760
15924  *     return html
15925  * 
15926  * def serialize_html_fragment(el, skip_outer=False):             # <<<<<<<<<<<<<<
15927  *     """ Serialize a single lxml element as HTML.  The serialized form
15928  *     includes the elements tail.
15929  */
15930
15931   /* function exit code */
15932   __pyx_L1_error:;
15933   __Pyx_XDECREF(__pyx_t_1);
15934   __Pyx_XDECREF(__pyx_t_3);
15935   __Pyx_XDECREF(__pyx_t_4);
15936   __Pyx_XDECREF(__pyx_t_5);
15937   __Pyx_AddTraceback("lxml.html.diff.serialize_html_fragment", __pyx_clineno, __pyx_lineno, __pyx_filename);
15938   __pyx_r = NULL;
15939   __pyx_L0:;
15940   __Pyx_XDECREF(__pyx_v_html);
15941   __Pyx_XGIVEREF(__pyx_r);
15942   __Pyx_RefNannyFinishContext();
15943   return __pyx_r;
15944 }
15945
15946 /* "lxml/html/diff.py":778
15947  *         return html
15948  * 
15949  * def _fixup_ins_del_tags(doc):             # <<<<<<<<<<<<<<
15950  *     """fixup_ins_del_tags that works on an lxml document in-place
15951  *     """
15952  */
15953
15954 /* Python wrapper */
15955 static PyObject *__pyx_pw_4lxml_4html_4diff_68_fixup_ins_del_tags(PyObject *__pyx_self, PyObject *__pyx_v_doc); /*proto*/
15956 static char __pyx_doc_4lxml_4html_4diff_67_fixup_ins_del_tags[] = "fixup_ins_del_tags that works on an lxml document in-place\n    ";
15957 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_68_fixup_ins_del_tags = {"_fixup_ins_del_tags", (PyCFunction)__pyx_pw_4lxml_4html_4diff_68_fixup_ins_del_tags, METH_O, __pyx_doc_4lxml_4html_4diff_67_fixup_ins_del_tags};
15958 static PyObject *__pyx_pw_4lxml_4html_4diff_68_fixup_ins_del_tags(PyObject *__pyx_self, PyObject *__pyx_v_doc) {
15959   PyObject *__pyx_r = 0;
15960   __Pyx_RefNannyDeclarations
15961   __Pyx_RefNannySetupContext("_fixup_ins_del_tags (wrapper)", 0);
15962   __pyx_r = __pyx_pf_4lxml_4html_4diff_67_fixup_ins_del_tags(__pyx_self, ((PyObject *)__pyx_v_doc));
15963
15964   /* function exit code */
15965   __Pyx_RefNannyFinishContext();
15966   return __pyx_r;
15967 }
15968
15969 static PyObject *__pyx_pf_4lxml_4html_4diff_67_fixup_ins_del_tags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doc) {
15970   PyObject *__pyx_v_tag = NULL;
15971   PyObject *__pyx_v_el = NULL;
15972   PyObject *__pyx_r = NULL;
15973   __Pyx_RefNannyDeclarations
15974   PyObject *__pyx_t_1 = NULL;
15975   Py_ssize_t __pyx_t_2;
15976   PyObject *__pyx_t_3 = NULL;
15977   PyObject *__pyx_t_4 = NULL;
15978   PyObject *__pyx_t_5 = NULL;
15979   PyObject *__pyx_t_6 = NULL;
15980   Py_ssize_t __pyx_t_7;
15981   PyObject *(*__pyx_t_8)(PyObject *);
15982   int __pyx_t_9;
15983   int __pyx_t_10;
15984   PyObject *__pyx_t_11 = NULL;
15985   int __pyx_lineno = 0;
15986   const char *__pyx_filename = NULL;
15987   int __pyx_clineno = 0;
15988   __Pyx_RefNannySetupContext("_fixup_ins_del_tags", 0);
15989
15990   /* "lxml/html/diff.py":781
15991  *     """fixup_ins_del_tags that works on an lxml document in-place
15992  *     """
15993  *     for tag in ['ins', 'del']:             # <<<<<<<<<<<<<<
15994  *         for el in doc.xpath('descendant-or-self::%s' % tag):
15995  *             if not _contains_block_level_tag(el):
15996  */
15997   __pyx_t_1 = __pyx_tuple__21; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
15998   for (;;) {
15999     if (__pyx_t_2 >= 2) break;
16000     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16001     __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 781, __pyx_L1_error)
16002     #else
16003     __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L1_error)
16004     __Pyx_GOTREF(__pyx_t_3);
16005     #endif
16006     __Pyx_XDECREF_SET(__pyx_v_tag, ((PyObject*)__pyx_t_3));
16007     __pyx_t_3 = 0;
16008
16009     /* "lxml/html/diff.py":782
16010  *     """
16011  *     for tag in ['ins', 'del']:
16012  *         for el in doc.xpath('descendant-or-self::%s' % tag):             # <<<<<<<<<<<<<<
16013  *             if not _contains_block_level_tag(el):
16014  *                 continue
16015  */
16016     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_doc, __pyx_n_s_xpath); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 782, __pyx_L1_error)
16017     __Pyx_GOTREF(__pyx_t_4);
16018     __pyx_t_5 = PyUnicode_Format(__pyx_kp_u_descendant_or_self_s, __pyx_v_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 782, __pyx_L1_error)
16019     __Pyx_GOTREF(__pyx_t_5);
16020     __pyx_t_6 = NULL;
16021     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
16022       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
16023       if (likely(__pyx_t_6)) {
16024         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
16025         __Pyx_INCREF(__pyx_t_6);
16026         __Pyx_INCREF(function);
16027         __Pyx_DECREF_SET(__pyx_t_4, function);
16028       }
16029     }
16030     __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
16031     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
16032     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16033     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
16034     __Pyx_GOTREF(__pyx_t_3);
16035     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16036     if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
16037       __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
16038       __pyx_t_8 = NULL;
16039     } else {
16040       __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 782, __pyx_L1_error)
16041       __Pyx_GOTREF(__pyx_t_4);
16042       __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 782, __pyx_L1_error)
16043     }
16044     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16045     for (;;) {
16046       if (likely(!__pyx_t_8)) {
16047         if (likely(PyList_CheckExact(__pyx_t_4))) {
16048           if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
16049           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16050           __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 782, __pyx_L1_error)
16051           #else
16052           __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
16053           __Pyx_GOTREF(__pyx_t_3);
16054           #endif
16055         } else {
16056           if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
16057           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16058           __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 782, __pyx_L1_error)
16059           #else
16060           __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
16061           __Pyx_GOTREF(__pyx_t_3);
16062           #endif
16063         }
16064       } else {
16065         __pyx_t_3 = __pyx_t_8(__pyx_t_4);
16066         if (unlikely(!__pyx_t_3)) {
16067           PyObject* exc_type = PyErr_Occurred();
16068           if (exc_type) {
16069             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
16070             else __PYX_ERR(0, 782, __pyx_L1_error)
16071           }
16072           break;
16073         }
16074         __Pyx_GOTREF(__pyx_t_3);
16075       }
16076       __Pyx_XDECREF_SET(__pyx_v_el, __pyx_t_3);
16077       __pyx_t_3 = 0;
16078
16079       /* "lxml/html/diff.py":783
16080  *     for tag in ['ins', 'del']:
16081  *         for el in doc.xpath('descendant-or-self::%s' % tag):
16082  *             if not _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
16083  *                 continue
16084  *             _move_el_inside_block(el, tag=tag)
16085  */
16086       __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_contains_block_level_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 783, __pyx_L1_error)
16087       __Pyx_GOTREF(__pyx_t_5);
16088       __pyx_t_6 = NULL;
16089       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
16090         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
16091         if (likely(__pyx_t_6)) {
16092           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
16093           __Pyx_INCREF(__pyx_t_6);
16094           __Pyx_INCREF(function);
16095           __Pyx_DECREF_SET(__pyx_t_5, function);
16096         }
16097       }
16098       __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_el) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_el);
16099       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
16100       if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 783, __pyx_L1_error)
16101       __Pyx_GOTREF(__pyx_t_3);
16102       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16103       __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 783, __pyx_L1_error)
16104       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16105       __pyx_t_10 = ((!__pyx_t_9) != 0);
16106       if (__pyx_t_10) {
16107
16108         /* "lxml/html/diff.py":784
16109  *         for el in doc.xpath('descendant-or-self::%s' % tag):
16110  *             if not _contains_block_level_tag(el):
16111  *                 continue             # <<<<<<<<<<<<<<
16112  *             _move_el_inside_block(el, tag=tag)
16113  *             el.drop_tag()
16114  */
16115         goto __pyx_L5_continue;
16116
16117         /* "lxml/html/diff.py":783
16118  *     for tag in ['ins', 'del']:
16119  *         for el in doc.xpath('descendant-or-self::%s' % tag):
16120  *             if not _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
16121  *                 continue
16122  *             _move_el_inside_block(el, tag=tag)
16123  */
16124       }
16125
16126       /* "lxml/html/diff.py":785
16127  *             if not _contains_block_level_tag(el):
16128  *                 continue
16129  *             _move_el_inside_block(el, tag=tag)             # <<<<<<<<<<<<<<
16130  *             el.drop_tag()
16131  *             #_merge_element_contents(el)
16132  */
16133       __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_move_el_inside_block); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
16134       __Pyx_GOTREF(__pyx_t_3);
16135       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __pyx_L1_error)
16136       __Pyx_GOTREF(__pyx_t_5);
16137       __Pyx_INCREF(__pyx_v_el);
16138       __Pyx_GIVEREF(__pyx_v_el);
16139       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_el);
16140       __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 785, __pyx_L1_error)
16141       __Pyx_GOTREF(__pyx_t_6);
16142       if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_tag, __pyx_v_tag) < 0) __PYX_ERR(0, 785, __pyx_L1_error)
16143       __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 785, __pyx_L1_error)
16144       __Pyx_GOTREF(__pyx_t_11);
16145       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16146       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16147       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16148       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
16149
16150       /* "lxml/html/diff.py":786
16151  *                 continue
16152  *             _move_el_inside_block(el, tag=tag)
16153  *             el.drop_tag()             # <<<<<<<<<<<<<<
16154  *             #_merge_element_contents(el)
16155  * 
16156  */
16157       __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_drop_tag); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 786, __pyx_L1_error)
16158       __Pyx_GOTREF(__pyx_t_6);
16159       __pyx_t_5 = NULL;
16160       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
16161         __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
16162         if (likely(__pyx_t_5)) {
16163           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
16164           __Pyx_INCREF(__pyx_t_5);
16165           __Pyx_INCREF(function);
16166           __Pyx_DECREF_SET(__pyx_t_6, function);
16167         }
16168       }
16169       __pyx_t_11 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
16170       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
16171       if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 786, __pyx_L1_error)
16172       __Pyx_GOTREF(__pyx_t_11);
16173       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16174       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
16175
16176       /* "lxml/html/diff.py":782
16177  *     """
16178  *     for tag in ['ins', 'del']:
16179  *         for el in doc.xpath('descendant-or-self::%s' % tag):             # <<<<<<<<<<<<<<
16180  *             if not _contains_block_level_tag(el):
16181  *                 continue
16182  */
16183       __pyx_L5_continue:;
16184     }
16185     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16186
16187     /* "lxml/html/diff.py":781
16188  *     """fixup_ins_del_tags that works on an lxml document in-place
16189  *     """
16190  *     for tag in ['ins', 'del']:             # <<<<<<<<<<<<<<
16191  *         for el in doc.xpath('descendant-or-self::%s' % tag):
16192  *             if not _contains_block_level_tag(el):
16193  */
16194   }
16195   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16196
16197   /* "lxml/html/diff.py":778
16198  *         return html
16199  * 
16200  * def _fixup_ins_del_tags(doc):             # <<<<<<<<<<<<<<
16201  *     """fixup_ins_del_tags that works on an lxml document in-place
16202  *     """
16203  */
16204
16205   /* function exit code */
16206   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16207   goto __pyx_L0;
16208   __pyx_L1_error:;
16209   __Pyx_XDECREF(__pyx_t_1);
16210   __Pyx_XDECREF(__pyx_t_3);
16211   __Pyx_XDECREF(__pyx_t_4);
16212   __Pyx_XDECREF(__pyx_t_5);
16213   __Pyx_XDECREF(__pyx_t_6);
16214   __Pyx_XDECREF(__pyx_t_11);
16215   __Pyx_AddTraceback("lxml.html.diff._fixup_ins_del_tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
16216   __pyx_r = NULL;
16217   __pyx_L0:;
16218   __Pyx_XDECREF(__pyx_v_tag);
16219   __Pyx_XDECREF(__pyx_v_el);
16220   __Pyx_XGIVEREF(__pyx_r);
16221   __Pyx_RefNannyFinishContext();
16222   return __pyx_r;
16223 }
16224
16225 /* "lxml/html/diff.py":789
16226  *             #_merge_element_contents(el)
16227  * 
16228  * def _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
16229  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
16230  *     """
16231  */
16232
16233 /* Python wrapper */
16234 static PyObject *__pyx_pw_4lxml_4html_4diff_70_contains_block_level_tag(PyObject *__pyx_self, PyObject *__pyx_v_el); /*proto*/
16235 static char __pyx_doc_4lxml_4html_4diff_69_contains_block_level_tag[] = "True if the element contains any block-level elements, like <p>, <td>, etc.\n    ";
16236 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_70_contains_block_level_tag = {"_contains_block_level_tag", (PyCFunction)__pyx_pw_4lxml_4html_4diff_70_contains_block_level_tag, METH_O, __pyx_doc_4lxml_4html_4diff_69_contains_block_level_tag};
16237 static PyObject *__pyx_pw_4lxml_4html_4diff_70_contains_block_level_tag(PyObject *__pyx_self, PyObject *__pyx_v_el) {
16238   PyObject *__pyx_r = 0;
16239   __Pyx_RefNannyDeclarations
16240   __Pyx_RefNannySetupContext("_contains_block_level_tag (wrapper)", 0);
16241   __pyx_r = __pyx_pf_4lxml_4html_4diff_69_contains_block_level_tag(__pyx_self, ((PyObject *)__pyx_v_el));
16242
16243   /* function exit code */
16244   __Pyx_RefNannyFinishContext();
16245   return __pyx_r;
16246 }
16247
16248 static PyObject *__pyx_pf_4lxml_4html_4diff_69_contains_block_level_tag(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el) {
16249   PyObject *__pyx_v_child = NULL;
16250   PyObject *__pyx_r = NULL;
16251   __Pyx_RefNannyDeclarations
16252   int __pyx_t_1;
16253   PyObject *__pyx_t_2 = NULL;
16254   PyObject *__pyx_t_3 = NULL;
16255   int __pyx_t_4;
16256   int __pyx_t_5;
16257   Py_ssize_t __pyx_t_6;
16258   PyObject *(*__pyx_t_7)(PyObject *);
16259   PyObject *__pyx_t_8 = NULL;
16260   PyObject *__pyx_t_9 = NULL;
16261   int __pyx_lineno = 0;
16262   const char *__pyx_filename = NULL;
16263   int __pyx_clineno = 0;
16264   __Pyx_RefNannySetupContext("_contains_block_level_tag", 0);
16265
16266   /* "lxml/html/diff.py":792
16267  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
16268  *     """
16269  *     if el.tag in block_level_tags or el.tag in block_level_container_tags:             # <<<<<<<<<<<<<<
16270  *         return True
16271  *     for child in el:
16272  */
16273   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 792, __pyx_L1_error)
16274   __Pyx_GOTREF(__pyx_t_2);
16275   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_block_level_tags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
16276   __Pyx_GOTREF(__pyx_t_3);
16277   __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 792, __pyx_L1_error)
16278   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16279   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16280   __pyx_t_5 = (__pyx_t_4 != 0);
16281   if (!__pyx_t_5) {
16282   } else {
16283     __pyx_t_1 = __pyx_t_5;
16284     goto __pyx_L4_bool_binop_done;
16285   }
16286   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
16287   __Pyx_GOTREF(__pyx_t_3);
16288   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_block_level_container_tags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 792, __pyx_L1_error)
16289   __Pyx_GOTREF(__pyx_t_2);
16290   __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 792, __pyx_L1_error)
16291   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16292   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16293   __pyx_t_4 = (__pyx_t_5 != 0);
16294   __pyx_t_1 = __pyx_t_4;
16295   __pyx_L4_bool_binop_done:;
16296   if (__pyx_t_1) {
16297
16298     /* "lxml/html/diff.py":793
16299  *     """
16300  *     if el.tag in block_level_tags or el.tag in block_level_container_tags:
16301  *         return True             # <<<<<<<<<<<<<<
16302  *     for child in el:
16303  *         if _contains_block_level_tag(child):
16304  */
16305     __Pyx_XDECREF(__pyx_r);
16306     __Pyx_INCREF(Py_True);
16307     __pyx_r = Py_True;
16308     goto __pyx_L0;
16309
16310     /* "lxml/html/diff.py":792
16311  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
16312  *     """
16313  *     if el.tag in block_level_tags or el.tag in block_level_container_tags:             # <<<<<<<<<<<<<<
16314  *         return True
16315  *     for child in el:
16316  */
16317   }
16318
16319   /* "lxml/html/diff.py":794
16320  *     if el.tag in block_level_tags or el.tag in block_level_container_tags:
16321  *         return True
16322  *     for child in el:             # <<<<<<<<<<<<<<
16323  *         if _contains_block_level_tag(child):
16324  *             return True
16325  */
16326   if (likely(PyList_CheckExact(__pyx_v_el)) || PyTuple_CheckExact(__pyx_v_el)) {
16327     __pyx_t_2 = __pyx_v_el; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
16328     __pyx_t_7 = NULL;
16329   } else {
16330     __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_el); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 794, __pyx_L1_error)
16331     __Pyx_GOTREF(__pyx_t_2);
16332     __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 794, __pyx_L1_error)
16333   }
16334   for (;;) {
16335     if (likely(!__pyx_t_7)) {
16336       if (likely(PyList_CheckExact(__pyx_t_2))) {
16337         if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
16338         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16339         __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 794, __pyx_L1_error)
16340         #else
16341         __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 794, __pyx_L1_error)
16342         __Pyx_GOTREF(__pyx_t_3);
16343         #endif
16344       } else {
16345         if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
16346         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16347         __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 794, __pyx_L1_error)
16348         #else
16349         __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 794, __pyx_L1_error)
16350         __Pyx_GOTREF(__pyx_t_3);
16351         #endif
16352       }
16353     } else {
16354       __pyx_t_3 = __pyx_t_7(__pyx_t_2);
16355       if (unlikely(!__pyx_t_3)) {
16356         PyObject* exc_type = PyErr_Occurred();
16357         if (exc_type) {
16358           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
16359           else __PYX_ERR(0, 794, __pyx_L1_error)
16360         }
16361         break;
16362       }
16363       __Pyx_GOTREF(__pyx_t_3);
16364     }
16365     __Pyx_XDECREF_SET(__pyx_v_child, __pyx_t_3);
16366     __pyx_t_3 = 0;
16367
16368     /* "lxml/html/diff.py":795
16369  *         return True
16370  *     for child in el:
16371  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
16372  *             return True
16373  *     return False
16374  */
16375     __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_contains_block_level_tag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 795, __pyx_L1_error)
16376     __Pyx_GOTREF(__pyx_t_8);
16377     __pyx_t_9 = NULL;
16378     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
16379       __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
16380       if (likely(__pyx_t_9)) {
16381         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
16382         __Pyx_INCREF(__pyx_t_9);
16383         __Pyx_INCREF(function);
16384         __Pyx_DECREF_SET(__pyx_t_8, function);
16385       }
16386     }
16387     __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_v_child) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_child);
16388     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
16389     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __pyx_L1_error)
16390     __Pyx_GOTREF(__pyx_t_3);
16391     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
16392     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
16393     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16394     if (__pyx_t_1) {
16395
16396       /* "lxml/html/diff.py":796
16397  *     for child in el:
16398  *         if _contains_block_level_tag(child):
16399  *             return True             # <<<<<<<<<<<<<<
16400  *     return False
16401  * 
16402  */
16403       __Pyx_XDECREF(__pyx_r);
16404       __Pyx_INCREF(Py_True);
16405       __pyx_r = Py_True;
16406       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16407       goto __pyx_L0;
16408
16409       /* "lxml/html/diff.py":795
16410  *         return True
16411  *     for child in el:
16412  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
16413  *             return True
16414  *     return False
16415  */
16416     }
16417
16418     /* "lxml/html/diff.py":794
16419  *     if el.tag in block_level_tags or el.tag in block_level_container_tags:
16420  *         return True
16421  *     for child in el:             # <<<<<<<<<<<<<<
16422  *         if _contains_block_level_tag(child):
16423  *             return True
16424  */
16425   }
16426   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16427
16428   /* "lxml/html/diff.py":797
16429  *         if _contains_block_level_tag(child):
16430  *             return True
16431  *     return False             # <<<<<<<<<<<<<<
16432  * 
16433  * def _move_el_inside_block(el, tag):
16434  */
16435   __Pyx_XDECREF(__pyx_r);
16436   __Pyx_INCREF(Py_False);
16437   __pyx_r = Py_False;
16438   goto __pyx_L0;
16439
16440   /* "lxml/html/diff.py":789
16441  *             #_merge_element_contents(el)
16442  * 
16443  * def _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
16444  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
16445  *     """
16446  */
16447
16448   /* function exit code */
16449   __pyx_L1_error:;
16450   __Pyx_XDECREF(__pyx_t_2);
16451   __Pyx_XDECREF(__pyx_t_3);
16452   __Pyx_XDECREF(__pyx_t_8);
16453   __Pyx_XDECREF(__pyx_t_9);
16454   __Pyx_AddTraceback("lxml.html.diff._contains_block_level_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
16455   __pyx_r = NULL;
16456   __pyx_L0:;
16457   __Pyx_XDECREF(__pyx_v_child);
16458   __Pyx_XGIVEREF(__pyx_r);
16459   __Pyx_RefNannyFinishContext();
16460   return __pyx_r;
16461 }
16462
16463 /* "lxml/html/diff.py":799
16464  *     return False
16465  * 
16466  * def _move_el_inside_block(el, tag):             # <<<<<<<<<<<<<<
16467  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
16468  *     and moves them inside any block-level tags.  """
16469  */
16470
16471 /* Python wrapper */
16472 static PyObject *__pyx_pw_4lxml_4html_4diff_72_move_el_inside_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
16473 static char __pyx_doc_4lxml_4html_4diff_71_move_el_inside_block[] = " helper for _fixup_ins_del_tags; actually takes the <ins> etc tags\n    and moves them inside any block-level tags.  ";
16474 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_72_move_el_inside_block = {"_move_el_inside_block", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lxml_4html_4diff_72_move_el_inside_block, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_4html_4diff_71_move_el_inside_block};
16475 static PyObject *__pyx_pw_4lxml_4html_4diff_72_move_el_inside_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
16476   PyObject *__pyx_v_el = 0;
16477   PyObject *__pyx_v_tag = 0;
16478   int __pyx_lineno = 0;
16479   const char *__pyx_filename = NULL;
16480   int __pyx_clineno = 0;
16481   PyObject *__pyx_r = 0;
16482   __Pyx_RefNannyDeclarations
16483   __Pyx_RefNannySetupContext("_move_el_inside_block (wrapper)", 0);
16484   {
16485     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_el,&__pyx_n_s_tag,0};
16486     PyObject* values[2] = {0,0};
16487     if (unlikely(__pyx_kwds)) {
16488       Py_ssize_t kw_args;
16489       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
16490       switch (pos_args) {
16491         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16492         CYTHON_FALLTHROUGH;
16493         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16494         CYTHON_FALLTHROUGH;
16495         case  0: break;
16496         default: goto __pyx_L5_argtuple_error;
16497       }
16498       kw_args = PyDict_Size(__pyx_kwds);
16499       switch (pos_args) {
16500         case  0:
16501         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_el)) != 0)) kw_args--;
16502         else goto __pyx_L5_argtuple_error;
16503         CYTHON_FALLTHROUGH;
16504         case  1:
16505         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tag)) != 0)) kw_args--;
16506         else {
16507           __Pyx_RaiseArgtupleInvalid("_move_el_inside_block", 1, 2, 2, 1); __PYX_ERR(0, 799, __pyx_L3_error)
16508         }
16509       }
16510       if (unlikely(kw_args > 0)) {
16511         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_move_el_inside_block") < 0)) __PYX_ERR(0, 799, __pyx_L3_error)
16512       }
16513     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
16514       goto __pyx_L5_argtuple_error;
16515     } else {
16516       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16517       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16518     }
16519     __pyx_v_el = values[0];
16520     __pyx_v_tag = values[1];
16521   }
16522   goto __pyx_L4_argument_unpacking_done;
16523   __pyx_L5_argtuple_error:;
16524   __Pyx_RaiseArgtupleInvalid("_move_el_inside_block", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 799, __pyx_L3_error)
16525   __pyx_L3_error:;
16526   __Pyx_AddTraceback("lxml.html.diff._move_el_inside_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
16527   __Pyx_RefNannyFinishContext();
16528   return NULL;
16529   __pyx_L4_argument_unpacking_done:;
16530   __pyx_r = __pyx_pf_4lxml_4html_4diff_71_move_el_inside_block(__pyx_self, __pyx_v_el, __pyx_v_tag);
16531
16532   /* function exit code */
16533   __Pyx_RefNannyFinishContext();
16534   return __pyx_r;
16535 }
16536
16537 static PyObject *__pyx_pf_4lxml_4html_4diff_71_move_el_inside_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el, PyObject *__pyx_v_tag) {
16538   PyObject *__pyx_v_child = NULL;
16539   PyObject *__pyx_v_children_tag = NULL;
16540   PyObject *__pyx_v_tail_tag = NULL;
16541   PyObject *__pyx_v_child_tag = NULL;
16542   PyObject *__pyx_v_text_tag = NULL;
16543   PyObject *__pyx_r = NULL;
16544   __Pyx_RefNannyDeclarations
16545   PyObject *__pyx_t_1 = NULL;
16546   Py_ssize_t __pyx_t_2;
16547   PyObject *(*__pyx_t_3)(PyObject *);
16548   PyObject *__pyx_t_4 = NULL;
16549   PyObject *__pyx_t_5 = NULL;
16550   PyObject *__pyx_t_6 = NULL;
16551   int __pyx_t_7;
16552   PyObject *__pyx_t_8 = NULL;
16553   int __pyx_t_9;
16554   PyObject *__pyx_t_10 = NULL;
16555   int __pyx_t_11;
16556   int __pyx_lineno = 0;
16557   const char *__pyx_filename = NULL;
16558   int __pyx_clineno = 0;
16559   __Pyx_RefNannySetupContext("_move_el_inside_block", 0);
16560
16561   /* "lxml/html/diff.py":802
16562  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
16563  *     and moves them inside any block-level tags.  """
16564  *     for child in el:             # <<<<<<<<<<<<<<
16565  *         if _contains_block_level_tag(child):
16566  *             break
16567  */
16568   if (likely(PyList_CheckExact(__pyx_v_el)) || PyTuple_CheckExact(__pyx_v_el)) {
16569     __pyx_t_1 = __pyx_v_el; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
16570     __pyx_t_3 = NULL;
16571   } else {
16572     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_el); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error)
16573     __Pyx_GOTREF(__pyx_t_1);
16574     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 802, __pyx_L1_error)
16575   }
16576   for (;;) {
16577     if (likely(!__pyx_t_3)) {
16578       if (likely(PyList_CheckExact(__pyx_t_1))) {
16579         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
16580         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16581         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 802, __pyx_L1_error)
16582         #else
16583         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
16584         __Pyx_GOTREF(__pyx_t_4);
16585         #endif
16586       } else {
16587         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
16588         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16589         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 802, __pyx_L1_error)
16590         #else
16591         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
16592         __Pyx_GOTREF(__pyx_t_4);
16593         #endif
16594       }
16595     } else {
16596       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
16597       if (unlikely(!__pyx_t_4)) {
16598         PyObject* exc_type = PyErr_Occurred();
16599         if (exc_type) {
16600           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
16601           else __PYX_ERR(0, 802, __pyx_L1_error)
16602         }
16603         break;
16604       }
16605       __Pyx_GOTREF(__pyx_t_4);
16606     }
16607     __Pyx_XDECREF_SET(__pyx_v_child, __pyx_t_4);
16608     __pyx_t_4 = 0;
16609
16610     /* "lxml/html/diff.py":803
16611  *     and moves them inside any block-level tags.  """
16612  *     for child in el:
16613  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
16614  *             break
16615  *     else:
16616  */
16617     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_contains_block_level_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 803, __pyx_L1_error)
16618     __Pyx_GOTREF(__pyx_t_5);
16619     __pyx_t_6 = NULL;
16620     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
16621       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
16622       if (likely(__pyx_t_6)) {
16623         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
16624         __Pyx_INCREF(__pyx_t_6);
16625         __Pyx_INCREF(function);
16626         __Pyx_DECREF_SET(__pyx_t_5, function);
16627       }
16628     }
16629     __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_child) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_child);
16630     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
16631     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error)
16632     __Pyx_GOTREF(__pyx_t_4);
16633     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16634     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 803, __pyx_L1_error)
16635     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16636     if (__pyx_t_7) {
16637
16638       /* "lxml/html/diff.py":804
16639  *     for child in el:
16640  *         if _contains_block_level_tag(child):
16641  *             break             # <<<<<<<<<<<<<<
16642  *     else:
16643  *         # No block-level tags in any child
16644  */
16645       goto __pyx_L4_break;
16646
16647       /* "lxml/html/diff.py":803
16648  *     and moves them inside any block-level tags.  """
16649  *     for child in el:
16650  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
16651  *             break
16652  *     else:
16653  */
16654     }
16655
16656     /* "lxml/html/diff.py":802
16657  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
16658  *     and moves them inside any block-level tags.  """
16659  *     for child in el:             # <<<<<<<<<<<<<<
16660  *         if _contains_block_level_tag(child):
16661  *             break
16662  */
16663   }
16664   /*else*/ {
16665
16666     /* "lxml/html/diff.py":807
16667  *     else:
16668  *         # No block-level tags in any child
16669  *         children_tag = etree.Element(tag)             # <<<<<<<<<<<<<<
16670  *         children_tag.text = el.text
16671  *         el.text = None
16672  */
16673     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_etree); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error)
16674     __Pyx_GOTREF(__pyx_t_5);
16675     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Element); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 807, __pyx_L1_error)
16676     __Pyx_GOTREF(__pyx_t_6);
16677     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16678     __pyx_t_5 = NULL;
16679     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
16680       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
16681       if (likely(__pyx_t_5)) {
16682         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
16683         __Pyx_INCREF(__pyx_t_5);
16684         __Pyx_INCREF(function);
16685         __Pyx_DECREF_SET(__pyx_t_6, function);
16686       }
16687     }
16688     __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_tag) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_tag);
16689     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
16690     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __pyx_L1_error)
16691     __Pyx_GOTREF(__pyx_t_4);
16692     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16693     __pyx_v_children_tag = __pyx_t_4;
16694     __pyx_t_4 = 0;
16695
16696     /* "lxml/html/diff.py":808
16697  *         # No block-level tags in any child
16698  *         children_tag = etree.Element(tag)
16699  *         children_tag.text = el.text             # <<<<<<<<<<<<<<
16700  *         el.text = None
16701  *         children_tag.extend(list(el))
16702  */
16703     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 808, __pyx_L1_error)
16704     __Pyx_GOTREF(__pyx_t_4);
16705     if (__Pyx_PyObject_SetAttrStr(__pyx_v_children_tag, __pyx_n_s_text, __pyx_t_4) < 0) __PYX_ERR(0, 808, __pyx_L1_error)
16706     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16707
16708     /* "lxml/html/diff.py":809
16709  *         children_tag = etree.Element(tag)
16710  *         children_tag.text = el.text
16711  *         el.text = None             # <<<<<<<<<<<<<<
16712  *         children_tag.extend(list(el))
16713  *         el[:] = [children_tag]
16714  */
16715     if (__Pyx_PyObject_SetAttrStr(__pyx_v_el, __pyx_n_s_text, Py_None) < 0) __PYX_ERR(0, 809, __pyx_L1_error)
16716
16717     /* "lxml/html/diff.py":810
16718  *         children_tag.text = el.text
16719  *         el.text = None
16720  *         children_tag.extend(list(el))             # <<<<<<<<<<<<<<
16721  *         el[:] = [children_tag]
16722  *         return
16723  */
16724     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_children_tag, __pyx_n_s_extend); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 810, __pyx_L1_error)
16725     __Pyx_GOTREF(__pyx_t_6);
16726     __pyx_t_5 = PySequence_List(__pyx_v_el); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 810, __pyx_L1_error)
16727     __Pyx_GOTREF(__pyx_t_5);
16728     __pyx_t_8 = NULL;
16729     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
16730       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
16731       if (likely(__pyx_t_8)) {
16732         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
16733         __Pyx_INCREF(__pyx_t_8);
16734         __Pyx_INCREF(function);
16735         __Pyx_DECREF_SET(__pyx_t_6, function);
16736       }
16737     }
16738     __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
16739     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
16740     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16741     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error)
16742     __Pyx_GOTREF(__pyx_t_4);
16743     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16744     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16745
16746     /* "lxml/html/diff.py":811
16747  *         el.text = None
16748  *         children_tag.extend(list(el))
16749  *         el[:] = [children_tag]             # <<<<<<<<<<<<<<
16750  *         return
16751  *     for child in list(el):
16752  */
16753     __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 811, __pyx_L1_error)
16754     __Pyx_GOTREF(__pyx_t_4);
16755     __Pyx_INCREF(__pyx_v_children_tag);
16756     __Pyx_GIVEREF(__pyx_v_children_tag);
16757     PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_children_tag);
16758     if (__Pyx_PyObject_SetSlice(__pyx_v_el, __pyx_t_4, 0, 0, NULL, NULL, &__pyx_slice__22, 0, 0, 1) < 0) __PYX_ERR(0, 811, __pyx_L1_error)
16759     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16760
16761     /* "lxml/html/diff.py":812
16762  *         children_tag.extend(list(el))
16763  *         el[:] = [children_tag]
16764  *         return             # <<<<<<<<<<<<<<
16765  *     for child in list(el):
16766  *         if _contains_block_level_tag(child):
16767  */
16768     __Pyx_XDECREF(__pyx_r);
16769     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16770     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16771     goto __pyx_L0;
16772   }
16773
16774   /* "lxml/html/diff.py":802
16775  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
16776  *     and moves them inside any block-level tags.  """
16777  *     for child in el:             # <<<<<<<<<<<<<<
16778  *         if _contains_block_level_tag(child):
16779  *             break
16780  */
16781   __pyx_L4_break:;
16782   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16783
16784   /* "lxml/html/diff.py":813
16785  *         el[:] = [children_tag]
16786  *         return
16787  *     for child in list(el):             # <<<<<<<<<<<<<<
16788  *         if _contains_block_level_tag(child):
16789  *             _move_el_inside_block(child, tag)
16790  */
16791   __pyx_t_1 = PySequence_List(__pyx_v_el); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
16792   __Pyx_GOTREF(__pyx_t_1);
16793   __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
16794   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16795   for (;;) {
16796     if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
16797     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16798     __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 813, __pyx_L1_error)
16799     #else
16800     __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
16801     __Pyx_GOTREF(__pyx_t_1);
16802     #endif
16803     __Pyx_DECREF_SET(__pyx_v_child, __pyx_t_1);
16804     __pyx_t_1 = 0;
16805
16806     /* "lxml/html/diff.py":814
16807  *         return
16808  *     for child in list(el):
16809  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
16810  *             _move_el_inside_block(child, tag)
16811  *             if child.tail:
16812  */
16813     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_contains_block_level_tag); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 814, __pyx_L1_error)
16814     __Pyx_GOTREF(__pyx_t_6);
16815     __pyx_t_5 = NULL;
16816     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
16817       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
16818       if (likely(__pyx_t_5)) {
16819         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
16820         __Pyx_INCREF(__pyx_t_5);
16821         __Pyx_INCREF(function);
16822         __Pyx_DECREF_SET(__pyx_t_6, function);
16823       }
16824     }
16825     __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_child) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_child);
16826     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
16827     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 814, __pyx_L1_error)
16828     __Pyx_GOTREF(__pyx_t_1);
16829     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16830     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 814, __pyx_L1_error)
16831     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16832     if (__pyx_t_7) {
16833
16834       /* "lxml/html/diff.py":815
16835  *     for child in list(el):
16836  *         if _contains_block_level_tag(child):
16837  *             _move_el_inside_block(child, tag)             # <<<<<<<<<<<<<<
16838  *             if child.tail:
16839  *                 tail_tag = etree.Element(tag)
16840  */
16841       __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_move_el_inside_block); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 815, __pyx_L1_error)
16842       __Pyx_GOTREF(__pyx_t_6);
16843       __pyx_t_5 = NULL;
16844       __pyx_t_9 = 0;
16845       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
16846         __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
16847         if (likely(__pyx_t_5)) {
16848           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
16849           __Pyx_INCREF(__pyx_t_5);
16850           __Pyx_INCREF(function);
16851           __Pyx_DECREF_SET(__pyx_t_6, function);
16852           __pyx_t_9 = 1;
16853         }
16854       }
16855       #if CYTHON_FAST_PYCALL
16856       if (PyFunction_Check(__pyx_t_6)) {
16857         PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_child, __pyx_v_tag};
16858         __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L1_error)
16859         __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
16860         __Pyx_GOTREF(__pyx_t_1);
16861       } else
16862       #endif
16863       #if CYTHON_FAST_PYCCALL
16864       if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
16865         PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_child, __pyx_v_tag};
16866         __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L1_error)
16867         __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
16868         __Pyx_GOTREF(__pyx_t_1);
16869       } else
16870       #endif
16871       {
16872         __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 815, __pyx_L1_error)
16873         __Pyx_GOTREF(__pyx_t_8);
16874         if (__pyx_t_5) {
16875           __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
16876         }
16877         __Pyx_INCREF(__pyx_v_child);
16878         __Pyx_GIVEREF(__pyx_v_child);
16879         PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_child);
16880         __Pyx_INCREF(__pyx_v_tag);
16881         __Pyx_GIVEREF(__pyx_v_tag);
16882         PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_v_tag);
16883         __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L1_error)
16884         __Pyx_GOTREF(__pyx_t_1);
16885         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
16886       }
16887       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16888       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16889
16890       /* "lxml/html/diff.py":816
16891  *         if _contains_block_level_tag(child):
16892  *             _move_el_inside_block(child, tag)
16893  *             if child.tail:             # <<<<<<<<<<<<<<
16894  *                 tail_tag = etree.Element(tag)
16895  *                 tail_tag.text = child.tail
16896  */
16897       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
16898       __Pyx_GOTREF(__pyx_t_1);
16899       __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 816, __pyx_L1_error)
16900       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16901       if (__pyx_t_7) {
16902
16903         /* "lxml/html/diff.py":817
16904  *             _move_el_inside_block(child, tag)
16905  *             if child.tail:
16906  *                 tail_tag = etree.Element(tag)             # <<<<<<<<<<<<<<
16907  *                 tail_tag.text = child.tail
16908  *                 child.tail = None
16909  */
16910         __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_etree); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 817, __pyx_L1_error)
16911         __Pyx_GOTREF(__pyx_t_6);
16912         __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_Element); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 817, __pyx_L1_error)
16913         __Pyx_GOTREF(__pyx_t_8);
16914         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16915         __pyx_t_6 = NULL;
16916         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
16917           __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
16918           if (likely(__pyx_t_6)) {
16919             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
16920             __Pyx_INCREF(__pyx_t_6);
16921             __Pyx_INCREF(function);
16922             __Pyx_DECREF_SET(__pyx_t_8, function);
16923           }
16924         }
16925         __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_6, __pyx_v_tag) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_tag);
16926         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
16927         if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
16928         __Pyx_GOTREF(__pyx_t_1);
16929         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
16930         __Pyx_XDECREF_SET(__pyx_v_tail_tag, __pyx_t_1);
16931         __pyx_t_1 = 0;
16932
16933         /* "lxml/html/diff.py":818
16934  *             if child.tail:
16935  *                 tail_tag = etree.Element(tag)
16936  *                 tail_tag.text = child.tail             # <<<<<<<<<<<<<<
16937  *                 child.tail = None
16938  *                 el.insert(el.index(child)+1, tail_tag)
16939  */
16940         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 818, __pyx_L1_error)
16941         __Pyx_GOTREF(__pyx_t_1);
16942         if (__Pyx_PyObject_SetAttrStr(__pyx_v_tail_tag, __pyx_n_s_text, __pyx_t_1) < 0) __PYX_ERR(0, 818, __pyx_L1_error)
16943         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16944
16945         /* "lxml/html/diff.py":819
16946  *                 tail_tag = etree.Element(tag)
16947  *                 tail_tag.text = child.tail
16948  *                 child.tail = None             # <<<<<<<<<<<<<<
16949  *                 el.insert(el.index(child)+1, tail_tag)
16950  *         else:
16951  */
16952         if (__Pyx_PyObject_SetAttrStr(__pyx_v_child, __pyx_n_s_tail, Py_None) < 0) __PYX_ERR(0, 819, __pyx_L1_error)
16953
16954         /* "lxml/html/diff.py":820
16955  *                 tail_tag.text = child.tail
16956  *                 child.tail = None
16957  *                 el.insert(el.index(child)+1, tail_tag)             # <<<<<<<<<<<<<<
16958  *         else:
16959  *             child_tag = etree.Element(tag)
16960  */
16961         __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_insert); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 820, __pyx_L1_error)
16962         __Pyx_GOTREF(__pyx_t_8);
16963         __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
16964         __Pyx_GOTREF(__pyx_t_5);
16965         __pyx_t_10 = NULL;
16966         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
16967           __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
16968           if (likely(__pyx_t_10)) {
16969             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
16970             __Pyx_INCREF(__pyx_t_10);
16971             __Pyx_INCREF(function);
16972             __Pyx_DECREF_SET(__pyx_t_5, function);
16973           }
16974         }
16975         __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_10, __pyx_v_child) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_child);
16976         __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
16977         if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 820, __pyx_L1_error)
16978         __Pyx_GOTREF(__pyx_t_6);
16979         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16980         __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
16981         __Pyx_GOTREF(__pyx_t_5);
16982         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16983         __pyx_t_6 = NULL;
16984         __pyx_t_9 = 0;
16985         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
16986           __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
16987           if (likely(__pyx_t_6)) {
16988             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
16989             __Pyx_INCREF(__pyx_t_6);
16990             __Pyx_INCREF(function);
16991             __Pyx_DECREF_SET(__pyx_t_8, function);
16992             __pyx_t_9 = 1;
16993           }
16994         }
16995         #if CYTHON_FAST_PYCALL
16996         if (PyFunction_Check(__pyx_t_8)) {
16997           PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_tail_tag};
16998           __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error)
16999           __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
17000           __Pyx_GOTREF(__pyx_t_1);
17001           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17002         } else
17003         #endif
17004         #if CYTHON_FAST_PYCCALL
17005         if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
17006           PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_tail_tag};
17007           __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error)
17008           __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
17009           __Pyx_GOTREF(__pyx_t_1);
17010           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17011         } else
17012         #endif
17013         {
17014           __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 820, __pyx_L1_error)
17015           __Pyx_GOTREF(__pyx_t_10);
17016           if (__pyx_t_6) {
17017             __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
17018           }
17019           __Pyx_GIVEREF(__pyx_t_5);
17020           PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
17021           __Pyx_INCREF(__pyx_v_tail_tag);
17022           __Pyx_GIVEREF(__pyx_v_tail_tag);
17023           PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_tail_tag);
17024           __pyx_t_5 = 0;
17025           __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error)
17026           __Pyx_GOTREF(__pyx_t_1);
17027           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
17028         }
17029         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
17030         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17031
17032         /* "lxml/html/diff.py":816
17033  *         if _contains_block_level_tag(child):
17034  *             _move_el_inside_block(child, tag)
17035  *             if child.tail:             # <<<<<<<<<<<<<<
17036  *                 tail_tag = etree.Element(tag)
17037  *                 tail_tag.text = child.tail
17038  */
17039       }
17040
17041       /* "lxml/html/diff.py":814
17042  *         return
17043  *     for child in list(el):
17044  *         if _contains_block_level_tag(child):             # <<<<<<<<<<<<<<
17045  *             _move_el_inside_block(child, tag)
17046  *             if child.tail:
17047  */
17048       goto __pyx_L9;
17049     }
17050
17051     /* "lxml/html/diff.py":822
17052  *                 el.insert(el.index(child)+1, tail_tag)
17053  *         else:
17054  *             child_tag = etree.Element(tag)             # <<<<<<<<<<<<<<
17055  *             el.replace(child, child_tag)
17056  *             child_tag.append(child)
17057  */
17058     /*else*/ {
17059       __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_etree); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 822, __pyx_L1_error)
17060       __Pyx_GOTREF(__pyx_t_8);
17061       __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_Element); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 822, __pyx_L1_error)
17062       __Pyx_GOTREF(__pyx_t_10);
17063       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
17064       __pyx_t_8 = NULL;
17065       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
17066         __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
17067         if (likely(__pyx_t_8)) {
17068           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
17069           __Pyx_INCREF(__pyx_t_8);
17070           __Pyx_INCREF(function);
17071           __Pyx_DECREF_SET(__pyx_t_10, function);
17072         }
17073       }
17074       __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_8, __pyx_v_tag) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_tag);
17075       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
17076       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 822, __pyx_L1_error)
17077       __Pyx_GOTREF(__pyx_t_1);
17078       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
17079       __Pyx_XDECREF_SET(__pyx_v_child_tag, __pyx_t_1);
17080       __pyx_t_1 = 0;
17081
17082       /* "lxml/html/diff.py":823
17083  *         else:
17084  *             child_tag = etree.Element(tag)
17085  *             el.replace(child, child_tag)             # <<<<<<<<<<<<<<
17086  *             child_tag.append(child)
17087  *     if el.text:
17088  */
17089       __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_replace); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 823, __pyx_L1_error)
17090       __Pyx_GOTREF(__pyx_t_10);
17091       __pyx_t_8 = NULL;
17092       __pyx_t_9 = 0;
17093       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
17094         __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
17095         if (likely(__pyx_t_8)) {
17096           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
17097           __Pyx_INCREF(__pyx_t_8);
17098           __Pyx_INCREF(function);
17099           __Pyx_DECREF_SET(__pyx_t_10, function);
17100           __pyx_t_9 = 1;
17101         }
17102       }
17103       #if CYTHON_FAST_PYCALL
17104       if (PyFunction_Check(__pyx_t_10)) {
17105         PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_child, __pyx_v_child_tag};
17106         __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error)
17107         __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
17108         __Pyx_GOTREF(__pyx_t_1);
17109       } else
17110       #endif
17111       #if CYTHON_FAST_PYCCALL
17112       if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
17113         PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_child, __pyx_v_child_tag};
17114         __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error)
17115         __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
17116         __Pyx_GOTREF(__pyx_t_1);
17117       } else
17118       #endif
17119       {
17120         __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error)
17121         __Pyx_GOTREF(__pyx_t_5);
17122         if (__pyx_t_8) {
17123           __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
17124         }
17125         __Pyx_INCREF(__pyx_v_child);
17126         __Pyx_GIVEREF(__pyx_v_child);
17127         PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_child);
17128         __Pyx_INCREF(__pyx_v_child_tag);
17129         __Pyx_GIVEREF(__pyx_v_child_tag);
17130         PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_v_child_tag);
17131         __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error)
17132         __Pyx_GOTREF(__pyx_t_1);
17133         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17134       }
17135       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
17136       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17137
17138       /* "lxml/html/diff.py":824
17139  *             child_tag = etree.Element(tag)
17140  *             el.replace(child, child_tag)
17141  *             child_tag.append(child)             # <<<<<<<<<<<<<<
17142  *     if el.text:
17143  *         text_tag = etree.Element(tag)
17144  */
17145       __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_child_tag, __pyx_v_child); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 824, __pyx_L1_error)
17146     }
17147     __pyx_L9:;
17148
17149     /* "lxml/html/diff.py":813
17150  *         el[:] = [children_tag]
17151  *         return
17152  *     for child in list(el):             # <<<<<<<<<<<<<<
17153  *         if _contains_block_level_tag(child):
17154  *             _move_el_inside_block(child, tag)
17155  */
17156   }
17157   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17158
17159   /* "lxml/html/diff.py":825
17160  *             el.replace(child, child_tag)
17161  *             child_tag.append(child)
17162  *     if el.text:             # <<<<<<<<<<<<<<
17163  *         text_tag = etree.Element(tag)
17164  *         text_tag.text = el.text
17165  */
17166   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 825, __pyx_L1_error)
17167   __Pyx_GOTREF(__pyx_t_4);
17168   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 825, __pyx_L1_error)
17169   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17170   if (__pyx_t_7) {
17171
17172     /* "lxml/html/diff.py":826
17173  *             child_tag.append(child)
17174  *     if el.text:
17175  *         text_tag = etree.Element(tag)             # <<<<<<<<<<<<<<
17176  *         text_tag.text = el.text
17177  *         el.text = None
17178  */
17179     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_etree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
17180     __Pyx_GOTREF(__pyx_t_1);
17181     __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Element); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 826, __pyx_L1_error)
17182     __Pyx_GOTREF(__pyx_t_10);
17183     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17184     __pyx_t_1 = NULL;
17185     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
17186       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
17187       if (likely(__pyx_t_1)) {
17188         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
17189         __Pyx_INCREF(__pyx_t_1);
17190         __Pyx_INCREF(function);
17191         __Pyx_DECREF_SET(__pyx_t_10, function);
17192       }
17193     }
17194     __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_1, __pyx_v_tag) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_tag);
17195     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
17196     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 826, __pyx_L1_error)
17197     __Pyx_GOTREF(__pyx_t_4);
17198     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
17199     __pyx_v_text_tag = __pyx_t_4;
17200     __pyx_t_4 = 0;
17201
17202     /* "lxml/html/diff.py":827
17203  *     if el.text:
17204  *         text_tag = etree.Element(tag)
17205  *         text_tag.text = el.text             # <<<<<<<<<<<<<<
17206  *         el.text = None
17207  *         el.insert(0, text_tag)
17208  */
17209     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 827, __pyx_L1_error)
17210     __Pyx_GOTREF(__pyx_t_4);
17211     if (__Pyx_PyObject_SetAttrStr(__pyx_v_text_tag, __pyx_n_s_text, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
17212     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17213
17214     /* "lxml/html/diff.py":828
17215  *         text_tag = etree.Element(tag)
17216  *         text_tag.text = el.text
17217  *         el.text = None             # <<<<<<<<<<<<<<
17218  *         el.insert(0, text_tag)
17219  * 
17220  */
17221     if (__Pyx_PyObject_SetAttrStr(__pyx_v_el, __pyx_n_s_text, Py_None) < 0) __PYX_ERR(0, 828, __pyx_L1_error)
17222
17223     /* "lxml/html/diff.py":829
17224  *         text_tag.text = el.text
17225  *         el.text = None
17226  *         el.insert(0, text_tag)             # <<<<<<<<<<<<<<
17227  * 
17228  * def _merge_element_contents(el):
17229  */
17230     __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_insert); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error)
17231     __Pyx_GOTREF(__pyx_t_10);
17232     __pyx_t_1 = NULL;
17233     __pyx_t_9 = 0;
17234     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
17235       __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
17236       if (likely(__pyx_t_1)) {
17237         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
17238         __Pyx_INCREF(__pyx_t_1);
17239         __Pyx_INCREF(function);
17240         __Pyx_DECREF_SET(__pyx_t_10, function);
17241         __pyx_t_9 = 1;
17242       }
17243     }
17244     #if CYTHON_FAST_PYCALL
17245     if (PyFunction_Check(__pyx_t_10)) {
17246       PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_int_0, __pyx_v_text_tag};
17247       __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error)
17248       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
17249       __Pyx_GOTREF(__pyx_t_4);
17250     } else
17251     #endif
17252     #if CYTHON_FAST_PYCCALL
17253     if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
17254       PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_int_0, __pyx_v_text_tag};
17255       __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error)
17256       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
17257       __Pyx_GOTREF(__pyx_t_4);
17258     } else
17259     #endif
17260     {
17261       __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 829, __pyx_L1_error)
17262       __Pyx_GOTREF(__pyx_t_5);
17263       if (__pyx_t_1) {
17264         __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
17265       }
17266       __Pyx_INCREF(__pyx_int_0);
17267       __Pyx_GIVEREF(__pyx_int_0);
17268       PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_int_0);
17269       __Pyx_INCREF(__pyx_v_text_tag);
17270       __Pyx_GIVEREF(__pyx_v_text_tag);
17271       PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_v_text_tag);
17272       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error)
17273       __Pyx_GOTREF(__pyx_t_4);
17274       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17275     }
17276     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
17277     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17278
17279     /* "lxml/html/diff.py":825
17280  *             el.replace(child, child_tag)
17281  *             child_tag.append(child)
17282  *     if el.text:             # <<<<<<<<<<<<<<
17283  *         text_tag = etree.Element(tag)
17284  *         text_tag.text = el.text
17285  */
17286   }
17287
17288   /* "lxml/html/diff.py":799
17289  *     return False
17290  * 
17291  * def _move_el_inside_block(el, tag):             # <<<<<<<<<<<<<<
17292  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
17293  *     and moves them inside any block-level tags.  """
17294  */
17295
17296   /* function exit code */
17297   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17298   goto __pyx_L0;
17299   __pyx_L1_error:;
17300   __Pyx_XDECREF(__pyx_t_1);
17301   __Pyx_XDECREF(__pyx_t_4);
17302   __Pyx_XDECREF(__pyx_t_5);
17303   __Pyx_XDECREF(__pyx_t_6);
17304   __Pyx_XDECREF(__pyx_t_8);
17305   __Pyx_XDECREF(__pyx_t_10);
17306   __Pyx_AddTraceback("lxml.html.diff._move_el_inside_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
17307   __pyx_r = NULL;
17308   __pyx_L0:;
17309   __Pyx_XDECREF(__pyx_v_child);
17310   __Pyx_XDECREF(__pyx_v_children_tag);
17311   __Pyx_XDECREF(__pyx_v_tail_tag);
17312   __Pyx_XDECREF(__pyx_v_child_tag);
17313   __Pyx_XDECREF(__pyx_v_text_tag);
17314   __Pyx_XGIVEREF(__pyx_r);
17315   __Pyx_RefNannyFinishContext();
17316   return __pyx_r;
17317 }
17318
17319 /* "lxml/html/diff.py":831
17320  *         el.insert(0, text_tag)
17321  * 
17322  * def _merge_element_contents(el):             # <<<<<<<<<<<<<<
17323  *     """
17324  *     Removes an element, but merges its contents into its place, e.g.,
17325  */
17326
17327 /* Python wrapper */
17328 static PyObject *__pyx_pw_4lxml_4html_4diff_74_merge_element_contents(PyObject *__pyx_self, PyObject *__pyx_v_el); /*proto*/
17329 static char __pyx_doc_4lxml_4html_4diff_73_merge_element_contents[] = "\n    Removes an element, but merges its contents into its place, e.g.,\n    given <p>Hi <i>there!</i></p>, if you remove the <i> element you get\n    <p>Hi there!</p>\n    ";
17330 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_74_merge_element_contents = {"_merge_element_contents", (PyCFunction)__pyx_pw_4lxml_4html_4diff_74_merge_element_contents, METH_O, __pyx_doc_4lxml_4html_4diff_73_merge_element_contents};
17331 static PyObject *__pyx_pw_4lxml_4html_4diff_74_merge_element_contents(PyObject *__pyx_self, PyObject *__pyx_v_el) {
17332   PyObject *__pyx_r = 0;
17333   __Pyx_RefNannyDeclarations
17334   __Pyx_RefNannySetupContext("_merge_element_contents (wrapper)", 0);
17335   __pyx_r = __pyx_pf_4lxml_4html_4diff_73_merge_element_contents(__pyx_self, ((PyObject *)__pyx_v_el));
17336
17337   /* function exit code */
17338   __Pyx_RefNannyFinishContext();
17339   return __pyx_r;
17340 }
17341
17342 static PyObject *__pyx_pf_4lxml_4html_4diff_73_merge_element_contents(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_el) {
17343   PyObject *__pyx_v_parent = NULL;
17344   PyObject *__pyx_v_text = NULL;
17345   PyObject *__pyx_v_index = NULL;
17346   PyObject *__pyx_v_previous = NULL;
17347   PyObject *__pyx_r = NULL;
17348   __Pyx_RefNannyDeclarations
17349   PyObject *__pyx_t_1 = NULL;
17350   PyObject *__pyx_t_2 = NULL;
17351   PyObject *__pyx_t_3 = NULL;
17352   int __pyx_t_4;
17353   Py_ssize_t __pyx_t_5;
17354   PyObject *__pyx_t_6 = NULL;
17355   int __pyx_t_7;
17356   int __pyx_lineno = 0;
17357   const char *__pyx_filename = NULL;
17358   int __pyx_clineno = 0;
17359   __Pyx_RefNannySetupContext("_merge_element_contents", 0);
17360
17361   /* "lxml/html/diff.py":837
17362  *     <p>Hi there!</p>
17363  *     """
17364  *     parent = el.getparent()             # <<<<<<<<<<<<<<
17365  *     text = el.text or ''
17366  *     if el.tail:
17367  */
17368   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_getparent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L1_error)
17369   __Pyx_GOTREF(__pyx_t_2);
17370   __pyx_t_3 = NULL;
17371   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
17372     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
17373     if (likely(__pyx_t_3)) {
17374       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
17375       __Pyx_INCREF(__pyx_t_3);
17376       __Pyx_INCREF(function);
17377       __Pyx_DECREF_SET(__pyx_t_2, function);
17378     }
17379   }
17380   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
17381   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
17382   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 837, __pyx_L1_error)
17383   __Pyx_GOTREF(__pyx_t_1);
17384   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17385   __pyx_v_parent = __pyx_t_1;
17386   __pyx_t_1 = 0;
17387
17388   /* "lxml/html/diff.py":838
17389  *     """
17390  *     parent = el.getparent()
17391  *     text = el.text or ''             # <<<<<<<<<<<<<<
17392  *     if el.tail:
17393  *         if not len(el):
17394  */
17395   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 838, __pyx_L1_error)
17396   __Pyx_GOTREF(__pyx_t_2);
17397   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 838, __pyx_L1_error)
17398   if (!__pyx_t_4) {
17399     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17400   } else {
17401     __Pyx_INCREF(__pyx_t_2);
17402     __pyx_t_1 = __pyx_t_2;
17403     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17404     goto __pyx_L3_bool_binop_done;
17405   }
17406   __Pyx_INCREF(__pyx_kp_u__2);
17407   __pyx_t_1 = __pyx_kp_u__2;
17408   __pyx_L3_bool_binop_done:;
17409   __pyx_v_text = __pyx_t_1;
17410   __pyx_t_1 = 0;
17411
17412   /* "lxml/html/diff.py":839
17413  *     parent = el.getparent()
17414  *     text = el.text or ''
17415  *     if el.tail:             # <<<<<<<<<<<<<<
17416  *         if not len(el):
17417  *             text += el.tail
17418  */
17419   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 839, __pyx_L1_error)
17420   __Pyx_GOTREF(__pyx_t_1);
17421   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 839, __pyx_L1_error)
17422   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17423   if (__pyx_t_4) {
17424
17425     /* "lxml/html/diff.py":840
17426  *     text = el.text or ''
17427  *     if el.tail:
17428  *         if not len(el):             # <<<<<<<<<<<<<<
17429  *             text += el.tail
17430  *         else:
17431  */
17432     __pyx_t_5 = PyObject_Length(__pyx_v_el); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 840, __pyx_L1_error)
17433     __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
17434     if (__pyx_t_4) {
17435
17436       /* "lxml/html/diff.py":841
17437  *     if el.tail:
17438  *         if not len(el):
17439  *             text += el.tail             # <<<<<<<<<<<<<<
17440  *         else:
17441  *             if el[-1].tail:
17442  */
17443       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 841, __pyx_L1_error)
17444       __Pyx_GOTREF(__pyx_t_1);
17445       __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_text, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 841, __pyx_L1_error)
17446       __Pyx_GOTREF(__pyx_t_2);
17447       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17448       __Pyx_DECREF_SET(__pyx_v_text, __pyx_t_2);
17449       __pyx_t_2 = 0;
17450
17451       /* "lxml/html/diff.py":840
17452  *     text = el.text or ''
17453  *     if el.tail:
17454  *         if not len(el):             # <<<<<<<<<<<<<<
17455  *             text += el.tail
17456  *         else:
17457  */
17458       goto __pyx_L6;
17459     }
17460
17461     /* "lxml/html/diff.py":843
17462  *             text += el.tail
17463  *         else:
17464  *             if el[-1].tail:             # <<<<<<<<<<<<<<
17465  *                 el[-1].tail += el.tail
17466  *             else:
17467  */
17468     /*else*/ {
17469       __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_el, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 843, __pyx_L1_error)
17470       __Pyx_GOTREF(__pyx_t_2);
17471       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 843, __pyx_L1_error)
17472       __Pyx_GOTREF(__pyx_t_1);
17473       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17474       __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 843, __pyx_L1_error)
17475       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17476       if (__pyx_t_4) {
17477
17478         /* "lxml/html/diff.py":844
17479  *         else:
17480  *             if el[-1].tail:
17481  *                 el[-1].tail += el.tail             # <<<<<<<<<<<<<<
17482  *             else:
17483  *                 el[-1].tail = el.tail
17484  */
17485         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_el, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
17486         __Pyx_GOTREF(__pyx_t_1);
17487         __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tail); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 844, __pyx_L1_error)
17488         __Pyx_GOTREF(__pyx_t_2);
17489         __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 844, __pyx_L1_error)
17490         __Pyx_GOTREF(__pyx_t_3);
17491         __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 844, __pyx_L1_error)
17492         __Pyx_GOTREF(__pyx_t_6);
17493         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17494         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17495         if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_n_s_tail, __pyx_t_6) < 0) __PYX_ERR(0, 844, __pyx_L1_error)
17496         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17497         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17498
17499         /* "lxml/html/diff.py":843
17500  *             text += el.tail
17501  *         else:
17502  *             if el[-1].tail:             # <<<<<<<<<<<<<<
17503  *                 el[-1].tail += el.tail
17504  *             else:
17505  */
17506         goto __pyx_L7;
17507       }
17508
17509       /* "lxml/html/diff.py":846
17510  *                 el[-1].tail += el.tail
17511  *             else:
17512  *                 el[-1].tail = el.tail             # <<<<<<<<<<<<<<
17513  *     index = parent.index(el)
17514  *     if text:
17515  */
17516       /*else*/ {
17517         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_tail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 846, __pyx_L1_error)
17518         __Pyx_GOTREF(__pyx_t_1);
17519         __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_el, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 846, __pyx_L1_error)
17520         __Pyx_GOTREF(__pyx_t_6);
17521         if (__Pyx_PyObject_SetAttrStr(__pyx_t_6, __pyx_n_s_tail, __pyx_t_1) < 0) __PYX_ERR(0, 846, __pyx_L1_error)
17522         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17523         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17524       }
17525       __pyx_L7:;
17526     }
17527     __pyx_L6:;
17528
17529     /* "lxml/html/diff.py":839
17530  *     parent = el.getparent()
17531  *     text = el.text or ''
17532  *     if el.tail:             # <<<<<<<<<<<<<<
17533  *         if not len(el):
17534  *             text += el.tail
17535  */
17536   }
17537
17538   /* "lxml/html/diff.py":847
17539  *             else:
17540  *                 el[-1].tail = el.tail
17541  *     index = parent.index(el)             # <<<<<<<<<<<<<<
17542  *     if text:
17543  *         if index == 0:
17544  */
17545   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent, __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 847, __pyx_L1_error)
17546   __Pyx_GOTREF(__pyx_t_1);
17547   __pyx_t_3 = NULL;
17548   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
17549     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
17550     if (likely(__pyx_t_3)) {
17551       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
17552       __Pyx_INCREF(__pyx_t_3);
17553       __Pyx_INCREF(function);
17554       __Pyx_DECREF_SET(__pyx_t_1, function);
17555     }
17556   }
17557   __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_el) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_el);
17558   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
17559   if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 847, __pyx_L1_error)
17560   __Pyx_GOTREF(__pyx_t_6);
17561   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17562   __pyx_v_index = __pyx_t_6;
17563   __pyx_t_6 = 0;
17564
17565   /* "lxml/html/diff.py":848
17566  *                 el[-1].tail = el.tail
17567  *     index = parent.index(el)
17568  *     if text:             # <<<<<<<<<<<<<<
17569  *         if index == 0:
17570  *             previous = None
17571  */
17572   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_text); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 848, __pyx_L1_error)
17573   if (__pyx_t_4) {
17574
17575     /* "lxml/html/diff.py":849
17576  *     index = parent.index(el)
17577  *     if text:
17578  *         if index == 0:             # <<<<<<<<<<<<<<
17579  *             previous = None
17580  *         else:
17581  */
17582     __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_index, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 849, __pyx_L1_error)
17583     __Pyx_GOTREF(__pyx_t_6);
17584     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 849, __pyx_L1_error)
17585     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17586     if (__pyx_t_4) {
17587
17588       /* "lxml/html/diff.py":850
17589  *     if text:
17590  *         if index == 0:
17591  *             previous = None             # <<<<<<<<<<<<<<
17592  *         else:
17593  *             previous = parent[index-1]
17594  */
17595       __Pyx_INCREF(Py_None);
17596       __pyx_v_previous = Py_None;
17597
17598       /* "lxml/html/diff.py":849
17599  *     index = parent.index(el)
17600  *     if text:
17601  *         if index == 0:             # <<<<<<<<<<<<<<
17602  *             previous = None
17603  *         else:
17604  */
17605       goto __pyx_L9;
17606     }
17607
17608     /* "lxml/html/diff.py":852
17609  *             previous = None
17610  *         else:
17611  *             previous = parent[index-1]             # <<<<<<<<<<<<<<
17612  *         if previous is None:
17613  *             if parent.text:
17614  */
17615     /*else*/ {
17616       __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_index, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 852, __pyx_L1_error)
17617       __Pyx_GOTREF(__pyx_t_6);
17618       __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_parent, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
17619       __Pyx_GOTREF(__pyx_t_1);
17620       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17621       __pyx_v_previous = __pyx_t_1;
17622       __pyx_t_1 = 0;
17623     }
17624     __pyx_L9:;
17625
17626     /* "lxml/html/diff.py":853
17627  *         else:
17628  *             previous = parent[index-1]
17629  *         if previous is None:             # <<<<<<<<<<<<<<
17630  *             if parent.text:
17631  *                 parent.text += text
17632  */
17633     __pyx_t_4 = (__pyx_v_previous == Py_None);
17634     __pyx_t_7 = (__pyx_t_4 != 0);
17635     if (__pyx_t_7) {
17636
17637       /* "lxml/html/diff.py":854
17638  *             previous = parent[index-1]
17639  *         if previous is None:
17640  *             if parent.text:             # <<<<<<<<<<<<<<
17641  *                 parent.text += text
17642  *             else:
17643  */
17644       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent, __pyx_n_s_text); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
17645       __Pyx_GOTREF(__pyx_t_1);
17646       __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 854, __pyx_L1_error)
17647       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17648       if (__pyx_t_7) {
17649
17650         /* "lxml/html/diff.py":855
17651  *         if previous is None:
17652  *             if parent.text:
17653  *                 parent.text += text             # <<<<<<<<<<<<<<
17654  *             else:
17655  *                 parent.text = text
17656  */
17657         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent, __pyx_n_s_text); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
17658         __Pyx_GOTREF(__pyx_t_1);
17659         __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_text); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 855, __pyx_L1_error)
17660         __Pyx_GOTREF(__pyx_t_6);
17661         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17662         if (__Pyx_PyObject_SetAttrStr(__pyx_v_parent, __pyx_n_s_text, __pyx_t_6) < 0) __PYX_ERR(0, 855, __pyx_L1_error)
17663         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17664
17665         /* "lxml/html/diff.py":854
17666  *             previous = parent[index-1]
17667  *         if previous is None:
17668  *             if parent.text:             # <<<<<<<<<<<<<<
17669  *                 parent.text += text
17670  *             else:
17671  */
17672         goto __pyx_L11;
17673       }
17674
17675       /* "lxml/html/diff.py":857
17676  *                 parent.text += text
17677  *             else:
17678  *                 parent.text = text             # <<<<<<<<<<<<<<
17679  *         else:
17680  *             if previous.tail:
17681  */
17682       /*else*/ {
17683         if (__Pyx_PyObject_SetAttrStr(__pyx_v_parent, __pyx_n_s_text, __pyx_v_text) < 0) __PYX_ERR(0, 857, __pyx_L1_error)
17684       }
17685       __pyx_L11:;
17686
17687       /* "lxml/html/diff.py":853
17688  *         else:
17689  *             previous = parent[index-1]
17690  *         if previous is None:             # <<<<<<<<<<<<<<
17691  *             if parent.text:
17692  *                 parent.text += text
17693  */
17694       goto __pyx_L10;
17695     }
17696
17697     /* "lxml/html/diff.py":859
17698  *                 parent.text = text
17699  *         else:
17700  *             if previous.tail:             # <<<<<<<<<<<<<<
17701  *                 previous.tail += text
17702  *             else:
17703  */
17704     /*else*/ {
17705       __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_previous, __pyx_n_s_tail); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 859, __pyx_L1_error)
17706       __Pyx_GOTREF(__pyx_t_6);
17707       __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 859, __pyx_L1_error)
17708       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17709       if (__pyx_t_7) {
17710
17711         /* "lxml/html/diff.py":860
17712  *         else:
17713  *             if previous.tail:
17714  *                 previous.tail += text             # <<<<<<<<<<<<<<
17715  *             else:
17716  *                 previous.tail = text
17717  */
17718         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_previous, __pyx_n_s_tail); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 860, __pyx_L1_error)
17719         __Pyx_GOTREF(__pyx_t_6);
17720         __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_v_text); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 860, __pyx_L1_error)
17721         __Pyx_GOTREF(__pyx_t_1);
17722         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17723         if (__Pyx_PyObject_SetAttrStr(__pyx_v_previous, __pyx_n_s_tail, __pyx_t_1) < 0) __PYX_ERR(0, 860, __pyx_L1_error)
17724         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17725
17726         /* "lxml/html/diff.py":859
17727  *                 parent.text = text
17728  *         else:
17729  *             if previous.tail:             # <<<<<<<<<<<<<<
17730  *                 previous.tail += text
17731  *             else:
17732  */
17733         goto __pyx_L12;
17734       }
17735
17736       /* "lxml/html/diff.py":862
17737  *                 previous.tail += text
17738  *             else:
17739  *                 previous.tail = text             # <<<<<<<<<<<<<<
17740  *     parent[index:index+1] = el.getchildren()
17741  * 
17742  */
17743       /*else*/ {
17744         if (__Pyx_PyObject_SetAttrStr(__pyx_v_previous, __pyx_n_s_tail, __pyx_v_text) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
17745       }
17746       __pyx_L12:;
17747     }
17748     __pyx_L10:;
17749
17750     /* "lxml/html/diff.py":848
17751  *                 el[-1].tail = el.tail
17752  *     index = parent.index(el)
17753  *     if text:             # <<<<<<<<<<<<<<
17754  *         if index == 0:
17755  *             previous = None
17756  */
17757   }
17758
17759   /* "lxml/html/diff.py":863
17760  *             else:
17761  *                 previous.tail = text
17762  *     parent[index:index+1] = el.getchildren()             # <<<<<<<<<<<<<<
17763  * 
17764  * class InsensitiveSequenceMatcher(difflib.SequenceMatcher):
17765  */
17766   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_el, __pyx_n_s_getchildren); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 863, __pyx_L1_error)
17767   __Pyx_GOTREF(__pyx_t_6);
17768   __pyx_t_3 = NULL;
17769   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
17770     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
17771     if (likely(__pyx_t_3)) {
17772       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
17773       __Pyx_INCREF(__pyx_t_3);
17774       __Pyx_INCREF(function);
17775       __Pyx_DECREF_SET(__pyx_t_6, function);
17776     }
17777   }
17778   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
17779   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
17780   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 863, __pyx_L1_error)
17781   __Pyx_GOTREF(__pyx_t_1);
17782   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17783   __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_index, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 863, __pyx_L1_error)
17784   __Pyx_GOTREF(__pyx_t_6);
17785   if (__Pyx_PyObject_SetSlice(__pyx_v_parent, __pyx_t_1, 0, 0, &__pyx_v_index, &__pyx_t_6, NULL, 0, 0, 1) < 0) __PYX_ERR(0, 863, __pyx_L1_error)
17786   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17787   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17788
17789   /* "lxml/html/diff.py":831
17790  *         el.insert(0, text_tag)
17791  * 
17792  * def _merge_element_contents(el):             # <<<<<<<<<<<<<<
17793  *     """
17794  *     Removes an element, but merges its contents into its place, e.g.,
17795  */
17796
17797   /* function exit code */
17798   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17799   goto __pyx_L0;
17800   __pyx_L1_error:;
17801   __Pyx_XDECREF(__pyx_t_1);
17802   __Pyx_XDECREF(__pyx_t_2);
17803   __Pyx_XDECREF(__pyx_t_3);
17804   __Pyx_XDECREF(__pyx_t_6);
17805   __Pyx_AddTraceback("lxml.html.diff._merge_element_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
17806   __pyx_r = NULL;
17807   __pyx_L0:;
17808   __Pyx_XDECREF(__pyx_v_parent);
17809   __Pyx_XDECREF(__pyx_v_text);
17810   __Pyx_XDECREF(__pyx_v_index);
17811   __Pyx_XDECREF(__pyx_v_previous);
17812   __Pyx_XGIVEREF(__pyx_r);
17813   __Pyx_RefNannyFinishContext();
17814   return __pyx_r;
17815 }
17816
17817 /* "lxml/html/diff.py":873
17818  *     threshold = 2
17819  * 
17820  *     def get_matching_blocks(self):             # <<<<<<<<<<<<<<
17821  *         size = min(len(self.b), len(self.b))
17822  *         threshold = min(self.threshold, size / 4)
17823  */
17824
17825 /* Python wrapper */
17826 static PyObject *__pyx_pw_4lxml_4html_4diff_26InsensitiveSequenceMatcher_1get_matching_blocks(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
17827 static PyMethodDef __pyx_mdef_4lxml_4html_4diff_26InsensitiveSequenceMatcher_1get_matching_blocks = {"get_matching_blocks", (PyCFunction)__pyx_pw_4lxml_4html_4diff_26InsensitiveSequenceMatcher_1get_matching_blocks, METH_O, 0};
17828 static PyObject *__pyx_pw_4lxml_4html_4diff_26InsensitiveSequenceMatcher_1get_matching_blocks(PyObject *__pyx_self, PyObject *__pyx_v_self) {
17829   PyObject *__pyx_r = 0;
17830   __Pyx_RefNannyDeclarations
17831   __Pyx_RefNannySetupContext("get_matching_blocks (wrapper)", 0);
17832   __pyx_r = __pyx_pf_4lxml_4html_4diff_26InsensitiveSequenceMatcher_get_matching_blocks(__pyx_self, ((PyObject *)__pyx_v_self));
17833
17834   /* function exit code */
17835   __Pyx_RefNannyFinishContext();
17836   return __pyx_r;
17837 }
17838
17839 static PyObject *__pyx_pf_4lxml_4html_4diff_26InsensitiveSequenceMatcher_get_matching_blocks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
17840   PyObject *__pyx_v_size = NULL;
17841   PyObject *__pyx_v_threshold = NULL;
17842   PyObject *__pyx_v_actual = NULL;
17843   PyObject *__pyx_8genexpr5__pyx_v_item = NULL;
17844   PyObject *__pyx_r = NULL;
17845   __Pyx_RefNannyDeclarations
17846   PyObject *__pyx_t_1 = NULL;
17847   Py_ssize_t __pyx_t_2;
17848   Py_ssize_t __pyx_t_3;
17849   Py_ssize_t __pyx_t_4;
17850   PyObject *__pyx_t_5 = NULL;
17851   PyObject *__pyx_t_6 = NULL;
17852   PyObject *__pyx_t_7 = NULL;
17853   int __pyx_t_8;
17854   PyObject *(*__pyx_t_9)(PyObject *);
17855   int __pyx_t_10;
17856   int __pyx_t_11;
17857   int __pyx_lineno = 0;
17858   const char *__pyx_filename = NULL;
17859   int __pyx_clineno = 0;
17860   __Pyx_RefNannySetupContext("get_matching_blocks", 0);
17861
17862   /* "lxml/html/diff.py":874
17863  * 
17864  *     def get_matching_blocks(self):
17865  *         size = min(len(self.b), len(self.b))             # <<<<<<<<<<<<<<
17866  *         threshold = min(self.threshold, size / 4)
17867  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
17868  */
17869   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
17870   __Pyx_GOTREF(__pyx_t_1);
17871   __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 874, __pyx_L1_error)
17872   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17873   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
17874   __Pyx_GOTREF(__pyx_t_1);
17875   __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 874, __pyx_L1_error)
17876   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17877   if (((__pyx_t_2 < __pyx_t_3) != 0)) {
17878     __pyx_t_4 = __pyx_t_2;
17879   } else {
17880     __pyx_t_4 = __pyx_t_3;
17881   }
17882   __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
17883   __Pyx_GOTREF(__pyx_t_1);
17884   __pyx_v_size = __pyx_t_1;
17885   __pyx_t_1 = 0;
17886
17887   /* "lxml/html/diff.py":875
17888  *     def get_matching_blocks(self):
17889  *         size = min(len(self.b), len(self.b))
17890  *         threshold = min(self.threshold, size / 4)             # <<<<<<<<<<<<<<
17891  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
17892  *         return [item for item in actual
17893  */
17894   __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_size, __pyx_int_4, 4, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
17895   __Pyx_GOTREF(__pyx_t_1);
17896   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_threshold); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 875, __pyx_L1_error)
17897   __Pyx_GOTREF(__pyx_t_5);
17898   __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 875, __pyx_L1_error)
17899   __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 875, __pyx_L1_error)
17900   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17901   if (__pyx_t_8) {
17902     __Pyx_INCREF(__pyx_t_1);
17903     __pyx_t_6 = __pyx_t_1;
17904   } else {
17905     __Pyx_INCREF(__pyx_t_5);
17906     __pyx_t_6 = __pyx_t_5;
17907   }
17908   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17909   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17910   __pyx_t_1 = __pyx_t_6;
17911   __Pyx_INCREF(__pyx_t_1);
17912   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17913   __pyx_v_threshold = __pyx_t_1;
17914   __pyx_t_1 = 0;
17915
17916   /* "lxml/html/diff.py":876
17917  *         size = min(len(self.b), len(self.b))
17918  *         threshold = min(self.threshold, size / 4)
17919  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)             # <<<<<<<<<<<<<<
17920  *         return [item for item in actual
17921  *                 if item[2] > threshold
17922  */
17923   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_difflib); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
17924   __Pyx_GOTREF(__pyx_t_6);
17925   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_SequenceMatcher); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L1_error)
17926   __Pyx_GOTREF(__pyx_t_5);
17927   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17928   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_matching_blocks); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
17929   __Pyx_GOTREF(__pyx_t_6);
17930   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17931   __pyx_t_5 = NULL;
17932   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
17933     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
17934     if (likely(__pyx_t_5)) {
17935       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
17936       __Pyx_INCREF(__pyx_t_5);
17937       __Pyx_INCREF(function);
17938       __Pyx_DECREF_SET(__pyx_t_6, function);
17939     }
17940   }
17941   __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self);
17942   __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
17943   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
17944   __Pyx_GOTREF(__pyx_t_1);
17945   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17946   __pyx_v_actual = __pyx_t_1;
17947   __pyx_t_1 = 0;
17948
17949   /* "lxml/html/diff.py":877
17950  *         threshold = min(self.threshold, size / 4)
17951  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
17952  *         return [item for item in actual             # <<<<<<<<<<<<<<
17953  *                 if item[2] > threshold
17954  *                 or not item[2]]
17955  */
17956   __Pyx_XDECREF(__pyx_r);
17957   { /* enter inner scope */
17958     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 877, __pyx_L5_error)
17959     __Pyx_GOTREF(__pyx_t_1);
17960     if (likely(PyList_CheckExact(__pyx_v_actual)) || PyTuple_CheckExact(__pyx_v_actual)) {
17961       __pyx_t_6 = __pyx_v_actual; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
17962       __pyx_t_9 = NULL;
17963     } else {
17964       __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_actual); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 877, __pyx_L5_error)
17965       __Pyx_GOTREF(__pyx_t_6);
17966       __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 877, __pyx_L5_error)
17967     }
17968     for (;;) {
17969       if (likely(!__pyx_t_9)) {
17970         if (likely(PyList_CheckExact(__pyx_t_6))) {
17971           if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
17972           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17973           __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 877, __pyx_L5_error)
17974           #else
17975           __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 877, __pyx_L5_error)
17976           __Pyx_GOTREF(__pyx_t_5);
17977           #endif
17978         } else {
17979           if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
17980           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17981           __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 877, __pyx_L5_error)
17982           #else
17983           __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 877, __pyx_L5_error)
17984           __Pyx_GOTREF(__pyx_t_5);
17985           #endif
17986         }
17987       } else {
17988         __pyx_t_5 = __pyx_t_9(__pyx_t_6);
17989         if (unlikely(!__pyx_t_5)) {
17990           PyObject* exc_type = PyErr_Occurred();
17991           if (exc_type) {
17992             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
17993             else __PYX_ERR(0, 877, __pyx_L5_error)
17994           }
17995           break;
17996         }
17997         __Pyx_GOTREF(__pyx_t_5);
17998       }
17999       __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_item, __pyx_t_5);
18000       __pyx_t_5 = 0;
18001
18002       /* "lxml/html/diff.py":878
18003  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
18004  *         return [item for item in actual
18005  *                 if item[2] > threshold             # <<<<<<<<<<<<<<
18006  *                 or not item[2]]
18007  * 
18008  */
18009       __pyx_t_5 = __Pyx_GetItemInt(__pyx_8genexpr5__pyx_v_item, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 878, __pyx_L5_error)
18010       __Pyx_GOTREF(__pyx_t_5);
18011       __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_v_threshold, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 878, __pyx_L5_error)
18012       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18013       __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 878, __pyx_L5_error)
18014       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
18015       if (!__pyx_t_10) {
18016       } else {
18017         __pyx_t_8 = __pyx_t_10;
18018         goto __pyx_L9_bool_binop_done;
18019       }
18020
18021       /* "lxml/html/diff.py":879
18022  *         return [item for item in actual
18023  *                 if item[2] > threshold
18024  *                 or not item[2]]             # <<<<<<<<<<<<<<
18025  * 
18026  * if __name__ == '__main__':
18027  */
18028       __pyx_t_7 = __Pyx_GetItemInt(__pyx_8genexpr5__pyx_v_item, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 879, __pyx_L5_error)
18029       __Pyx_GOTREF(__pyx_t_7);
18030       __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 879, __pyx_L5_error)
18031       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
18032       __pyx_t_11 = ((!__pyx_t_10) != 0);
18033       __pyx_t_8 = __pyx_t_11;
18034       __pyx_L9_bool_binop_done:;
18035
18036       /* "lxml/html/diff.py":878
18037  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
18038  *         return [item for item in actual
18039  *                 if item[2] > threshold             # <<<<<<<<<<<<<<
18040  *                 or not item[2]]
18041  * 
18042  */
18043       if (__pyx_t_8) {
18044
18045         /* "lxml/html/diff.py":877
18046  *         threshold = min(self.threshold, size / 4)
18047  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
18048  *         return [item for item in actual             # <<<<<<<<<<<<<<
18049  *                 if item[2] > threshold
18050  *                 or not item[2]]
18051  */
18052         if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_8genexpr5__pyx_v_item))) __PYX_ERR(0, 877, __pyx_L5_error)
18053
18054         /* "lxml/html/diff.py":878
18055  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
18056  *         return [item for item in actual
18057  *                 if item[2] > threshold             # <<<<<<<<<<<<<<
18058  *                 or not item[2]]
18059  * 
18060  */
18061       }
18062
18063       /* "lxml/html/diff.py":877
18064  *         threshold = min(self.threshold, size / 4)
18065  *         actual = difflib.SequenceMatcher.get_matching_blocks(self)
18066  *         return [item for item in actual             # <<<<<<<<<<<<<<
18067  *                 if item[2] > threshold
18068  *                 or not item[2]]
18069  */
18070     }
18071     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18072     __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_item); __pyx_8genexpr5__pyx_v_item = 0;
18073     goto __pyx_L11_exit_scope;
18074     __pyx_L5_error:;
18075     __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_item); __pyx_8genexpr5__pyx_v_item = 0;
18076     goto __pyx_L1_error;
18077     __pyx_L11_exit_scope:;
18078   } /* exit inner scope */
18079   __pyx_r = __pyx_t_1;
18080   __pyx_t_1 = 0;
18081   goto __pyx_L0;
18082
18083   /* "lxml/html/diff.py":873
18084  *     threshold = 2
18085  * 
18086  *     def get_matching_blocks(self):             # <<<<<<<<<<<<<<
18087  *         size = min(len(self.b), len(self.b))
18088  *         threshold = min(self.threshold, size / 4)
18089  */
18090
18091   /* function exit code */
18092   __pyx_L1_error:;
18093   __Pyx_XDECREF(__pyx_t_1);
18094   __Pyx_XDECREF(__pyx_t_5);
18095   __Pyx_XDECREF(__pyx_t_6);
18096   __Pyx_XDECREF(__pyx_t_7);
18097   __Pyx_AddTraceback("lxml.html.diff.InsensitiveSequenceMatcher.get_matching_blocks", __pyx_clineno, __pyx_lineno, __pyx_filename);
18098   __pyx_r = NULL;
18099   __pyx_L0:;
18100   __Pyx_XDECREF(__pyx_v_size);
18101   __Pyx_XDECREF(__pyx_v_threshold);
18102   __Pyx_XDECREF(__pyx_v_actual);
18103   __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_item);
18104   __Pyx_XGIVEREF(__pyx_r);
18105   __Pyx_RefNannyFinishContext();
18106   return __pyx_r;
18107 }
18108
18109 static struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens[8];
18110 static int __pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens = 0;
18111
18112 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
18113   PyObject *o;
18114   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens)))) {
18115     o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens];
18116     memset(o, 0, sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens));
18117     (void) PyObject_INIT(o, t);
18118     PyObject_GC_Track(o);
18119   } else {
18120     o = (*t->tp_alloc)(t, 0);
18121     if (unlikely(!o)) return 0;
18122   }
18123   return o;
18124 }
18125
18126 static void __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens(PyObject *o) {
18127   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)o;
18128   PyObject_GC_UnTrack(o);
18129   Py_CLEAR(p->__pyx_v_html);
18130   Py_CLEAR(p->__pyx_v_markup_func);
18131   Py_CLEAR(p->__pyx_v_post);
18132   Py_CLEAR(p->__pyx_v_pre);
18133   Py_CLEAR(p->__pyx_v_token);
18134   Py_CLEAR(p->__pyx_v_tokens);
18135   Py_CLEAR(p->__pyx_t_0);
18136   Py_CLEAR(p->__pyx_t_3);
18137   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens)))) {
18138     __pyx_freelist_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens[__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens++] = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)o);
18139   } else {
18140     (*Py_TYPE(o)->tp_free)(o);
18141   }
18142 }
18143
18144 static int __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens(PyObject *o, visitproc v, void *a) {
18145   int e;
18146   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens *)o;
18147   if (p->__pyx_v_html) {
18148     e = (*v)(p->__pyx_v_html, a); if (e) return e;
18149   }
18150   if (p->__pyx_v_markup_func) {
18151     e = (*v)(p->__pyx_v_markup_func, a); if (e) return e;
18152   }
18153   if (p->__pyx_v_post) {
18154     e = (*v)(p->__pyx_v_post, a); if (e) return e;
18155   }
18156   if (p->__pyx_v_pre) {
18157     e = (*v)(p->__pyx_v_pre, a); if (e) return e;
18158   }
18159   if (p->__pyx_v_token) {
18160     e = (*v)(p->__pyx_v_token, a); if (e) return e;
18161   }
18162   if (p->__pyx_v_tokens) {
18163     e = (*v)(p->__pyx_v_tokens, a); if (e) return e;
18164   }
18165   if (p->__pyx_t_0) {
18166     e = (*v)(p->__pyx_t_0, a); if (e) return e;
18167   }
18168   if (p->__pyx_t_3) {
18169     e = (*v)(p->__pyx_t_3, a); if (e) return e;
18170   }
18171   return 0;
18172 }
18173
18174 static PyTypeObject __pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens = {
18175   PyVarObject_HEAD_INIT(0, 0)
18176   "lxml.html.diff.__pyx_scope_struct__markup_serialize_tokens", /*tp_name*/
18177   sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens), /*tp_basicsize*/
18178   0, /*tp_itemsize*/
18179   __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens, /*tp_dealloc*/
18180   #if PY_VERSION_HEX < 0x030800b4
18181   0, /*tp_print*/
18182   #endif
18183   #if PY_VERSION_HEX >= 0x030800b4
18184   0, /*tp_vectorcall_offset*/
18185   #endif
18186   0, /*tp_getattr*/
18187   0, /*tp_setattr*/
18188   #if PY_MAJOR_VERSION < 3
18189   0, /*tp_compare*/
18190   #endif
18191   #if PY_MAJOR_VERSION >= 3
18192   0, /*tp_as_async*/
18193   #endif
18194   0, /*tp_repr*/
18195   0, /*tp_as_number*/
18196   0, /*tp_as_sequence*/
18197   0, /*tp_as_mapping*/
18198   0, /*tp_hash*/
18199   0, /*tp_call*/
18200   0, /*tp_str*/
18201   0, /*tp_getattro*/
18202   0, /*tp_setattro*/
18203   0, /*tp_as_buffer*/
18204   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
18205   0, /*tp_doc*/
18206   __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens, /*tp_traverse*/
18207   0, /*tp_clear*/
18208   0, /*tp_richcompare*/
18209   0, /*tp_weaklistoffset*/
18210   0, /*tp_iter*/
18211   0, /*tp_iternext*/
18212   0, /*tp_methods*/
18213   0, /*tp_members*/
18214   0, /*tp_getset*/
18215   0, /*tp_base*/
18216   0, /*tp_dict*/
18217   0, /*tp_descr_get*/
18218   0, /*tp_descr_set*/
18219   0, /*tp_dictoffset*/
18220   0, /*tp_init*/
18221   0, /*tp_alloc*/
18222   __pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens, /*tp_new*/
18223   0, /*tp_free*/
18224   0, /*tp_is_gc*/
18225   0, /*tp_bases*/
18226   0, /*tp_mro*/
18227   0, /*tp_cache*/
18228   0, /*tp_subclasses*/
18229   0, /*tp_weaklist*/
18230   0, /*tp_del*/
18231   0, /*tp_version_tag*/
18232   #if PY_VERSION_HEX >= 0x030400a1
18233   0, /*tp_finalize*/
18234   #endif
18235   #if PY_VERSION_HEX >= 0x030800b1
18236   0, /*tp_vectorcall*/
18237   #endif
18238   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
18239   0, /*tp_print*/
18240   #endif
18241 };
18242
18243 static struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens[8];
18244 static int __pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens = 0;
18245
18246 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
18247   PyObject *o;
18248   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens)))) {
18249     o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens];
18250     memset(o, 0, sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens));
18251     (void) PyObject_INIT(o, t);
18252     PyObject_GC_Track(o);
18253   } else {
18254     o = (*t->tp_alloc)(t, 0);
18255     if (unlikely(!o)) return 0;
18256   }
18257   return o;
18258 }
18259
18260 static void __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens(PyObject *o) {
18261   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)o;
18262   PyObject_GC_UnTrack(o);
18263   Py_CLEAR(p->__pyx_v_equal);
18264   Py_CLEAR(p->__pyx_v_post);
18265   Py_CLEAR(p->__pyx_v_pre);
18266   Py_CLEAR(p->__pyx_v_token);
18267   Py_CLEAR(p->__pyx_v_tokens);
18268   Py_CLEAR(p->__pyx_t_0);
18269   Py_CLEAR(p->__pyx_t_3);
18270   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens)))) {
18271     __pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens[__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens++] = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)o);
18272   } else {
18273     (*Py_TYPE(o)->tp_free)(o);
18274   }
18275 }
18276
18277 static int __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens(PyObject *o, visitproc v, void *a) {
18278   int e;
18279   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens *)o;
18280   if (p->__pyx_v_equal) {
18281     e = (*v)(p->__pyx_v_equal, a); if (e) return e;
18282   }
18283   if (p->__pyx_v_post) {
18284     e = (*v)(p->__pyx_v_post, a); if (e) return e;
18285   }
18286   if (p->__pyx_v_pre) {
18287     e = (*v)(p->__pyx_v_pre, a); if (e) return e;
18288   }
18289   if (p->__pyx_v_token) {
18290     e = (*v)(p->__pyx_v_token, a); if (e) return e;
18291   }
18292   if (p->__pyx_v_tokens) {
18293     e = (*v)(p->__pyx_v_tokens, a); if (e) return e;
18294   }
18295   if (p->__pyx_t_0) {
18296     e = (*v)(p->__pyx_t_0, a); if (e) return e;
18297   }
18298   if (p->__pyx_t_3) {
18299     e = (*v)(p->__pyx_t_3, a); if (e) return e;
18300   }
18301   return 0;
18302 }
18303
18304 static PyTypeObject __pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens = {
18305   PyVarObject_HEAD_INIT(0, 0)
18306   "lxml.html.diff.__pyx_scope_struct_1_expand_tokens", /*tp_name*/
18307   sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens), /*tp_basicsize*/
18308   0, /*tp_itemsize*/
18309   __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens, /*tp_dealloc*/
18310   #if PY_VERSION_HEX < 0x030800b4
18311   0, /*tp_print*/
18312   #endif
18313   #if PY_VERSION_HEX >= 0x030800b4
18314   0, /*tp_vectorcall_offset*/
18315   #endif
18316   0, /*tp_getattr*/
18317   0, /*tp_setattr*/
18318   #if PY_MAJOR_VERSION < 3
18319   0, /*tp_compare*/
18320   #endif
18321   #if PY_MAJOR_VERSION >= 3
18322   0, /*tp_as_async*/
18323   #endif
18324   0, /*tp_repr*/
18325   0, /*tp_as_number*/
18326   0, /*tp_as_sequence*/
18327   0, /*tp_as_mapping*/
18328   0, /*tp_hash*/
18329   0, /*tp_call*/
18330   0, /*tp_str*/
18331   0, /*tp_getattro*/
18332   0, /*tp_setattro*/
18333   0, /*tp_as_buffer*/
18334   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
18335   0, /*tp_doc*/
18336   __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens, /*tp_traverse*/
18337   0, /*tp_clear*/
18338   0, /*tp_richcompare*/
18339   0, /*tp_weaklistoffset*/
18340   0, /*tp_iter*/
18341   0, /*tp_iternext*/
18342   0, /*tp_methods*/
18343   0, /*tp_members*/
18344   0, /*tp_getset*/
18345   0, /*tp_base*/
18346   0, /*tp_dict*/
18347   0, /*tp_descr_get*/
18348   0, /*tp_descr_set*/
18349   0, /*tp_dictoffset*/
18350   0, /*tp_init*/
18351   0, /*tp_alloc*/
18352   __pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens, /*tp_new*/
18353   0, /*tp_free*/
18354   0, /*tp_is_gc*/
18355   0, /*tp_bases*/
18356   0, /*tp_mro*/
18357   0, /*tp_cache*/
18358   0, /*tp_subclasses*/
18359   0, /*tp_weaklist*/
18360   0, /*tp_del*/
18361   0, /*tp_version_tag*/
18362   #if PY_VERSION_HEX >= 0x030400a1
18363   0, /*tp_finalize*/
18364   #endif
18365   #if PY_VERSION_HEX >= 0x030800b1
18366   0, /*tp_vectorcall*/
18367   #endif
18368   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
18369   0, /*tp_print*/
18370   #endif
18371 };
18372
18373 static struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el[8];
18374 static int __pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el = 0;
18375
18376 static PyObject *__pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
18377   PyObject *o;
18378   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el)))) {
18379     o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el];
18380     memset(o, 0, sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el));
18381     (void) PyObject_INIT(o, t);
18382     PyObject_GC_Track(o);
18383   } else {
18384     o = (*t->tp_alloc)(t, 0);
18385     if (unlikely(!o)) return 0;
18386   }
18387   return o;
18388 }
18389
18390 static void __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el(PyObject *o) {
18391   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)o;
18392   PyObject_GC_UnTrack(o);
18393   Py_CLEAR(p->__pyx_v_child);
18394   Py_CLEAR(p->__pyx_v_el);
18395   Py_CLEAR(p->__pyx_v_end_words);
18396   Py_CLEAR(p->__pyx_v_include_hrefs);
18397   Py_CLEAR(p->__pyx_v_item);
18398   Py_CLEAR(p->__pyx_v_skip_tag);
18399   Py_CLEAR(p->__pyx_v_start_words);
18400   Py_CLEAR(p->__pyx_v_word);
18401   Py_CLEAR(p->__pyx_t_0);
18402   Py_CLEAR(p->__pyx_t_3);
18403   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el)))) {
18404     __pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el[__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el++] = ((struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)o);
18405   } else {
18406     (*Py_TYPE(o)->tp_free)(o);
18407   }
18408 }
18409
18410 static int __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el(PyObject *o, visitproc v, void *a) {
18411   int e;
18412   struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *p = (struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el *)o;
18413   if (p->__pyx_v_child) {
18414     e = (*v)(p->__pyx_v_child, a); if (e) return e;
18415   }
18416   if (p->__pyx_v_el) {
18417     e = (*v)(p->__pyx_v_el, a); if (e) return e;
18418   }
18419   if (p->__pyx_v_end_words) {
18420     e = (*v)(p->__pyx_v_end_words, a); if (e) return e;
18421   }
18422   if (p->__pyx_v_include_hrefs) {
18423     e = (*v)(p->__pyx_v_include_hrefs, a); if (e) return e;
18424   }
18425   if (p->__pyx_v_item) {
18426     e = (*v)(p->__pyx_v_item, a); if (e) return e;
18427   }
18428   if (p->__pyx_v_skip_tag) {
18429     e = (*v)(p->__pyx_v_skip_tag, a); if (e) return e;
18430   }
18431   if (p->__pyx_v_start_words) {
18432     e = (*v)(p->__pyx_v_start_words, a); if (e) return e;
18433   }
18434   if (p->__pyx_v_word) {
18435     e = (*v)(p->__pyx_v_word, a); if (e) return e;
18436   }
18437   if (p->__pyx_t_0) {
18438     e = (*v)(p->__pyx_t_0, a); if (e) return e;
18439   }
18440   if (p->__pyx_t_3) {
18441     e = (*v)(p->__pyx_t_3, a); if (e) return e;
18442   }
18443   return 0;
18444 }
18445
18446 static PyTypeObject __pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el = {
18447   PyVarObject_HEAD_INIT(0, 0)
18448   "lxml.html.diff.__pyx_scope_struct_2_flatten_el", /*tp_name*/
18449   sizeof(struct __pyx_obj_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el), /*tp_basicsize*/
18450   0, /*tp_itemsize*/
18451   __pyx_tp_dealloc_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el, /*tp_dealloc*/
18452   #if PY_VERSION_HEX < 0x030800b4
18453   0, /*tp_print*/
18454   #endif
18455   #if PY_VERSION_HEX >= 0x030800b4
18456   0, /*tp_vectorcall_offset*/
18457   #endif
18458   0, /*tp_getattr*/
18459   0, /*tp_setattr*/
18460   #if PY_MAJOR_VERSION < 3
18461   0, /*tp_compare*/
18462   #endif
18463   #if PY_MAJOR_VERSION >= 3
18464   0, /*tp_as_async*/
18465   #endif
18466   0, /*tp_repr*/
18467   0, /*tp_as_number*/
18468   0, /*tp_as_sequence*/
18469   0, /*tp_as_mapping*/
18470   0, /*tp_hash*/
18471   0, /*tp_call*/
18472   0, /*tp_str*/
18473   0, /*tp_getattro*/
18474   0, /*tp_setattro*/
18475   0, /*tp_as_buffer*/
18476   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
18477   0, /*tp_doc*/
18478   __pyx_tp_traverse_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el, /*tp_traverse*/
18479   0, /*tp_clear*/
18480   0, /*tp_richcompare*/
18481   0, /*tp_weaklistoffset*/
18482   0, /*tp_iter*/
18483   0, /*tp_iternext*/
18484   0, /*tp_methods*/
18485   0, /*tp_members*/
18486   0, /*tp_getset*/
18487   0, /*tp_base*/
18488   0, /*tp_dict*/
18489   0, /*tp_descr_get*/
18490   0, /*tp_descr_set*/
18491   0, /*tp_dictoffset*/
18492   0, /*tp_init*/
18493   0, /*tp_alloc*/
18494   __pyx_tp_new_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el, /*tp_new*/
18495   0, /*tp_free*/
18496   0, /*tp_is_gc*/
18497   0, /*tp_bases*/
18498   0, /*tp_mro*/
18499   0, /*tp_cache*/
18500   0, /*tp_subclasses*/
18501   0, /*tp_weaklist*/
18502   0, /*tp_del*/
18503   0, /*tp_version_tag*/
18504   #if PY_VERSION_HEX >= 0x030400a1
18505   0, /*tp_finalize*/
18506   #endif
18507   #if PY_VERSION_HEX >= 0x030800b1
18508   0, /*tp_vectorcall*/
18509   #endif
18510   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
18511   0, /*tp_print*/
18512   #endif
18513 };
18514
18515 static PyMethodDef __pyx_methods[] = {
18516   {0, 0, 0, 0}
18517 };
18518
18519 #if PY_MAJOR_VERSION >= 3
18520 #if CYTHON_PEP489_MULTI_PHASE_INIT
18521 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
18522 static int __pyx_pymod_exec_diff(PyObject* module); /*proto*/
18523 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
18524   {Py_mod_create, (void*)__pyx_pymod_create},
18525   {Py_mod_exec, (void*)__pyx_pymod_exec_diff},
18526   {0, NULL}
18527 };
18528 #endif
18529
18530 static struct PyModuleDef __pyx_moduledef = {
18531     PyModuleDef_HEAD_INIT,
18532     "diff",
18533     0, /* m_doc */
18534   #if CYTHON_PEP489_MULTI_PHASE_INIT
18535     0, /* m_size */
18536   #else
18537     -1, /* m_size */
18538   #endif
18539     __pyx_methods /* m_methods */,
18540   #if CYTHON_PEP489_MULTI_PHASE_INIT
18541     __pyx_moduledef_slots, /* m_slots */
18542   #else
18543     NULL, /* m_reload */
18544   #endif
18545     NULL, /* m_traverse */
18546     NULL, /* m_clear */
18547     (freefunc)__pyx_module_cleanup /* m_free */
18548 };
18549 #endif
18550 #ifndef CYTHON_SMALL_CODE
18551 #if defined(__clang__)
18552     #define CYTHON_SMALL_CODE
18553 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
18554     #define CYTHON_SMALL_CODE __attribute__((cold))
18555 #else
18556     #define CYTHON_SMALL_CODE
18557 #endif
18558 #endif
18559
18560 static __Pyx_StringTabEntry __pyx_string_tab[] = {
18561   {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
18562   {&__pyx_kp_s_Acts_like_SequenceMatcher_but_t, __pyx_k_Acts_like_SequenceMatcher_but_t, sizeof(__pyx_k_Acts_like_SequenceMatcher_but_t), 0, 0, 1, 0},
18563   {&__pyx_n_s_DEL_END, __pyx_k_DEL_END, sizeof(__pyx_k_DEL_END), 0, 0, 1, 1},
18564   {&__pyx_n_s_DEL_START, __pyx_k_DEL_START, sizeof(__pyx_k_DEL_START), 0, 0, 1, 1},
18565   {&__pyx_n_s_Element, __pyx_k_Element, sizeof(__pyx_k_Element), 0, 0, 1, 1},
18566   {&__pyx_n_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 1},
18567   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
18568   {&__pyx_n_s_InsensitiveSequenceMatcher, __pyx_k_InsensitiveSequenceMatcher, sizeof(__pyx_k_InsensitiveSequenceMatcher), 0, 0, 1, 1},
18569   {&__pyx_n_s_InsensitiveSequenceMatcher_get_m, __pyx_k_InsensitiveSequenceMatcher_get_m, sizeof(__pyx_k_InsensitiveSequenceMatcher_get_m), 0, 0, 1, 1},
18570   {&__pyx_kp_u_Link_s, __pyx_k_Link_s, sizeof(__pyx_k_Link_s), 0, 1, 0, 0},
18571   {&__pyx_n_s_NameError, __pyx_k_NameError, sizeof(__pyx_k_NameError), 0, 0, 1, 1},
18572   {&__pyx_n_s_NoDeletes, __pyx_k_NoDeletes, sizeof(__pyx_k_NoDeletes), 0, 0, 1, 1},
18573   {&__pyx_kp_s_Raised_when_the_document_no_lon, __pyx_k_Raised_when_the_document_no_lon, sizeof(__pyx_k_Raised_when_the_document_no_lon), 0, 0, 1, 0},
18574   {&__pyx_kp_s_Represents_a_diffable_token_gen, __pyx_k_Represents_a_diffable_token_gen, sizeof(__pyx_k_Represents_a_diffable_token_gen), 0, 0, 1, 0},
18575   {&__pyx_kp_s_Represents_a_token_that_is_actu, __pyx_k_Represents_a_token_that_is_actu, sizeof(__pyx_k_Represents_a_token_that_is_actu), 0, 0, 1, 0},
18576   {&__pyx_kp_s_Represents_the_href_in_an_ancho, __pyx_k_Represents_the_href_in_an_ancho, sizeof(__pyx_k_Represents_the_href_in_an_ancho), 0, 0, 1, 0},
18577   {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1},
18578   {&__pyx_kp_u_S_s, __pyx_k_S_s, sizeof(__pyx_k_S_s), 0, 1, 0, 0},
18579   {&__pyx_n_s_SequenceMatcher, __pyx_k_SequenceMatcher, sizeof(__pyx_k_SequenceMatcher), 0, 0, 1, 1},
18580   {&__pyx_n_s_U, __pyx_k_U, sizeof(__pyx_k_U), 0, 0, 1, 1},
18581   {&__pyx_kp_u_Unexpected_delete_tag_r, __pyx_k_Unexpected_delete_tag_r, sizeof(__pyx_k_Unexpected_delete_tag_r), 0, 1, 0, 0},
18582   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
18583   {&__pyx_kp_u_Weird_state_cur_word, __pyx_k_Weird_state_cur_word, sizeof(__pyx_k_Weird_state_cur_word), 0, 1, 0, 0},
18584   {&__pyx_kp_u_You_should_pass_in_an_element_no, __pyx_k_You_should_pass_in_an_element_no, sizeof(__pyx_k_You_should_pass_in_an_element_no), 0, 1, 0, 0},
18585   {&__pyx_kp_u__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 1, 0, 0},
18586   {&__pyx_kp_u__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 1, 0, 0},
18587   {&__pyx_kp_u__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 1, 0, 0},
18588   {&__pyx_kp_u__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 1, 0, 0},
18589   {&__pyx_kp_u__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 1, 0, 0},
18590   {&__pyx_kp_u__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 1, 0, 0},
18591   {&__pyx_kp_u__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 1, 0, 0},
18592   {&__pyx_kp_u__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 1, 0, 0},
18593   {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
18594   {&__pyx_kp_u__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 1, 0, 0},
18595   {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
18596   {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0},
18597   {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0},
18598   {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
18599   {&__pyx_n_u_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 1, 0, 1},
18600   {&__pyx_n_s_actual, __pyx_k_actual, sizeof(__pyx_k_actual), 0, 0, 1, 1},
18601   {&__pyx_n_u_address, __pyx_k_address, sizeof(__pyx_k_address), 0, 1, 0, 1},
18602   {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
18603   {&__pyx_n_s_annotation, __pyx_k_annotation, sizeof(__pyx_k_annotation), 0, 0, 1, 1},
18604   {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
18605   {&__pyx_n_u_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 1, 0, 1},
18606   {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
18607   {&__pyx_n_s_attrib, __pyx_k_attrib, sizeof(__pyx_k_attrib), 0, 0, 1, 1},
18608   {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
18609   {&__pyx_n_s_balanced, __pyx_k_balanced, sizeof(__pyx_k_balanced), 0, 0, 1, 1},
18610   {&__pyx_n_u_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 1, 0, 1},
18611   {&__pyx_n_u_basefont, __pyx_k_basefont, sizeof(__pyx_k_basefont), 0, 1, 0, 1},
18612   {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1},
18613   {&__pyx_n_s_block_level_container_tags, __pyx_k_block_level_container_tags, sizeof(__pyx_k_block_level_container_tags), 0, 0, 1, 1},
18614   {&__pyx_n_s_block_level_tags, __pyx_k_block_level_tags, sizeof(__pyx_k_block_level_tags), 0, 0, 1, 1},
18615   {&__pyx_n_u_blockquote, __pyx_k_blockquote, sizeof(__pyx_k_blockquote), 0, 1, 0, 1},
18616   {&__pyx_kp_u_body, __pyx_k_body, sizeof(__pyx_k_body), 0, 1, 0, 0},
18617   {&__pyx_kp_u_body_2, __pyx_k_body_2, sizeof(__pyx_k_body_2), 0, 1, 0, 0},
18618   {&__pyx_n_s_body_el, __pyx_k_body_el, sizeof(__pyx_k_body_el), 0, 0, 1, 1},
18619   {&__pyx_n_s_body_re, __pyx_k_body_re, sizeof(__pyx_k_body_re), 0, 0, 1, 1},
18620   {&__pyx_n_u_br, __pyx_k_br, sizeof(__pyx_k_br), 0, 1, 0, 1},
18621   {&__pyx_n_u_center, __pyx_k_center, sizeof(__pyx_k_center), 0, 1, 0, 1},
18622   {&__pyx_n_s_cgi, __pyx_k_cgi, sizeof(__pyx_k_cgi), 0, 0, 1, 1},
18623   {&__pyx_n_s_child, __pyx_k_child, sizeof(__pyx_k_child), 0, 0, 1, 1},
18624   {&__pyx_n_s_child_tag, __pyx_k_child_tag, sizeof(__pyx_k_child_tag), 0, 0, 1, 1},
18625   {&__pyx_n_s_children_tag, __pyx_k_children_tag, sizeof(__pyx_k_children_tag), 0, 0, 1, 1},
18626   {&__pyx_n_s_chunk, __pyx_k_chunk, sizeof(__pyx_k_chunk), 0, 0, 1, 1},
18627   {&__pyx_kp_u_chunks, __pyx_k_chunks, sizeof(__pyx_k_chunks), 0, 1, 0, 0},
18628   {&__pyx_n_s_chunks_2, __pyx_k_chunks_2, sizeof(__pyx_k_chunks_2), 0, 0, 1, 1},
18629   {&__pyx_n_s_cleanup, __pyx_k_cleanup, sizeof(__pyx_k_cleanup), 0, 0, 1, 1},
18630   {&__pyx_n_s_cleanup_delete, __pyx_k_cleanup_delete, sizeof(__pyx_k_cleanup_delete), 0, 0, 1, 1},
18631   {&__pyx_n_s_cleanup_html, __pyx_k_cleanup_html, sizeof(__pyx_k_cleanup_html), 0, 0, 1, 1},
18632   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
18633   {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
18634   {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
18635   {&__pyx_n_u_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 1, 0, 1},
18636   {&__pyx_n_s_command, __pyx_k_command, sizeof(__pyx_k_command), 0, 0, 1, 1},
18637   {&__pyx_n_s_commands, __pyx_k_commands, sizeof(__pyx_k_commands), 0, 0, 1, 1},
18638   {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
18639   {&__pyx_n_s_compress_merge_back, __pyx_k_compress_merge_back, sizeof(__pyx_k_compress_merge_back), 0, 0, 1, 1},
18640   {&__pyx_n_s_compress_tokens, __pyx_k_compress_tokens, sizeof(__pyx_k_compress_tokens), 0, 0, 1, 1},
18641   {&__pyx_n_s_contains_block_level_tag, __pyx_k_contains_block_level_tag, sizeof(__pyx_k_contains_block_level_tag), 0, 0, 1, 1},
18642   {&__pyx_n_s_copy_annotations, __pyx_k_copy_annotations, sizeof(__pyx_k_copy_annotations), 0, 0, 1, 1},
18643   {&__pyx_n_s_create_parent, __pyx_k_create_parent, sizeof(__pyx_k_create_parent), 0, 0, 1, 1},
18644   {&__pyx_n_s_cur_tokens, __pyx_k_cur_tokens, sizeof(__pyx_k_cur_tokens), 0, 0, 1, 1},
18645   {&__pyx_n_s_cur_word, __pyx_k_cur_word, sizeof(__pyx_k_cur_word), 0, 0, 1, 1},
18646   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
18647   {&__pyx_n_u_dd, __pyx_k_dd, sizeof(__pyx_k_dd), 0, 1, 0, 1},
18648   {&__pyx_n_s_default_markup, __pyx_k_default_markup, sizeof(__pyx_k_default_markup), 0, 0, 1, 1},
18649   {&__pyx_kp_u_del, __pyx_k_del, sizeof(__pyx_k_del), 0, 1, 0, 0},
18650   {&__pyx_kp_u_del_2, __pyx_k_del_2, sizeof(__pyx_k_del_2), 0, 1, 0, 0},
18651   {&__pyx_n_u_del_3, __pyx_k_del_3, sizeof(__pyx_k_del_3), 0, 1, 0, 1},
18652   {&__pyx_n_s_del_chunks, __pyx_k_del_chunks, sizeof(__pyx_k_del_chunks), 0, 0, 1, 1},
18653   {&__pyx_n_s_del_tokens, __pyx_k_del_tokens, sizeof(__pyx_k_del_tokens), 0, 0, 1, 1},
18654   {&__pyx_n_s_delete, __pyx_k_delete, sizeof(__pyx_k_delete), 0, 0, 1, 1},
18655   {&__pyx_n_u_delete, __pyx_k_delete, sizeof(__pyx_k_delete), 0, 1, 0, 1},
18656   {&__pyx_kp_u_descendant_or_self_s, __pyx_k_descendant_or_self_s, sizeof(__pyx_k_descendant_or_self_s), 0, 1, 0, 0},
18657   {&__pyx_n_s_dest, __pyx_k_dest, sizeof(__pyx_k_dest), 0, 0, 1, 1},
18658   {&__pyx_n_s_dest_tok, __pyx_k_dest_tok, sizeof(__pyx_k_dest_tok), 0, 0, 1, 1},
18659   {&__pyx_n_s_diffcommand, __pyx_k_diffcommand, sizeof(__pyx_k_diffcommand), 0, 0, 1, 1},
18660   {&__pyx_n_s_difflib, __pyx_k_difflib, sizeof(__pyx_k_difflib), 0, 0, 1, 1},
18661   {&__pyx_n_u_dir, __pyx_k_dir, sizeof(__pyx_k_dir), 0, 1, 0, 1},
18662   {&__pyx_n_u_div, __pyx_k_div, sizeof(__pyx_k_div), 0, 1, 0, 1},
18663   {&__pyx_n_u_dl, __pyx_k_dl, sizeof(__pyx_k_dl), 0, 1, 0, 1},
18664   {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
18665   {&__pyx_n_s_doc_2, __pyx_k_doc_2, sizeof(__pyx_k_doc_2), 0, 0, 1, 1},
18666   {&__pyx_n_s_doclist, __pyx_k_doclist, sizeof(__pyx_k_doclist), 0, 0, 1, 1},
18667   {&__pyx_kp_u_doclist_should_be_ordered_from, __pyx_k_doclist_should_be_ordered_from, sizeof(__pyx_k_doclist_should_be_ordered_from), 0, 1, 0, 0},
18668   {&__pyx_n_s_drop_tag, __pyx_k_drop_tag, sizeof(__pyx_k_drop_tag), 0, 0, 1, 1},
18669   {&__pyx_n_u_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 1, 0, 1},
18670   {&__pyx_n_s_el, __pyx_k_el, sizeof(__pyx_k_el), 0, 0, 1, 1},
18671   {&__pyx_n_s_empty_tags, __pyx_k_empty_tags, sizeof(__pyx_k_empty_tags), 0, 0, 1, 1},
18672   {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
18673   {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
18674   {&__pyx_n_s_end_body_re, __pyx_k_end_body_re, sizeof(__pyx_k_end_body_re), 0, 0, 1, 1},
18675   {&__pyx_n_s_end_tag, __pyx_k_end_tag, sizeof(__pyx_k_end_tag), 0, 0, 1, 1},
18676   {&__pyx_n_s_end_whitespace_re, __pyx_k_end_whitespace_re, sizeof(__pyx_k_end_whitespace_re), 0, 0, 1, 1},
18677   {&__pyx_n_s_end_words, __pyx_k_end_words, sizeof(__pyx_k_end_words), 0, 0, 1, 1},
18678   {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
18679   {&__pyx_n_s_endtag, __pyx_k_endtag, sizeof(__pyx_k_endtag), 0, 0, 1, 1},
18680   {&__pyx_n_s_eq_new, __pyx_k_eq_new, sizeof(__pyx_k_eq_new), 0, 0, 1, 1},
18681   {&__pyx_n_s_eq_old, __pyx_k_eq_old, sizeof(__pyx_k_eq_old), 0, 0, 1, 1},
18682   {&__pyx_n_s_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 0, 1, 1},
18683   {&__pyx_n_u_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 1, 0, 1},
18684   {&__pyx_n_s_escape, __pyx_k_escape, sizeof(__pyx_k_escape), 0, 0, 1, 1},
18685   {&__pyx_n_s_etree, __pyx_k_etree, sizeof(__pyx_k_etree), 0, 0, 1, 1},
18686   {&__pyx_n_s_expand_tokens, __pyx_k_expand_tokens, sizeof(__pyx_k_expand_tokens), 0, 0, 1, 1},
18687   {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
18688   {&__pyx_n_s_extra, __pyx_k_extra, sizeof(__pyx_k_extra), 0, 0, 1, 1},
18689   {&__pyx_n_u_fieldset, __pyx_k_fieldset, sizeof(__pyx_k_fieldset), 0, 1, 0, 1},
18690   {&__pyx_n_s_find, __pyx_k_find, sizeof(__pyx_k_find), 0, 0, 1, 1},
18691   {&__pyx_n_s_findall, __pyx_k_findall, sizeof(__pyx_k_findall), 0, 0, 1, 1},
18692   {&__pyx_n_s_finding, __pyx_k_finding, sizeof(__pyx_k_finding), 0, 0, 1, 1},
18693   {&__pyx_n_s_finding_name, __pyx_k_finding_name, sizeof(__pyx_k_finding_name), 0, 0, 1, 1},
18694   {&__pyx_n_s_fixup_chunks, __pyx_k_fixup_chunks, sizeof(__pyx_k_fixup_chunks), 0, 0, 1, 1},
18695   {&__pyx_n_s_fixup_ins_del_tags, __pyx_k_fixup_ins_del_tags, sizeof(__pyx_k_fixup_ins_del_tags), 0, 0, 1, 1},
18696   {&__pyx_n_s_fixup_ins_del_tags_2, __pyx_k_fixup_ins_del_tags_2, sizeof(__pyx_k_fixup_ins_del_tags_2), 0, 0, 1, 1},
18697   {&__pyx_n_s_flatten_el, __pyx_k_flatten_el, sizeof(__pyx_k_flatten_el), 0, 0, 1, 1},
18698   {&__pyx_n_u_form, __pyx_k_form, sizeof(__pyx_k_form), 0, 1, 0, 1},
18699   {&__pyx_n_s_fragment_fromstring, __pyx_k_fragment_fromstring, sizeof(__pyx_k_fragment_fromstring), 0, 0, 1, 1},
18700   {&__pyx_n_u_frameset, __pyx_k_frameset, sizeof(__pyx_k_frameset), 0, 1, 0, 1},
18701   {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
18702   {&__pyx_n_s_get_matching_blocks, __pyx_k_get_matching_blocks, sizeof(__pyx_k_get_matching_blocks), 0, 0, 1, 1},
18703   {&__pyx_n_s_get_opcodes, __pyx_k_get_opcodes, sizeof(__pyx_k_get_opcodes), 0, 0, 1, 1},
18704   {&__pyx_n_s_getchildren, __pyx_k_getchildren, sizeof(__pyx_k_getchildren), 0, 0, 1, 1},
18705   {&__pyx_n_s_getparent, __pyx_k_getparent, sizeof(__pyx_k_getparent), 0, 0, 1, 1},
18706   {&__pyx_n_u_h1, __pyx_k_h1, sizeof(__pyx_k_h1), 0, 1, 0, 1},
18707   {&__pyx_n_u_h2, __pyx_k_h2, sizeof(__pyx_k_h2), 0, 1, 0, 1},
18708   {&__pyx_n_u_h3, __pyx_k_h3, sizeof(__pyx_k_h3), 0, 1, 0, 1},
18709   {&__pyx_n_u_h4, __pyx_k_h4, sizeof(__pyx_k_h4), 0, 1, 0, 1},
18710   {&__pyx_n_u_h5, __pyx_k_h5, sizeof(__pyx_k_h5), 0, 1, 0, 1},
18711   {&__pyx_n_u_h6, __pyx_k_h6, sizeof(__pyx_k_h6), 0, 1, 0, 1},
18712   {&__pyx_n_s_hide_when_equal, __pyx_k_hide_when_equal, sizeof(__pyx_k_hide_when_equal), 0, 0, 1, 1},
18713   {&__pyx_n_u_hr, __pyx_k_hr, sizeof(__pyx_k_hr), 0, 1, 0, 1},
18714   {&__pyx_n_s_href, __pyx_k_href, sizeof(__pyx_k_href), 0, 0, 1, 1},
18715   {&__pyx_n_u_href, __pyx_k_href, sizeof(__pyx_k_href), 0, 1, 0, 1},
18716   {&__pyx_n_s_href_token, __pyx_k_href_token, sizeof(__pyx_k_href_token), 0, 0, 1, 1},
18717   {&__pyx_n_s_href_token_html, __pyx_k_href_token_html, sizeof(__pyx_k_href_token_html), 0, 0, 1, 1},
18718   {&__pyx_n_s_html, __pyx_k_html, sizeof(__pyx_k_html), 0, 0, 1, 1},
18719   {&__pyx_n_u_html, __pyx_k_html, sizeof(__pyx_k_html), 0, 1, 0, 1},
18720   {&__pyx_n_s_html1_tokens, __pyx_k_html1_tokens, sizeof(__pyx_k_html1_tokens), 0, 0, 1, 1},
18721   {&__pyx_n_s_html2_tokens, __pyx_k_html2_tokens, sizeof(__pyx_k_html2_tokens), 0, 0, 1, 1},
18722   {&__pyx_n_s_html_annotate, __pyx_k_html_annotate, sizeof(__pyx_k_html_annotate), 0, 0, 1, 1},
18723   {&__pyx_n_u_html_annotate, __pyx_k_html_annotate, sizeof(__pyx_k_html_annotate), 0, 1, 0, 1},
18724   {&__pyx_kp_u_html_annotate_line_35, __pyx_k_html_annotate_line_35, sizeof(__pyx_k_html_annotate_line_35), 0, 1, 0, 0},
18725   {&__pyx_n_s_html_annotate_merge_annotations, __pyx_k_html_annotate_merge_annotations, sizeof(__pyx_k_html_annotate_merge_annotations), 0, 0, 1, 1},
18726   {&__pyx_n_s_html_escape, __pyx_k_html_escape, sizeof(__pyx_k_html_escape), 0, 0, 1, 1},
18727   {&__pyx_n_s_html_repr, __pyx_k_html_repr, sizeof(__pyx_k_html_repr), 0, 0, 1, 1},
18728   {&__pyx_kp_u_html_repr_2, __pyx_k_html_repr_2, sizeof(__pyx_k_html_repr_2), 0, 1, 0, 0},
18729   {&__pyx_n_s_htmldiff, __pyx_k_htmldiff, sizeof(__pyx_k_htmldiff), 0, 0, 1, 1},
18730   {&__pyx_n_u_htmldiff, __pyx_k_htmldiff, sizeof(__pyx_k_htmldiff), 0, 1, 0, 1},
18731   {&__pyx_n_s_htmldiff_tokens, __pyx_k_htmldiff_tokens, sizeof(__pyx_k_htmldiff_tokens), 0, 0, 1, 1},
18732   {&__pyx_n_s_i1, __pyx_k_i1, sizeof(__pyx_k_i1), 0, 0, 1, 1},
18733   {&__pyx_n_s_i2, __pyx_k_i2, sizeof(__pyx_k_i2), 0, 0, 1, 1},
18734   {&__pyx_n_u_img, __pyx_k_img, sizeof(__pyx_k_img), 0, 1, 0, 1},
18735   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
18736   {&__pyx_n_s_include_hrefs, __pyx_k_include_hrefs, sizeof(__pyx_k_include_hrefs), 0, 0, 1, 1},
18737   {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
18738   {&__pyx_n_u_input, __pyx_k_input, sizeof(__pyx_k_input), 0, 1, 0, 1},
18739   {&__pyx_kp_u_ins, __pyx_k_ins, sizeof(__pyx_k_ins), 0, 1, 0, 0},
18740   {&__pyx_kp_u_ins_2, __pyx_k_ins_2, sizeof(__pyx_k_ins_2), 0, 1, 0, 0},
18741   {&__pyx_n_u_ins_3, __pyx_k_ins_3, sizeof(__pyx_k_ins_3), 0, 1, 0, 1},
18742   {&__pyx_n_s_ins_chunks, __pyx_k_ins_chunks, sizeof(__pyx_k_ins_chunks), 0, 0, 1, 1},
18743   {&__pyx_kp_u_ins_del, __pyx_k_ins_del, sizeof(__pyx_k_ins_del), 0, 1, 0, 0},
18744   {&__pyx_n_s_ins_del_re, __pyx_k_ins_del_re, sizeof(__pyx_k_ins_del_re), 0, 0, 1, 1},
18745   {&__pyx_n_s_ins_tokens, __pyx_k_ins_tokens, sizeof(__pyx_k_ins_tokens), 0, 0, 1, 1},
18746   {&__pyx_n_s_insert, __pyx_k_insert, sizeof(__pyx_k_insert), 0, 0, 1, 1},
18747   {&__pyx_n_u_insert, __pyx_k_insert, sizeof(__pyx_k_insert), 0, 1, 0, 1},
18748   {&__pyx_n_s_is_end_tag, __pyx_k_is_end_tag, sizeof(__pyx_k_is_end_tag), 0, 0, 1, 1},
18749   {&__pyx_n_s_is_start_tag, __pyx_k_is_start_tag, sizeof(__pyx_k_is_start_tag), 0, 0, 1, 1},
18750   {&__pyx_n_s_is_word, __pyx_k_is_word, sizeof(__pyx_k_is_word), 0, 0, 1, 1},
18751   {&__pyx_n_s_iselement, __pyx_k_iselement, sizeof(__pyx_k_iselement), 0, 0, 1, 1},
18752   {&__pyx_n_u_isindex, __pyx_k_isindex, sizeof(__pyx_k_isindex), 0, 1, 0, 1},
18753   {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
18754   {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
18755   {&__pyx_n_s_j1, __pyx_k_j1, sizeof(__pyx_k_j1), 0, 0, 1, 1},
18756   {&__pyx_n_s_j2, __pyx_k_j2, sizeof(__pyx_k_j2), 0, 0, 1, 1},
18757   {&__pyx_n_s_last, __pyx_k_last, sizeof(__pyx_k_last), 0, 0, 1, 1},
18758   {&__pyx_n_u_li, __pyx_k_li, sizeof(__pyx_k_li), 0, 1, 0, 1},
18759   {&__pyx_n_u_link, __pyx_k_link, sizeof(__pyx_k_link), 0, 1, 0, 1},
18760   {&__pyx_n_s_locate_unbalanced_end, __pyx_k_locate_unbalanced_end, sizeof(__pyx_k_locate_unbalanced_end), 0, 0, 1, 1},
18761   {&__pyx_n_s_locate_unbalanced_start, __pyx_k_locate_unbalanced_start, sizeof(__pyx_k_locate_unbalanced_start), 0, 0, 1, 1},
18762   {&__pyx_kp_u_locate_unbalanced_start_line_365, __pyx_k_locate_unbalanced_start_line_365, sizeof(__pyx_k_locate_unbalanced_start_line_365), 0, 1, 0, 0},
18763   {&__pyx_n_s_lxml, __pyx_k_lxml, sizeof(__pyx_k_lxml), 0, 0, 1, 1},
18764   {&__pyx_n_s_lxml_html, __pyx_k_lxml_html, sizeof(__pyx_k_lxml_html), 0, 0, 1, 1},
18765   {&__pyx_n_s_lxml_html_diff, __pyx_k_lxml_html_diff, sizeof(__pyx_k_lxml_html_diff), 0, 0, 1, 1},
18766   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
18767   {&__pyx_n_u_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 1, 0, 1},
18768   {&__pyx_n_s_main_2, __pyx_k_main_2, sizeof(__pyx_k_main_2), 0, 0, 1, 1},
18769   {&__pyx_n_s_markup, __pyx_k_markup, sizeof(__pyx_k_markup), 0, 0, 1, 1},
18770   {&__pyx_n_s_markup_func, __pyx_k_markup_func, sizeof(__pyx_k_markup_func), 0, 0, 1, 1},
18771   {&__pyx_n_s_markup_serialize_tokens, __pyx_k_markup_serialize_tokens, sizeof(__pyx_k_markup_serialize_tokens), 0, 0, 1, 1},
18772   {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
18773   {&__pyx_n_u_menu, __pyx_k_menu, sizeof(__pyx_k_menu), 0, 1, 0, 1},
18774   {&__pyx_n_s_merge_delete, __pyx_k_merge_delete, sizeof(__pyx_k_merge_delete), 0, 0, 1, 1},
18775   {&__pyx_n_s_merge_element_contents, __pyx_k_merge_element_contents, sizeof(__pyx_k_merge_element_contents), 0, 0, 1, 1},
18776   {&__pyx_n_s_merge_insert, __pyx_k_merge_insert, sizeof(__pyx_k_merge_insert), 0, 0, 1, 1},
18777   {&__pyx_n_s_merged, __pyx_k_merged, sizeof(__pyx_k_merged), 0, 0, 1, 1},
18778   {&__pyx_n_u_meta, __pyx_k_meta, sizeof(__pyx_k_meta), 0, 1, 0, 1},
18779   {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
18780   {&__pyx_n_s_method, __pyx_k_method, sizeof(__pyx_k_method), 0, 0, 1, 1},
18781   {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
18782   {&__pyx_n_s_move_el_inside_block, __pyx_k_move_el_inside_block, sizeof(__pyx_k_move_el_inside_block), 0, 0, 1, 1},
18783   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
18784   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
18785   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
18786   {&__pyx_n_s_new_html, __pyx_k_new_html, sizeof(__pyx_k_new_html), 0, 0, 1, 1},
18787   {&__pyx_n_s_new_html_tokens, __pyx_k_new_html_tokens, sizeof(__pyx_k_new_html_tokens), 0, 0, 1, 1},
18788   {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
18789   {&__pyx_n_u_noframes, __pyx_k_noframes, sizeof(__pyx_k_noframes), 0, 1, 0, 1},
18790   {&__pyx_n_u_noscript, __pyx_k_noscript, sizeof(__pyx_k_noscript), 0, 1, 0, 1},
18791   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
18792   {&__pyx_kp_u_of, __pyx_k_of, sizeof(__pyx_k_of), 0, 1, 0, 0},
18793   {&__pyx_n_u_ol, __pyx_k_ol, sizeof(__pyx_k_ol), 0, 1, 0, 1},
18794   {&__pyx_n_s_old_html, __pyx_k_old_html, sizeof(__pyx_k_old_html), 0, 0, 1, 1},
18795   {&__pyx_n_s_old_html_tokens, __pyx_k_old_html_tokens, sizeof(__pyx_k_old_html_tokens), 0, 0, 1, 1},
18796   {&__pyx_n_u_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 1, 0, 1},
18797   {&__pyx_n_u_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 1, 0, 1},
18798   {&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
18799   {&__pyx_n_s_parse_html, __pyx_k_parse_html, sizeof(__pyx_k_parse_html), 0, 0, 1, 1},
18800   {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
18801   {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
18802   {&__pyx_n_s_pos2, __pyx_k_pos2, sizeof(__pyx_k_pos2), 0, 0, 1, 1},
18803   {&__pyx_n_s_post, __pyx_k_post, sizeof(__pyx_k_post), 0, 0, 1, 1},
18804   {&__pyx_n_s_post_delete, __pyx_k_post_delete, sizeof(__pyx_k_post_delete), 0, 0, 1, 1},
18805   {&__pyx_n_s_post_tags, __pyx_k_post_tags, sizeof(__pyx_k_post_tags), 0, 0, 1, 1},
18806   {&__pyx_kp_u_post_tags_2, __pyx_k_post_tags_2, sizeof(__pyx_k_post_tags_2), 0, 1, 0, 0},
18807   {&__pyx_n_s_pre, __pyx_k_pre, sizeof(__pyx_k_pre), 0, 0, 1, 1},
18808   {&__pyx_n_u_pre, __pyx_k_pre, sizeof(__pyx_k_pre), 0, 1, 0, 1},
18809   {&__pyx_n_s_pre_delete, __pyx_k_pre_delete, sizeof(__pyx_k_pre_delete), 0, 0, 1, 1},
18810   {&__pyx_kp_u_pre_delete_and_post_delete_impl, __pyx_k_pre_delete_and_post_delete_impl, sizeof(__pyx_k_pre_delete_and_post_delete_impl), 0, 1, 0, 0},
18811   {&__pyx_n_s_pre_tags, __pyx_k_pre_tags, sizeof(__pyx_k_pre_tags), 0, 0, 1, 1},
18812   {&__pyx_kp_u_pre_tags_2, __pyx_k_pre_tags_2, sizeof(__pyx_k_pre_tags_2), 0, 1, 0, 0},
18813   {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
18814   {&__pyx_n_s_previous, __pyx_k_previous, sizeof(__pyx_k_previous), 0, 0, 1, 1},
18815   {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
18816   {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
18817   {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1},
18818   {&__pyx_n_u_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 1, 0, 1},
18819   {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
18820   {&__pyx_kp_u_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 1, 0, 0},
18821   {&__pyx_n_s_result_2, __pyx_k_result_2, sizeof(__pyx_k_result_2), 0, 0, 1, 1},
18822   {&__pyx_n_s_rfind, __pyx_k_rfind, sizeof(__pyx_k_rfind), 0, 0, 1, 1},
18823   {&__pyx_n_s_rstrip, __pyx_k_rstrip, sizeof(__pyx_k_rstrip), 0, 0, 1, 1},
18824   {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
18825   {&__pyx_n_s_search, __pyx_k_search, sizeof(__pyx_k_search), 0, 0, 1, 1},
18826   {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
18827   {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
18828   {&__pyx_n_s_serialize_html_fragment, __pyx_k_serialize_html_fragment, sizeof(__pyx_k_serialize_html_fragment), 0, 0, 1, 1},
18829   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
18830   {&__pyx_n_s_skip_outer, __pyx_k_skip_outer, sizeof(__pyx_k_skip_outer), 0, 0, 1, 1},
18831   {&__pyx_n_s_skip_tag, __pyx_k_skip_tag, sizeof(__pyx_k_skip_tag), 0, 0, 1, 1},
18832   {&__pyx_kp_u_span, __pyx_k_span, sizeof(__pyx_k_span), 0, 1, 0, 0},
18833   {&__pyx_kp_u_span_title, __pyx_k_span_title, sizeof(__pyx_k_span_title), 0, 1, 0, 0},
18834   {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
18835   {&__pyx_n_s_split_delete, __pyx_k_split_delete, sizeof(__pyx_k_split_delete), 0, 0, 1, 1},
18836   {&__pyx_n_s_split_trailing_whitespace, __pyx_k_split_trailing_whitespace, sizeof(__pyx_k_split_trailing_whitespace), 0, 0, 1, 1},
18837   {&__pyx_n_s_split_unbalanced, __pyx_k_split_unbalanced, sizeof(__pyx_k_split_unbalanced), 0, 0, 1, 1},
18838   {&__pyx_n_s_split_words, __pyx_k_split_words, sizeof(__pyx_k_split_words), 0, 0, 1, 1},
18839   {&__pyx_n_s_split_words_re, __pyx_k_split_words_re, sizeof(__pyx_k_split_words_re), 0, 0, 1, 1},
18840   {&__pyx_n_s_src, __pyx_k_src, sizeof(__pyx_k_src), 0, 0, 1, 1},
18841   {&__pyx_n_u_src, __pyx_k_src, sizeof(__pyx_k_src), 0, 1, 0, 1},
18842   {&__pyx_kp_s_src_lxml_html_diff_py, __pyx_k_src_lxml_html_diff_py, sizeof(__pyx_k_src_lxml_html_diff_py), 0, 0, 1, 0},
18843   {&__pyx_n_s_src_tok, __pyx_k_src_tok, sizeof(__pyx_k_src_tok), 0, 0, 1, 1},
18844   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
18845   {&__pyx_n_s_start_tag, __pyx_k_start_tag, sizeof(__pyx_k_start_tag), 0, 0, 1, 1},
18846   {&__pyx_n_s_start_whitespace_re, __pyx_k_start_whitespace_re, sizeof(__pyx_k_start_whitespace_re), 0, 0, 1, 1},
18847   {&__pyx_n_s_start_words, __pyx_k_start_words, sizeof(__pyx_k_start_words), 0, 0, 1, 1},
18848   {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
18849   {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
18850   {&__pyx_n_s_stripped_length, __pyx_k_stripped_length, sizeof(__pyx_k_stripped_length), 0, 0, 1, 1},
18851   {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
18852   {&__pyx_kp_u_t_n_r, __pyx_k_t_n_r, sizeof(__pyx_k_t_n_r), 0, 1, 0, 0},
18853   {&__pyx_kp_u_t_n_r_2, __pyx_k_t_n_r_2, sizeof(__pyx_k_t_n_r_2), 0, 1, 0, 0},
18854   {&__pyx_n_u_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 1, 0, 1},
18855   {&__pyx_n_s_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 0, 0, 1, 1},
18856   {&__pyx_n_s_tag_accum, __pyx_k_tag_accum, sizeof(__pyx_k_tag_accum), 0, 0, 1, 1},
18857   {&__pyx_n_s_tag_stack, __pyx_k_tag_stack, sizeof(__pyx_k_tag_stack), 0, 0, 1, 1},
18858   {&__pyx_kp_u_tag_token, __pyx_k_tag_token, sizeof(__pyx_k_tag_token), 0, 1, 0, 0},
18859   {&__pyx_n_s_tag_token_2, __pyx_k_tag_token_2, sizeof(__pyx_k_tag_token_2), 0, 0, 1, 1},
18860   {&__pyx_n_s_tag_token___new, __pyx_k_tag_token___new, sizeof(__pyx_k_tag_token___new), 0, 0, 1, 1},
18861   {&__pyx_n_s_tag_token___repr, __pyx_k_tag_token___repr, sizeof(__pyx_k_tag_token___repr), 0, 0, 1, 1},
18862   {&__pyx_n_s_tag_token_html, __pyx_k_tag_token_html, sizeof(__pyx_k_tag_token_html), 0, 0, 1, 1},
18863   {&__pyx_n_s_tail, __pyx_k_tail, sizeof(__pyx_k_tail), 0, 0, 1, 1},
18864   {&__pyx_n_s_tail_tag, __pyx_k_tail_tag, sizeof(__pyx_k_tail_tag), 0, 0, 1, 1},
18865   {&__pyx_n_u_tbody, __pyx_k_tbody, sizeof(__pyx_k_tbody), 0, 1, 0, 1},
18866   {&__pyx_n_u_td, __pyx_k_td, sizeof(__pyx_k_td), 0, 1, 0, 1},
18867   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
18868   {&__pyx_n_s_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 0, 1, 1},
18869   {&__pyx_n_s_text_tag, __pyx_k_text_tag, sizeof(__pyx_k_text_tag), 0, 0, 1, 1},
18870   {&__pyx_n_u_tfoot, __pyx_k_tfoot, sizeof(__pyx_k_tfoot), 0, 1, 0, 1},
18871   {&__pyx_n_u_th, __pyx_k_th, sizeof(__pyx_k_th), 0, 1, 0, 1},
18872   {&__pyx_n_u_thead, __pyx_k_thead, sizeof(__pyx_k_thead), 0, 1, 0, 1},
18873   {&__pyx_n_s_threshold, __pyx_k_threshold, sizeof(__pyx_k_threshold), 0, 0, 1, 1},
18874   {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
18875   {&__pyx_n_s_tok, __pyx_k_tok, sizeof(__pyx_k_tok), 0, 0, 1, 1},
18876   {&__pyx_n_s_token, __pyx_k_token, sizeof(__pyx_k_token), 0, 0, 1, 1},
18877   {&__pyx_kp_u_token_2, __pyx_k_token_2, sizeof(__pyx_k_token_2), 0, 1, 0, 0},
18878   {&__pyx_n_s_token___new, __pyx_k_token___new, sizeof(__pyx_k_token___new), 0, 0, 1, 1},
18879   {&__pyx_n_s_token___repr, __pyx_k_token___repr, sizeof(__pyx_k_token___repr), 0, 0, 1, 1},
18880   {&__pyx_n_s_token_html, __pyx_k_token_html, sizeof(__pyx_k_token_html), 0, 0, 1, 1},
18881   {&__pyx_n_s_tokenize, __pyx_k_tokenize, sizeof(__pyx_k_tokenize), 0, 0, 1, 1},
18882   {&__pyx_n_s_tokenize_annotated, __pyx_k_tokenize_annotated, sizeof(__pyx_k_tokenize_annotated), 0, 0, 1, 1},
18883   {&__pyx_n_s_tokenlist, __pyx_k_tokenlist, sizeof(__pyx_k_tokenlist), 0, 0, 1, 1},
18884   {&__pyx_n_s_tokens, __pyx_k_tokens, sizeof(__pyx_k_tokens), 0, 0, 1, 1},
18885   {&__pyx_n_s_tokens_new, __pyx_k_tokens_new, sizeof(__pyx_k_tokens_new), 0, 0, 1, 1},
18886   {&__pyx_n_s_tokens_old, __pyx_k_tokens_old, sizeof(__pyx_k_tokens_old), 0, 0, 1, 1},
18887   {&__pyx_n_s_tostring, __pyx_k_tostring, sizeof(__pyx_k_tostring), 0, 0, 1, 1},
18888   {&__pyx_n_u_tr, __pyx_k_tr, sizeof(__pyx_k_tr), 0, 1, 0, 1},
18889   {&__pyx_n_s_trailing_whitespace, __pyx_k_trailing_whitespace, sizeof(__pyx_k_trailing_whitespace), 0, 0, 1, 1},
18890   {&__pyx_kp_u_trailing_whitespace_2, __pyx_k_trailing_whitespace_2, sizeof(__pyx_k_trailing_whitespace_2), 0, 1, 0, 0},
18891   {&__pyx_n_u_ul, __pyx_k_ul, sizeof(__pyx_k_ul), 0, 1, 0, 1},
18892   {&__pyx_n_s_unbalanced_end, __pyx_k_unbalanced_end, sizeof(__pyx_k_unbalanced_end), 0, 0, 1, 1},
18893   {&__pyx_n_s_unbalanced_start, __pyx_k_unbalanced_start, sizeof(__pyx_k_unbalanced_start), 0, 0, 1, 1},
18894   {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1},
18895   {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
18896   {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1},
18897   {&__pyx_n_s_word, __pyx_k_word, sizeof(__pyx_k_word), 0, 0, 1, 1},
18898   {&__pyx_n_s_words, __pyx_k_words, sizeof(__pyx_k_words), 0, 0, 1, 1},
18899   {&__pyx_n_s_xpath, __pyx_k_xpath, sizeof(__pyx_k_xpath), 0, 0, 1, 1},
18900   {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
18901   {0, 0, 0, 0, 0, 0, 0}
18902 };
18903 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
18904   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 14, __pyx_L1_error)
18905   __pyx_builtin_NameError = __Pyx_GetBuiltinName(__pyx_n_s_NameError); if (!__pyx_builtin_NameError) __PYX_ERR(0, 18, __pyx_L1_error)
18906   __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 101, __pyx_L1_error)
18907   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 360, __pyx_L1_error)
18908   return 0;
18909   __pyx_L1_error:;
18910   return -1;
18911 }
18912
18913 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
18914   __Pyx_RefNannyDeclarations
18915   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
18916
18917   /* "lxml/html/diff.py":110
18918  *     """
18919  *     result = [tokens[0]]
18920  *     for tok in tokens[1:]:             # <<<<<<<<<<<<<<
18921  *         if (not result[-1].post_tags and
18922  *             not tok.pre_tags and
18923  */
18924   __pyx_slice__3 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 110, __pyx_L1_error)
18925   __Pyx_GOTREF(__pyx_slice__3);
18926   __Pyx_GIVEREF(__pyx_slice__3);
18927
18928   /* "lxml/html/diff.py":249
18929  *     if balanced and balanced[-1].endswith(' '):
18930  *         # We move space outside of </ins>
18931  *         balanced[-1] = balanced[-1][:-1]             # <<<<<<<<<<<<<<
18932  *     doc.extend(balanced)
18933  *     doc.append('</ins> ')
18934  */
18935   __pyx_slice__7 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__7)) __PYX_ERR(0, 249, __pyx_L1_error)
18936   __Pyx_GOTREF(__pyx_slice__7);
18937   __Pyx_GIVEREF(__pyx_slice__7);
18938
18939   /* "lxml/html/diff.py":631
18940  * 
18941  *     if not result:
18942  *         return [token('', pre_tags=tag_accum)]             # <<<<<<<<<<<<<<
18943  *     else:
18944  *         result[-1].post_tags.extend(tag_accum)
18945  */
18946   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u__2); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 631, __pyx_L1_error)
18947   __Pyx_GOTREF(__pyx_tuple__16);
18948   __Pyx_GIVEREF(__pyx_tuple__16);
18949
18950   /* "lxml/html/diff.py":781
18951  *     """fixup_ins_del_tags that works on an lxml document in-place
18952  *     """
18953  *     for tag in ['ins', 'del']:             # <<<<<<<<<<<<<<
18954  *         for el in doc.xpath('descendant-or-self::%s' % tag):
18955  *             if not _contains_block_level_tag(el):
18956  */
18957   __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_u_ins_3, __pyx_n_u_del_3); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 781, __pyx_L1_error)
18958   __Pyx_GOTREF(__pyx_tuple__21);
18959   __Pyx_GIVEREF(__pyx_tuple__21);
18960
18961   /* "lxml/html/diff.py":811
18962  *         el.text = None
18963  *         children_tag.extend(list(el))
18964  *         el[:] = [children_tag]             # <<<<<<<<<<<<<<
18965  *         return
18966  *     for child in list(el):
18967  */
18968   __pyx_slice__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) __PYX_ERR(0, 811, __pyx_L1_error)
18969   __Pyx_GOTREF(__pyx_slice__22);
18970   __Pyx_GIVEREF(__pyx_slice__22);
18971
18972   /* "lxml/html/diff.py":31
18973  * ############################################################
18974  * 
18975  * def default_markup(text, version):             # <<<<<<<<<<<<<<
18976  *     return '<span title="%s">%s</span>' % (
18977  *         html_escape(_unicode(version), 1), text)
18978  */
18979   __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_text, __pyx_n_s_version); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 31, __pyx_L1_error)
18980   __Pyx_GOTREF(__pyx_tuple__23);
18981   __Pyx_GIVEREF(__pyx_tuple__23);
18982   __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_default_markup, 31, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 31, __pyx_L1_error)
18983
18984   /* "lxml/html/diff.py":35
18985  *         html_escape(_unicode(version), 1), text)
18986  * 
18987  * def html_annotate(doclist, markup=default_markup):             # <<<<<<<<<<<<<<
18988  *     """
18989  *     doclist should be ordered from oldest to newest, like::
18990  */
18991   __pyx_tuple__25 = PyTuple_Pack(8, __pyx_n_s_doclist, __pyx_n_s_markup, __pyx_n_s_tokenlist, __pyx_n_s_cur_tokens, __pyx_n_s_tokens, __pyx_n_s_result_2, __pyx_n_s_doc, __pyx_n_s_version); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 35, __pyx_L1_error)
18992   __Pyx_GOTREF(__pyx_tuple__25);
18993   __Pyx_GIVEREF(__pyx_tuple__25);
18994   __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_html_annotate, 35, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 35, __pyx_L1_error)
18995
18996   /* "lxml/html/diff.py":75
18997  *     return ''.join(result).strip()
18998  * 
18999  * def tokenize_annotated(doc, annotation):             # <<<<<<<<<<<<<<
19000  *     """Tokenize a document and add an annotation attribute to each token
19001  *     """
19002  */
19003   __pyx_tuple__27 = PyTuple_Pack(4, __pyx_n_s_doc, __pyx_n_s_annotation, __pyx_n_s_tokens, __pyx_n_s_tok); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 75, __pyx_L1_error)
19004   __Pyx_GOTREF(__pyx_tuple__27);
19005   __Pyx_GIVEREF(__pyx_tuple__27);
19006   __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_tokenize_annotated, 75, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 75, __pyx_L1_error)
19007
19008   /* "lxml/html/diff.py":83
19009  *     return tokens
19010  * 
19011  * def html_annotate_merge_annotations(tokens_old, tokens_new):             # <<<<<<<<<<<<<<
19012  *     """Merge the annotations from tokens_old into tokens_new, when the
19013  *     tokens in the new document already existed in the old document.
19014  */
19015   __pyx_tuple__29 = PyTuple_Pack(11, __pyx_n_s_tokens_old, __pyx_n_s_tokens_new, __pyx_n_s_s, __pyx_n_s_commands, __pyx_n_s_command, __pyx_n_s_i1, __pyx_n_s_i2, __pyx_n_s_j1, __pyx_n_s_j2, __pyx_n_s_eq_old, __pyx_n_s_eq_new); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 83, __pyx_L1_error)
19016   __Pyx_GOTREF(__pyx_tuple__29);
19017   __Pyx_GIVEREF(__pyx_tuple__29);
19018   __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_html_annotate_merge_annotations, 83, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 83, __pyx_L1_error)
19019
19020   /* "lxml/html/diff.py":96
19021  *             copy_annotations(eq_old, eq_new)
19022  * 
19023  * def copy_annotations(src, dest):             # <<<<<<<<<<<<<<
19024  *     """
19025  *     Copy annotations from the tokens listed in src to the tokens in dest
19026  */
19027   __pyx_tuple__31 = PyTuple_Pack(4, __pyx_n_s_src, __pyx_n_s_dest, __pyx_n_s_src_tok, __pyx_n_s_dest_tok); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 96, __pyx_L1_error)
19028   __Pyx_GOTREF(__pyx_tuple__31);
19029   __Pyx_GIVEREF(__pyx_tuple__31);
19030   __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_copy_annotations, 96, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 96, __pyx_L1_error)
19031
19032   /* "lxml/html/diff.py":104
19033  *         dest_tok.annotation = src_tok.annotation
19034  * 
19035  * def compress_tokens(tokens):             # <<<<<<<<<<<<<<
19036  *     """
19037  *     Combine adjacent tokens when there is no HTML between the tokens,
19038  */
19039   __pyx_tuple__33 = PyTuple_Pack(3, __pyx_n_s_tokens, __pyx_n_s_result_2, __pyx_n_s_tok); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 104, __pyx_L1_error)
19040   __Pyx_GOTREF(__pyx_tuple__33);
19041   __Pyx_GIVEREF(__pyx_tuple__33);
19042   __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_compress_tokens, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 104, __pyx_L1_error)
19043
19044   /* "lxml/html/diff.py":119
19045  *     return result
19046  * 
19047  * def compress_merge_back(tokens, tok):             # <<<<<<<<<<<<<<
19048  *     """ Merge tok into the last element of tokens (modifying the list of
19049  *     tokens in-place).  """
19050  */
19051   __pyx_tuple__35 = PyTuple_Pack(5, __pyx_n_s_tokens, __pyx_n_s_tok, __pyx_n_s_last, __pyx_n_s_text, __pyx_n_s_merged); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 119, __pyx_L1_error)
19052   __Pyx_GOTREF(__pyx_tuple__35);
19053   __Pyx_GIVEREF(__pyx_tuple__35);
19054   __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_compress_merge_back, 119, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 119, __pyx_L1_error)
19055
19056   /* "lxml/html/diff.py":137
19057  *         tokens[-1] = merged
19058  * 
19059  * def markup_serialize_tokens(tokens, markup_func):             # <<<<<<<<<<<<<<
19060  *     """
19061  *     Serialize the list of tokens into a list of text chunks, calling
19062  */
19063   __pyx_tuple__37 = PyTuple_Pack(6, __pyx_n_s_tokens, __pyx_n_s_markup_func, __pyx_n_s_token, __pyx_n_s_pre, __pyx_n_s_html, __pyx_n_s_post); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 137, __pyx_L1_error)
19064   __Pyx_GOTREF(__pyx_tuple__37);
19065   __Pyx_GIVEREF(__pyx_tuple__37);
19066   __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_markup_serialize_tokens, 137, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 137, __pyx_L1_error)
19067
19068   /* "lxml/html/diff.py":158
19069  * ############################################################
19070  * 
19071  * def htmldiff(old_html, new_html):             # <<<<<<<<<<<<<<
19072  *     ## FIXME: this should take parsed documents too, and use their body
19073  *     ## or other content.
19074  */
19075   __pyx_tuple__38 = PyTuple_Pack(5, __pyx_n_s_old_html, __pyx_n_s_new_html, __pyx_n_s_old_html_tokens, __pyx_n_s_new_html_tokens, __pyx_n_s_result_2); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 158, __pyx_L1_error)
19076   __Pyx_GOTREF(__pyx_tuple__38);
19077   __Pyx_GIVEREF(__pyx_tuple__38);
19078   __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_htmldiff, 158, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 158, __pyx_L1_error)
19079
19080   /* "lxml/html/diff.py":181
19081  *     return fixup_ins_del_tags(result)
19082  * 
19083  * def htmldiff_tokens(html1_tokens, html2_tokens):             # <<<<<<<<<<<<<<
19084  *     """ Does a diff on the tokens themselves, returning a list of text
19085  *     chunks (not tokens).
19086  */
19087   __pyx_tuple__40 = PyTuple_Pack(12, __pyx_n_s_html1_tokens, __pyx_n_s_html2_tokens, __pyx_n_s_s, __pyx_n_s_commands, __pyx_n_s_result_2, __pyx_n_s_command, __pyx_n_s_i1, __pyx_n_s_i2, __pyx_n_s_j1, __pyx_n_s_j2, __pyx_n_s_ins_tokens, __pyx_n_s_del_tokens); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 181, __pyx_L1_error)
19088   __Pyx_GOTREF(__pyx_tuple__40);
19089   __Pyx_GIVEREF(__pyx_tuple__40);
19090   __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(2, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_htmldiff_tokens, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 181, __pyx_L1_error)
19091
19092   /* "lxml/html/diff.py":219
19093  *     return result
19094  * 
19095  * def expand_tokens(tokens, equal=False):             # <<<<<<<<<<<<<<
19096  *     """Given a list of tokens, return a generator of the chunks of
19097  *     text for the data in the tokens.
19098  */
19099   __pyx_tuple__42 = PyTuple_Pack(5, __pyx_n_s_tokens, __pyx_n_s_equal, __pyx_n_s_token, __pyx_n_s_pre, __pyx_n_s_post); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 219, __pyx_L1_error)
19100   __Pyx_GOTREF(__pyx_tuple__42);
19101   __Pyx_GIVEREF(__pyx_tuple__42);
19102   __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_expand_tokens, 219, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 219, __pyx_L1_error)
19103   __pyx_tuple__43 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 219, __pyx_L1_error)
19104   __Pyx_GOTREF(__pyx_tuple__43);
19105   __Pyx_GIVEREF(__pyx_tuple__43);
19106
19107   /* "lxml/html/diff.py":234
19108  *             yield post
19109  * 
19110  * def merge_insert(ins_chunks, doc):             # <<<<<<<<<<<<<<
19111  *     """ doc is the already-handled document (as a list of text chunks);
19112  *     here we add <ins>ins_chunks</ins> to the end of that.  """
19113  */
19114   __pyx_tuple__44 = PyTuple_Pack(5, __pyx_n_s_ins_chunks, __pyx_n_s_doc, __pyx_n_s_unbalanced_start, __pyx_n_s_balanced, __pyx_n_s_unbalanced_end); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 234, __pyx_L1_error)
19115   __Pyx_GOTREF(__pyx_tuple__44);
19116   __Pyx_GIVEREF(__pyx_tuple__44);
19117   __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_merge_insert, 234, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 234, __pyx_L1_error)
19118
19119   /* "lxml/html/diff.py":266
19120  *     (DEL_START/DEL_END) """
19121  * 
19122  * def merge_delete(del_chunks, doc):             # <<<<<<<<<<<<<<
19123  *     """ Adds the text chunks in del_chunks to the document doc (another
19124  *     list of text chunks) with marker to show it is a delete.
19125  */
19126   __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_del_chunks, __pyx_n_s_doc); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 266, __pyx_L1_error)
19127   __Pyx_GOTREF(__pyx_tuple__46);
19128   __Pyx_GIVEREF(__pyx_tuple__46);
19129   __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_merge_delete, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 266, __pyx_L1_error)
19130
19131   /* "lxml/html/diff.py":274
19132  *     doc.append(DEL_END)
19133  * 
19134  * def cleanup_delete(chunks):             # <<<<<<<<<<<<<<
19135  *     """ Cleans up any DEL_START/DEL_END markers in the document, replacing
19136  *     them with <del></del>.  To do this while keeping the document
19137  */
19138   __pyx_tuple__48 = PyTuple_Pack(8, __pyx_n_s_chunks_2, __pyx_n_s_pre_delete, __pyx_n_s_delete, __pyx_n_s_post_delete, __pyx_n_s_unbalanced_start, __pyx_n_s_balanced, __pyx_n_s_unbalanced_end, __pyx_n_s_doc); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 274, __pyx_L1_error)
19139   __Pyx_GOTREF(__pyx_tuple__48);
19140   __Pyx_GIVEREF(__pyx_tuple__48);
19141   __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_cleanup_delete, 274, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 274, __pyx_L1_error)
19142
19143   /* "lxml/html/diff.py":313
19144  *     return chunks
19145  * 
19146  * def split_unbalanced(chunks):             # <<<<<<<<<<<<<<
19147  *     """Return (unbalanced_start, balanced, unbalanced_end), where each is
19148  *     a list of text and tag chunks.
19149  */
19150   __pyx_tuple__50 = PyTuple_Pack(17, __pyx_n_s_chunks_2, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_tag_stack, __pyx_n_s_balanced, __pyx_n_s_chunk, __pyx_n_s_endtag, __pyx_n_s_name_2, __pyx_n_s_pos, __pyx_n_s_tag, __pyx_n_s_name_2, __pyx_n_s_pos, __pyx_n_s_tag, __pyx_n_s_name_2, __pyx_n_s_pos, __pyx_n_s_chunk, __pyx_n_s_chunk); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 313, __pyx_L1_error)
19151   __Pyx_GOTREF(__pyx_tuple__50);
19152   __Pyx_GIVEREF(__pyx_tuple__50);
19153   __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(1, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_split_unbalanced, 313, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 313, __pyx_L1_error)
19154
19155   /* "lxml/html/diff.py":353
19156  *     return start, balanced, end
19157  * 
19158  * def split_delete(chunks):             # <<<<<<<<<<<<<<
19159  *     """ Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
19160  *     stuff_after_DEL_END).  Returns the first case found (there may be
19161  */
19162   __pyx_tuple__52 = PyTuple_Pack(3, __pyx_n_s_chunks_2, __pyx_n_s_pos, __pyx_n_s_pos2); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 353, __pyx_L1_error)
19163   __Pyx_GOTREF(__pyx_tuple__52);
19164   __Pyx_GIVEREF(__pyx_tuple__52);
19165   __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_split_delete, 353, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 353, __pyx_L1_error)
19166
19167   /* "lxml/html/diff.py":365
19168  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
19169  * 
19170  * def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):             # <<<<<<<<<<<<<<
19171  *     """ pre_delete and post_delete implicitly point to a place in the
19172  *     document (where the two were split).  This moves that point (by
19173  */
19174   __pyx_tuple__54 = PyTuple_Pack(7, __pyx_n_s_unbalanced_start, __pyx_n_s_pre_delete, __pyx_n_s_post_delete, __pyx_n_s_finding, __pyx_n_s_finding_name, __pyx_n_s_next, __pyx_n_s_name_2); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 365, __pyx_L1_error)
19175   __Pyx_GOTREF(__pyx_tuple__54);
19176   __Pyx_GIVEREF(__pyx_tuple__54);
19177   __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_locate_unbalanced_start, 365, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(0, 365, __pyx_L1_error)
19178
19179   /* "lxml/html/diff.py":415
19180  *             break
19181  * 
19182  * def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):             # <<<<<<<<<<<<<<
19183  *     """ like locate_unbalanced_start, except handling end tags and
19184  *     possibly moving the point earlier in the document.  """
19185  */
19186   __pyx_tuple__56 = PyTuple_Pack(7, __pyx_n_s_unbalanced_end, __pyx_n_s_pre_delete, __pyx_n_s_post_delete, __pyx_n_s_finding, __pyx_n_s_finding_name, __pyx_n_s_next, __pyx_n_s_name_2); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 415, __pyx_L1_error)
19187   __Pyx_GOTREF(__pyx_tuple__56);
19188   __Pyx_GIVEREF(__pyx_tuple__56);
19189   __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_locate_unbalanced_end, 415, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 415, __pyx_L1_error)
19190
19191   /* "lxml/html/diff.py":458
19192  *     hide_when_equal = False
19193  * 
19194  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):             # <<<<<<<<<<<<<<
19195  *         obj = _unicode.__new__(cls, text)
19196  * 
19197  */
19198   __pyx_tuple__58 = PyTuple_Pack(6, __pyx_n_s_cls, __pyx_n_s_text, __pyx_n_s_pre_tags, __pyx_n_s_post_tags, __pyx_n_s_trailing_whitespace, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 458, __pyx_L1_error)
19199   __Pyx_GOTREF(__pyx_tuple__58);
19200   __Pyx_GIVEREF(__pyx_tuple__58);
19201   __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_new, 458, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 458, __pyx_L1_error)
19202   __pyx_tuple__60 = PyTuple_Pack(3, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_kp_u__2)); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 458, __pyx_L1_error)
19203   __Pyx_GOTREF(__pyx_tuple__60);
19204   __Pyx_GIVEREF(__pyx_tuple__60);
19205
19206   /* "lxml/html/diff.py":475
19207  *         return obj
19208  * 
19209  *     def __repr__(self):             # <<<<<<<<<<<<<<
19210  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
19211  *                                           self.post_tags, self.trailing_whitespace)
19212  */
19213   __pyx_tuple__61 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 475, __pyx_L1_error)
19214   __Pyx_GOTREF(__pyx_tuple__61);
19215   __Pyx_GIVEREF(__pyx_tuple__61);
19216   __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_repr, 475, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 475, __pyx_L1_error)
19217
19218   /* "lxml/html/diff.py":479
19219  *                                           self.post_tags, self.trailing_whitespace)
19220  * 
19221  *     def html(self):             # <<<<<<<<<<<<<<
19222  *         return _unicode(self)
19223  * 
19224  */
19225   __pyx_tuple__63 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 479, __pyx_L1_error)
19226   __Pyx_GOTREF(__pyx_tuple__63);
19227   __Pyx_GIVEREF(__pyx_tuple__63);
19228   __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_html, 479, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 479, __pyx_L1_error)
19229
19230   /* "lxml/html/diff.py":488
19231  *     is only represented in a document by a tag.  """
19232  * 
19233  *     def __new__(cls, tag, data, html_repr, pre_tags=None,             # <<<<<<<<<<<<<<
19234  *                 post_tags=None, trailing_whitespace=""):
19235  *         obj = token.__new__(cls, "%s: %s" % (type, data),
19236  */
19237   __pyx_tuple__65 = PyTuple_Pack(8, __pyx_n_s_cls, __pyx_n_s_tag, __pyx_n_s_data, __pyx_n_s_html_repr, __pyx_n_s_pre_tags, __pyx_n_s_post_tags, __pyx_n_s_trailing_whitespace, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 488, __pyx_L1_error)
19238   __Pyx_GOTREF(__pyx_tuple__65);
19239   __Pyx_GIVEREF(__pyx_tuple__65);
19240   __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(7, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_new, 488, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 488, __pyx_L1_error)
19241   __pyx_tuple__67 = PyTuple_Pack(3, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_kp_u__2)); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 488, __pyx_L1_error)
19242   __Pyx_GOTREF(__pyx_tuple__67);
19243   __Pyx_GIVEREF(__pyx_tuple__67);
19244
19245   /* "lxml/html/diff.py":499
19246  *         return obj
19247  * 
19248  *     def __repr__(self):             # <<<<<<<<<<<<<<
19249  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
19250  *             self.tag,
19251  */
19252   __pyx_tuple__68 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 499, __pyx_L1_error)
19253   __Pyx_GOTREF(__pyx_tuple__68);
19254   __Pyx_GIVEREF(__pyx_tuple__68);
19255   __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_repr, 499, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(0, 499, __pyx_L1_error)
19256
19257   /* "lxml/html/diff.py":507
19258  *             self.post_tags,
19259  *             self.trailing_whitespace)
19260  *     def html(self):             # <<<<<<<<<<<<<<
19261  *         return self.html_repr
19262  * 
19263  */
19264   __pyx_tuple__70 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 507, __pyx_L1_error)
19265   __Pyx_GOTREF(__pyx_tuple__70);
19266   __Pyx_GIVEREF(__pyx_tuple__70);
19267   __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_html, 507, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(0, 507, __pyx_L1_error)
19268
19269   /* "lxml/html/diff.py":517
19270  *     hide_when_equal = True
19271  * 
19272  *     def html(self):             # <<<<<<<<<<<<<<
19273  *         return ' Link: %s' % self
19274  * 
19275  */
19276   __pyx_tuple__72 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 517, __pyx_L1_error)
19277   __Pyx_GOTREF(__pyx_tuple__72);
19278   __Pyx_GIVEREF(__pyx_tuple__72);
19279   __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_html, 517, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) __PYX_ERR(0, 517, __pyx_L1_error)
19280
19281   /* "lxml/html/diff.py":520
19282  *         return ' Link: %s' % self
19283  * 
19284  * def tokenize(html, include_hrefs=True):             # <<<<<<<<<<<<<<
19285  *     """
19286  *     Parse the given HTML and returns token objects (words with attached tags).
19287  */
19288   __pyx_tuple__74 = PyTuple_Pack(4, __pyx_n_s_html, __pyx_n_s_include_hrefs, __pyx_n_s_body_el, __pyx_n_s_chunks_2); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 520, __pyx_L1_error)
19289   __Pyx_GOTREF(__pyx_tuple__74);
19290   __Pyx_GIVEREF(__pyx_tuple__74);
19291   __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_tokenize, 520, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(0, 520, __pyx_L1_error)
19292   __pyx_tuple__76 = PyTuple_Pack(1, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 520, __pyx_L1_error)
19293   __Pyx_GOTREF(__pyx_tuple__76);
19294   __Pyx_GIVEREF(__pyx_tuple__76);
19295
19296   /* "lxml/html/diff.py":544
19297  *     return fixup_chunks(chunks)
19298  * 
19299  * def parse_html(html, cleanup=True):             # <<<<<<<<<<<<<<
19300  *     """
19301  *     Parses an HTML fragment, returning an lxml element.  Note that the HTML will be
19302  */
19303   __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_html, __pyx_n_s_cleanup); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 544, __pyx_L1_error)
19304   __Pyx_GOTREF(__pyx_tuple__77);
19305   __Pyx_GIVEREF(__pyx_tuple__77);
19306   __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_parse_html, 544, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 544, __pyx_L1_error)
19307   __pyx_tuple__79 = PyTuple_Pack(1, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 544, __pyx_L1_error)
19308   __Pyx_GOTREF(__pyx_tuple__79);
19309   __Pyx_GIVEREF(__pyx_tuple__79);
19310
19311   /* "lxml/html/diff.py":561
19312  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
19313  * 
19314  * def cleanup_html(html):             # <<<<<<<<<<<<<<
19315  *     """ This 'cleans' the HTML, meaning that any page structure is removed
19316  *     (only the contents of <body> are used, if there is any <body).
19317  */
19318   __pyx_tuple__80 = PyTuple_Pack(2, __pyx_n_s_html, __pyx_n_s_match); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 561, __pyx_L1_error)
19319   __Pyx_GOTREF(__pyx_tuple__80);
19320   __Pyx_GIVEREF(__pyx_tuple__80);
19321   __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_cleanup_html, 561, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 561, __pyx_L1_error)
19322
19323   /* "lxml/html/diff.py":575
19324  * 
19325  * 
19326  * end_whitespace_re = re.compile(r'[ \t\n\r]$')             # <<<<<<<<<<<<<<
19327  * 
19328  * def split_trailing_whitespace(word):
19329  */
19330   __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_u_t_n_r); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 575, __pyx_L1_error)
19331   __Pyx_GOTREF(__pyx_tuple__82);
19332   __Pyx_GIVEREF(__pyx_tuple__82);
19333
19334   /* "lxml/html/diff.py":577
19335  * end_whitespace_re = re.compile(r'[ \t\n\r]$')
19336  * 
19337  * def split_trailing_whitespace(word):             # <<<<<<<<<<<<<<
19338  *     """
19339  *     This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
19340  */
19341   __pyx_tuple__83 = PyTuple_Pack(2, __pyx_n_s_word, __pyx_n_s_stripped_length); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 577, __pyx_L1_error)
19342   __Pyx_GOTREF(__pyx_tuple__83);
19343   __Pyx_GIVEREF(__pyx_tuple__83);
19344   __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_split_trailing_whitespace, 577, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(0, 577, __pyx_L1_error)
19345
19346   /* "lxml/html/diff.py":585
19347  * 
19348  * 
19349  * def fixup_chunks(chunks):             # <<<<<<<<<<<<<<
19350  *     """
19351  *     This function takes a list of chunks and produces a list of tokens.
19352  */
19353   __pyx_tuple__85 = PyTuple_Pack(9, __pyx_n_s_chunks_2, __pyx_n_s_tag_accum, __pyx_n_s_cur_word, __pyx_n_s_result_2, __pyx_n_s_chunk, __pyx_n_s_src, __pyx_n_s_tag, __pyx_n_s_trailing_whitespace, __pyx_n_s_href); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 585, __pyx_L1_error)
19354   __Pyx_GOTREF(__pyx_tuple__85);
19355   __Pyx_GIVEREF(__pyx_tuple__85);
19356   __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_fixup_chunks, 585, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(0, 585, __pyx_L1_error)
19357
19358   /* "lxml/html/diff.py":640
19359  * # All the tags in HTML that don't require end tags:
19360  * empty_tags = (
19361  *     'param', 'img', 'area', 'br', 'basefont', 'input',             # <<<<<<<<<<<<<<
19362  *     'base', 'meta', 'link', 'col')
19363  * 
19364  */
19365   __pyx_tuple__87 = PyTuple_Pack(10, __pyx_n_u_param, __pyx_n_u_img, __pyx_n_u_area, __pyx_n_u_br, __pyx_n_u_basefont, __pyx_n_u_input, __pyx_n_u_base, __pyx_n_u_meta, __pyx_n_u_link, __pyx_n_u_col); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 640, __pyx_L1_error)
19366   __Pyx_GOTREF(__pyx_tuple__87);
19367   __Pyx_GIVEREF(__pyx_tuple__87);
19368
19369   /* "lxml/html/diff.py":644
19370  * 
19371  * block_level_tags = (
19372  *     'address',             # <<<<<<<<<<<<<<
19373  *     'blockquote',
19374  *     'center',
19375  */
19376   __pyx_tuple__88 = PyTuple_Pack(24, __pyx_n_u_address, __pyx_n_u_blockquote, __pyx_n_u_center, __pyx_n_u_dir, __pyx_n_u_div, __pyx_n_u_dl, __pyx_n_u_fieldset, __pyx_n_u_form, __pyx_n_u_h1, __pyx_n_u_h2, __pyx_n_u_h3, __pyx_n_u_h4, __pyx_n_u_h5, __pyx_n_u_h6, __pyx_n_u_hr, __pyx_n_u_isindex, __pyx_n_u_menu, __pyx_n_u_noframes, __pyx_n_u_noscript, __pyx_n_u_ol, __pyx_n_u_p, __pyx_n_u_pre, __pyx_n_u_table, __pyx_n_u_ul); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 644, __pyx_L1_error)
19377   __Pyx_GOTREF(__pyx_tuple__88);
19378   __Pyx_GIVEREF(__pyx_tuple__88);
19379
19380   /* "lxml/html/diff.py":671
19381  * 
19382  * block_level_container_tags = (
19383  *     'dd',             # <<<<<<<<<<<<<<
19384  *     'dt',
19385  *     'frameset',
19386  */
19387   __pyx_tuple__89 = PyTuple_Pack(10, __pyx_n_u_dd, __pyx_n_u_dt, __pyx_n_u_frameset, __pyx_n_u_li, __pyx_n_u_tbody, __pyx_n_u_td, __pyx_n_u_tfoot, __pyx_n_u_th, __pyx_n_u_thead, __pyx_n_u_tr); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 671, __pyx_L1_error)
19388   __Pyx_GOTREF(__pyx_tuple__89);
19389   __Pyx_GIVEREF(__pyx_tuple__89);
19390
19391   /* "lxml/html/diff.py":684
19392  * 
19393  * 
19394  * def flatten_el(el, include_hrefs, skip_tag=False):             # <<<<<<<<<<<<<<
19395  *     """ Takes an lxml element el, and generates all the text chunks for
19396  *     that tag.  Each start tag is a chunk, each word is a chunk, and each
19397  */
19398   __pyx_tuple__90 = PyTuple_Pack(8, __pyx_n_s_el, __pyx_n_s_include_hrefs, __pyx_n_s_skip_tag, __pyx_n_s_start_words, __pyx_n_s_word, __pyx_n_s_child, __pyx_n_s_item, __pyx_n_s_end_words); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 684, __pyx_L1_error)
19399   __Pyx_GOTREF(__pyx_tuple__90);
19400   __Pyx_GIVEREF(__pyx_tuple__90);
19401   __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__90, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_flatten_el, 684, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 684, __pyx_L1_error)
19402   __pyx_tuple__91 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 684, __pyx_L1_error)
19403   __Pyx_GOTREF(__pyx_tuple__91);
19404   __Pyx_GIVEREF(__pyx_tuple__91);
19405
19406   /* "lxml/html/diff.py":714
19407  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
19408  * 
19409  * def split_words(text):             # <<<<<<<<<<<<<<
19410  *     """ Splits some text into words. Includes trailing whitespace
19411  *     on each word when appropriate.  """
19412  */
19413   __pyx_tuple__92 = PyTuple_Pack(2, __pyx_n_s_text, __pyx_n_s_words); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 714, __pyx_L1_error)
19414   __Pyx_GOTREF(__pyx_tuple__92);
19415   __Pyx_GIVEREF(__pyx_tuple__92);
19416   __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_split_words, 714, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 714, __pyx_L1_error)
19417
19418   /* "lxml/html/diff.py":723
19419  *     return words
19420  * 
19421  * start_whitespace_re = re.compile(r'^[ \t\n\r]')             # <<<<<<<<<<<<<<
19422  * 
19423  * def start_tag(el):
19424  */
19425   __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_u_t_n_r_2); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 723, __pyx_L1_error)
19426   __Pyx_GOTREF(__pyx_tuple__94);
19427   __Pyx_GIVEREF(__pyx_tuple__94);
19428
19429   /* "lxml/html/diff.py":725
19430  * start_whitespace_re = re.compile(r'^[ \t\n\r]')
19431  * 
19432  * def start_tag(el):             # <<<<<<<<<<<<<<
19433  *     """
19434  *     The text representation of the start tag for a tag.
19435  */
19436   __pyx_tuple__95 = PyTuple_Pack(3, __pyx_n_s_el, __pyx_n_s_name_2, __pyx_n_s_value); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 725, __pyx_L1_error)
19437   __Pyx_GOTREF(__pyx_tuple__95);
19438   __Pyx_GIVEREF(__pyx_tuple__95);
19439   __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_start_tag, 725, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(0, 725, __pyx_L1_error)
19440
19441   /* "lxml/html/diff.py":733
19442  *                          for name, value in el.attrib.items()]))
19443  * 
19444  * def end_tag(el):             # <<<<<<<<<<<<<<
19445  *     """ The text representation of an end tag for a tag.  Includes
19446  *     trailing whitespace when appropriate.  """
19447  */
19448   __pyx_tuple__97 = PyTuple_Pack(2, __pyx_n_s_el, __pyx_n_s_extra); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 733, __pyx_L1_error)
19449   __Pyx_GOTREF(__pyx_tuple__97);
19450   __Pyx_GIVEREF(__pyx_tuple__97);
19451   __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_end_tag, 733, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 733, __pyx_L1_error)
19452
19453   /* "lxml/html/diff.py":742
19454  *     return '</%s>%s' % (el.tag, extra)
19455  * 
19456  * def is_word(tok):             # <<<<<<<<<<<<<<
19457  *     return not tok.startswith('<')
19458  * 
19459  */
19460   __pyx_tuple__99 = PyTuple_Pack(1, __pyx_n_s_tok); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 742, __pyx_L1_error)
19461   __Pyx_GOTREF(__pyx_tuple__99);
19462   __Pyx_GIVEREF(__pyx_tuple__99);
19463   __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_is_word, 742, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(0, 742, __pyx_L1_error)
19464
19465   /* "lxml/html/diff.py":745
19466  *     return not tok.startswith('<')
19467  * 
19468  * def is_end_tag(tok):             # <<<<<<<<<<<<<<
19469  *     return tok.startswith('</')
19470  * 
19471  */
19472   __pyx_tuple__101 = PyTuple_Pack(1, __pyx_n_s_tok); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(0, 745, __pyx_L1_error)
19473   __Pyx_GOTREF(__pyx_tuple__101);
19474   __Pyx_GIVEREF(__pyx_tuple__101);
19475   __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_is_end_tag, 745, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(0, 745, __pyx_L1_error)
19476
19477   /* "lxml/html/diff.py":748
19478  *     return tok.startswith('</')
19479  * 
19480  * def is_start_tag(tok):             # <<<<<<<<<<<<<<
19481  *     return tok.startswith('<') and not tok.startswith('</')
19482  * 
19483  */
19484   __pyx_tuple__103 = PyTuple_Pack(1, __pyx_n_s_tok); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(0, 748, __pyx_L1_error)
19485   __Pyx_GOTREF(__pyx_tuple__103);
19486   __Pyx_GIVEREF(__pyx_tuple__103);
19487   __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_is_start_tag, 748, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(0, 748, __pyx_L1_error)
19488
19489   /* "lxml/html/diff.py":751
19490  *     return tok.startswith('<') and not tok.startswith('</')
19491  * 
19492  * def fixup_ins_del_tags(html):             # <<<<<<<<<<<<<<
19493  *     """ Given an html string, move any <ins> or <del> tags inside of any
19494  *     block-level elements, e.g. transform <ins><p>word</p></ins> to
19495  */
19496   __pyx_tuple__105 = PyTuple_Pack(2, __pyx_n_s_html, __pyx_n_s_doc); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 751, __pyx_L1_error)
19497   __Pyx_GOTREF(__pyx_tuple__105);
19498   __Pyx_GIVEREF(__pyx_tuple__105);
19499   __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_fixup_ins_del_tags, 751, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(0, 751, __pyx_L1_error)
19500
19501   /* "lxml/html/diff.py":760
19502  *     return html
19503  * 
19504  * def serialize_html_fragment(el, skip_outer=False):             # <<<<<<<<<<<<<<
19505  *     """ Serialize a single lxml element as HTML.  The serialized form
19506  *     includes the elements tail.
19507  */
19508   __pyx_tuple__107 = PyTuple_Pack(3, __pyx_n_s_el, __pyx_n_s_skip_outer, __pyx_n_s_html); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 760, __pyx_L1_error)
19509   __Pyx_GOTREF(__pyx_tuple__107);
19510   __Pyx_GIVEREF(__pyx_tuple__107);
19511   __pyx_codeobj__108 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_serialize_html_fragment, 760, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__108)) __PYX_ERR(0, 760, __pyx_L1_error)
19512   __pyx_tuple__109 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 760, __pyx_L1_error)
19513   __Pyx_GOTREF(__pyx_tuple__109);
19514   __Pyx_GIVEREF(__pyx_tuple__109);
19515
19516   /* "lxml/html/diff.py":778
19517  *         return html
19518  * 
19519  * def _fixup_ins_del_tags(doc):             # <<<<<<<<<<<<<<
19520  *     """fixup_ins_del_tags that works on an lxml document in-place
19521  *     """
19522  */
19523   __pyx_tuple__110 = PyTuple_Pack(3, __pyx_n_s_doc, __pyx_n_s_tag, __pyx_n_s_el); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 778, __pyx_L1_error)
19524   __Pyx_GOTREF(__pyx_tuple__110);
19525   __Pyx_GIVEREF(__pyx_tuple__110);
19526   __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_fixup_ins_del_tags_2, 778, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 778, __pyx_L1_error)
19527
19528   /* "lxml/html/diff.py":789
19529  *             #_merge_element_contents(el)
19530  * 
19531  * def _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
19532  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
19533  *     """
19534  */
19535   __pyx_tuple__112 = PyTuple_Pack(2, __pyx_n_s_el, __pyx_n_s_child); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 789, __pyx_L1_error)
19536   __Pyx_GOTREF(__pyx_tuple__112);
19537   __Pyx_GIVEREF(__pyx_tuple__112);
19538   __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_contains_block_level_tag, 789, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(0, 789, __pyx_L1_error)
19539
19540   /* "lxml/html/diff.py":799
19541  *     return False
19542  * 
19543  * def _move_el_inside_block(el, tag):             # <<<<<<<<<<<<<<
19544  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
19545  *     and moves them inside any block-level tags.  """
19546  */
19547   __pyx_tuple__114 = PyTuple_Pack(7, __pyx_n_s_el, __pyx_n_s_tag, __pyx_n_s_child, __pyx_n_s_children_tag, __pyx_n_s_tail_tag, __pyx_n_s_child_tag, __pyx_n_s_text_tag); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 799, __pyx_L1_error)
19548   __Pyx_GOTREF(__pyx_tuple__114);
19549   __Pyx_GIVEREF(__pyx_tuple__114);
19550   __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_move_el_inside_block, 799, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 799, __pyx_L1_error)
19551
19552   /* "lxml/html/diff.py":831
19553  *         el.insert(0, text_tag)
19554  * 
19555  * def _merge_element_contents(el):             # <<<<<<<<<<<<<<
19556  *     """
19557  *     Removes an element, but merges its contents into its place, e.g.,
19558  */
19559   __pyx_tuple__116 = PyTuple_Pack(5, __pyx_n_s_el, __pyx_n_s_parent, __pyx_n_s_text, __pyx_n_s_index, __pyx_n_s_previous); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 831, __pyx_L1_error)
19560   __Pyx_GOTREF(__pyx_tuple__116);
19561   __Pyx_GIVEREF(__pyx_tuple__116);
19562   __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_merge_element_contents, 831, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) __PYX_ERR(0, 831, __pyx_L1_error)
19563
19564   /* "lxml/html/diff.py":873
19565  *     threshold = 2
19566  * 
19567  *     def get_matching_blocks(self):             # <<<<<<<<<<<<<<
19568  *         size = min(len(self.b), len(self.b))
19569  *         threshold = min(self.threshold, size / 4)
19570  */
19571   __pyx_tuple__118 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_size, __pyx_n_s_threshold, __pyx_n_s_actual, __pyx_n_s_item); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 873, __pyx_L1_error)
19572   __Pyx_GOTREF(__pyx_tuple__118);
19573   __Pyx_GIVEREF(__pyx_tuple__118);
19574   __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_lxml_html_diff_py, __pyx_n_s_get_matching_blocks, 873, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(0, 873, __pyx_L1_error)
19575   __Pyx_RefNannyFinishContext();
19576   return 0;
19577   __pyx_L1_error:;
19578   __Pyx_RefNannyFinishContext();
19579   return -1;
19580 }
19581
19582 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
19583   __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
19584   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
19585   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
19586   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
19587   __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
19588   __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
19589   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
19590   return 0;
19591   __pyx_L1_error:;
19592   return -1;
19593 }
19594
19595 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
19596 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
19597 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
19598 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
19599 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
19600 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
19601 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
19602
19603 static int __Pyx_modinit_global_init_code(void) {
19604   __Pyx_RefNannyDeclarations
19605   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
19606   /*--- Global init code ---*/
19607   __Pyx_RefNannyFinishContext();
19608   return 0;
19609 }
19610
19611 static int __Pyx_modinit_variable_export_code(void) {
19612   __Pyx_RefNannyDeclarations
19613   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
19614   /*--- Variable export code ---*/
19615   __Pyx_RefNannyFinishContext();
19616   return 0;
19617 }
19618
19619 static int __Pyx_modinit_function_export_code(void) {
19620   __Pyx_RefNannyDeclarations
19621   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
19622   /*--- Function export code ---*/
19623   __Pyx_RefNannyFinishContext();
19624   return 0;
19625 }
19626
19627 static int __Pyx_modinit_type_init_code(void) {
19628   __Pyx_RefNannyDeclarations
19629   int __pyx_lineno = 0;
19630   const char *__pyx_filename = NULL;
19631   int __pyx_clineno = 0;
19632   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
19633   /*--- Type init code ---*/
19634   if (PyType_Ready(&__pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens) < 0) __PYX_ERR(0, 137, __pyx_L1_error)
19635   #if PY_VERSION_HEX < 0x030800B1
19636   __pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens.tp_print = 0;
19637   #endif
19638   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens.tp_dictoffset && __pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens.tp_getattro == PyObject_GenericGetAttr)) {
19639     __pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
19640   }
19641   __pyx_ptype_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens = &__pyx_type_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens;
19642   if (PyType_Ready(&__pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
19643   #if PY_VERSION_HEX < 0x030800B1
19644   __pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens.tp_print = 0;
19645   #endif
19646   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens.tp_dictoffset && __pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens.tp_getattro == PyObject_GenericGetAttr)) {
19647     __pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
19648   }
19649   __pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens = &__pyx_type_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens;
19650   if (PyType_Ready(&__pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el) < 0) __PYX_ERR(0, 684, __pyx_L1_error)
19651   #if PY_VERSION_HEX < 0x030800B1
19652   __pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el.tp_print = 0;
19653   #endif
19654   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el.tp_dictoffset && __pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el.tp_getattro == PyObject_GenericGetAttr)) {
19655     __pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
19656   }
19657   __pyx_ptype_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el = &__pyx_type_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el;
19658   __Pyx_RefNannyFinishContext();
19659   return 0;
19660   __pyx_L1_error:;
19661   __Pyx_RefNannyFinishContext();
19662   return -1;
19663 }
19664
19665 static int __Pyx_modinit_type_import_code(void) {
19666   __Pyx_RefNannyDeclarations
19667   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
19668   /*--- Type import code ---*/
19669   __Pyx_RefNannyFinishContext();
19670   return 0;
19671 }
19672
19673 static int __Pyx_modinit_variable_import_code(void) {
19674   __Pyx_RefNannyDeclarations
19675   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
19676   /*--- Variable import code ---*/
19677   __Pyx_RefNannyFinishContext();
19678   return 0;
19679 }
19680
19681 static int __Pyx_modinit_function_import_code(void) {
19682   __Pyx_RefNannyDeclarations
19683   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
19684   /*--- Function import code ---*/
19685   __Pyx_RefNannyFinishContext();
19686   return 0;
19687 }
19688
19689
19690 #ifndef CYTHON_NO_PYINIT_EXPORT
19691 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
19692 #elif PY_MAJOR_VERSION < 3
19693 #ifdef __cplusplus
19694 #define __Pyx_PyMODINIT_FUNC extern "C" void
19695 #else
19696 #define __Pyx_PyMODINIT_FUNC void
19697 #endif
19698 #else
19699 #ifdef __cplusplus
19700 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
19701 #else
19702 #define __Pyx_PyMODINIT_FUNC PyObject *
19703 #endif
19704 #endif
19705
19706
19707 #if PY_MAJOR_VERSION < 3
19708 __Pyx_PyMODINIT_FUNC initdiff(void) CYTHON_SMALL_CODE; /*proto*/
19709 __Pyx_PyMODINIT_FUNC initdiff(void)
19710 #else
19711 __Pyx_PyMODINIT_FUNC PyInit_diff(void) CYTHON_SMALL_CODE; /*proto*/
19712 __Pyx_PyMODINIT_FUNC PyInit_diff(void)
19713 #if CYTHON_PEP489_MULTI_PHASE_INIT
19714 {
19715   return PyModuleDef_Init(&__pyx_moduledef);
19716 }
19717 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
19718     #if PY_VERSION_HEX >= 0x030700A1
19719     static PY_INT64_T main_interpreter_id = -1;
19720     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
19721     if (main_interpreter_id == -1) {
19722         main_interpreter_id = current_id;
19723         return (unlikely(current_id == -1)) ? -1 : 0;
19724     } else if (unlikely(main_interpreter_id != current_id))
19725     #else
19726     static PyInterpreterState *main_interpreter = NULL;
19727     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
19728     if (!main_interpreter) {
19729         main_interpreter = current_interpreter;
19730     } else if (unlikely(main_interpreter != current_interpreter))
19731     #endif
19732     {
19733         PyErr_SetString(
19734             PyExc_ImportError,
19735             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
19736         return -1;
19737     }
19738     return 0;
19739 }
19740 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
19741     PyObject *value = PyObject_GetAttrString(spec, from_name);
19742     int result = 0;
19743     if (likely(value)) {
19744         if (allow_none || value != Py_None) {
19745             result = PyDict_SetItemString(moddict, to_name, value);
19746         }
19747         Py_DECREF(value);
19748     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
19749         PyErr_Clear();
19750     } else {
19751         result = -1;
19752     }
19753     return result;
19754 }
19755 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
19756     PyObject *module = NULL, *moddict, *modname;
19757     if (__Pyx_check_single_interpreter())
19758         return NULL;
19759     if (__pyx_m)
19760         return __Pyx_NewRef(__pyx_m);
19761     modname = PyObject_GetAttrString(spec, "name");
19762     if (unlikely(!modname)) goto bad;
19763     module = PyModule_NewObject(modname);
19764     Py_DECREF(modname);
19765     if (unlikely(!module)) goto bad;
19766     moddict = PyModule_GetDict(module);
19767     if (unlikely(!moddict)) goto bad;
19768     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
19769     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
19770     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
19771     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
19772     return module;
19773 bad:
19774     Py_XDECREF(module);
19775     return NULL;
19776 }
19777
19778
19779 static CYTHON_SMALL_CODE int __pyx_pymod_exec_diff(PyObject *__pyx_pyinit_module)
19780 #endif
19781 #endif
19782 {
19783   PyObject *__pyx_t_1 = NULL;
19784   PyObject *__pyx_t_2 = NULL;
19785   PyObject *__pyx_t_3 = NULL;
19786   PyObject *__pyx_t_4 = NULL;
19787   PyObject *__pyx_t_5 = NULL;
19788   int __pyx_t_6;
19789   PyObject *__pyx_t_7 = NULL;
19790   PyObject *__pyx_t_8 = NULL;
19791   PyObject *__pyx_t_9 = NULL;
19792   int __pyx_t_10;
19793   int __pyx_lineno = 0;
19794   const char *__pyx_filename = NULL;
19795   int __pyx_clineno = 0;
19796   __Pyx_RefNannyDeclarations
19797   #if CYTHON_PEP489_MULTI_PHASE_INIT
19798   if (__pyx_m) {
19799     if (__pyx_m == __pyx_pyinit_module) return 0;
19800     PyErr_SetString(PyExc_RuntimeError, "Module 'diff' has already been imported. Re-initialisation is not supported.");
19801     return -1;
19802   }
19803   #elif PY_MAJOR_VERSION >= 3
19804   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
19805   #endif
19806   #if CYTHON_REFNANNY
19807 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
19808 if (!__Pyx_RefNanny) {
19809   PyErr_Clear();
19810   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
19811   if (!__Pyx_RefNanny)
19812       Py_FatalError("failed to import 'refnanny' module");
19813 }
19814 #endif
19815   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_diff(void)", 0);
19816   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19817   #ifdef __Pxy_PyFrame_Initialize_Offsets
19818   __Pxy_PyFrame_Initialize_Offsets();
19819   #endif
19820   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
19821   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
19822   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
19823   #ifdef __Pyx_CyFunction_USED
19824   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19825   #endif
19826   #ifdef __Pyx_FusedFunction_USED
19827   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19828   #endif
19829   #ifdef __Pyx_Coroutine_USED
19830   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19831   #endif
19832   #ifdef __Pyx_Generator_USED
19833   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19834   #endif
19835   #ifdef __Pyx_AsyncGen_USED
19836   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19837   #endif
19838   #ifdef __Pyx_StopAsyncIteration_USED
19839   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19840   #endif
19841   /*--- Library function declarations ---*/
19842   /*--- Threads initialization code ---*/
19843   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
19844   #ifdef WITH_THREAD /* Python build with threading support? */
19845   PyEval_InitThreads();
19846   #endif
19847   #endif
19848   /*--- Module creation code ---*/
19849   #if CYTHON_PEP489_MULTI_PHASE_INIT
19850   __pyx_m = __pyx_pyinit_module;
19851   Py_INCREF(__pyx_m);
19852   #else
19853   #if PY_MAJOR_VERSION < 3
19854   __pyx_m = Py_InitModule4("diff", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
19855   #else
19856   __pyx_m = PyModule_Create(&__pyx_moduledef);
19857   #endif
19858   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
19859   #endif
19860   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
19861   Py_INCREF(__pyx_d);
19862   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
19863   Py_INCREF(__pyx_b);
19864   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
19865   Py_INCREF(__pyx_cython_runtime);
19866   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
19867   /*--- Initialize various global constants etc. ---*/
19868   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19869   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
19870   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19871   #endif
19872   if (__pyx_module_is_main_lxml__html__diff) {
19873     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19874   }
19875   #if PY_MAJOR_VERSION >= 3
19876   {
19877     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
19878     if (!PyDict_GetItemString(modules, "lxml.html.diff")) {
19879       if (unlikely(PyDict_SetItemString(modules, "lxml.html.diff", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
19880     }
19881   }
19882   #endif
19883   /*--- Builtin init code ---*/
19884   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19885   /*--- Constants init code ---*/
19886   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19887   /*--- Global type/function init code ---*/
19888   (void)__Pyx_modinit_global_init_code();
19889   (void)__Pyx_modinit_variable_export_code();
19890   (void)__Pyx_modinit_function_export_code();
19891   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
19892   (void)__Pyx_modinit_type_import_code();
19893   (void)__Pyx_modinit_variable_import_code();
19894   (void)__Pyx_modinit_function_import_code();
19895   /*--- Execution code ---*/
19896   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
19897   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
19898   #endif
19899
19900   /* "lxml/html/diff.py":5
19901  * from __future__ import absolute_import
19902  * 
19903  * import difflib             # <<<<<<<<<<<<<<
19904  * from lxml import etree
19905  * from lxml.html import fragment_fromstring
19906  */
19907   __pyx_t_1 = __Pyx_Import(__pyx_n_s_difflib, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
19908   __Pyx_GOTREF(__pyx_t_1);
19909   if (PyDict_SetItem(__pyx_d, __pyx_n_s_difflib, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
19910   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19911
19912   /* "lxml/html/diff.py":6
19913  * 
19914  * import difflib
19915  * from lxml import etree             # <<<<<<<<<<<<<<
19916  * from lxml.html import fragment_fromstring
19917  * import re
19918  */
19919   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
19920   __Pyx_GOTREF(__pyx_t_1);
19921   __Pyx_INCREF(__pyx_n_s_etree);
19922   __Pyx_GIVEREF(__pyx_n_s_etree);
19923   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_etree);
19924   __pyx_t_2 = __Pyx_Import(__pyx_n_s_lxml, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
19925   __Pyx_GOTREF(__pyx_t_2);
19926   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19927   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_etree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
19928   __Pyx_GOTREF(__pyx_t_1);
19929   if (PyDict_SetItem(__pyx_d, __pyx_n_s_etree, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
19930   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19931   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19932
19933   /* "lxml/html/diff.py":7
19934  * import difflib
19935  * from lxml import etree
19936  * from lxml.html import fragment_fromstring             # <<<<<<<<<<<<<<
19937  * import re
19938  * 
19939  */
19940   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
19941   __Pyx_GOTREF(__pyx_t_2);
19942   __Pyx_INCREF(__pyx_n_s_fragment_fromstring);
19943   __Pyx_GIVEREF(__pyx_n_s_fragment_fromstring);
19944   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_fragment_fromstring);
19945   __pyx_t_1 = __Pyx_Import(__pyx_n_s_lxml_html, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
19946   __Pyx_GOTREF(__pyx_t_1);
19947   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19948   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_fragment_fromstring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
19949   __Pyx_GOTREF(__pyx_t_2);
19950   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fragment_fromstring, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
19951   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19952   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19953
19954   /* "lxml/html/diff.py":8
19955  * from lxml import etree
19956  * from lxml.html import fragment_fromstring
19957  * import re             # <<<<<<<<<<<<<<
19958  * 
19959  * __all__ = ['html_annotate', 'htmldiff']
19960  */
19961   __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
19962   __Pyx_GOTREF(__pyx_t_1);
19963   if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
19964   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19965
19966   /* "lxml/html/diff.py":10
19967  * import re
19968  * 
19969  * __all__ = ['html_annotate', 'htmldiff']             # <<<<<<<<<<<<<<
19970  * 
19971  * try:
19972  */
19973   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
19974   __Pyx_GOTREF(__pyx_t_1);
19975   __Pyx_INCREF(__pyx_n_u_html_annotate);
19976   __Pyx_GIVEREF(__pyx_n_u_html_annotate);
19977   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_html_annotate);
19978   __Pyx_INCREF(__pyx_n_u_htmldiff);
19979   __Pyx_GIVEREF(__pyx_n_u_htmldiff);
19980   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_htmldiff);
19981   if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
19982   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19983
19984   /* "lxml/html/diff.py":12
19985  * __all__ = ['html_annotate', 'htmldiff']
19986  * 
19987  * try:             # <<<<<<<<<<<<<<
19988  *     from html import escape as html_escape
19989  * except ImportError:
19990  */
19991   {
19992     __Pyx_PyThreadState_declare
19993     __Pyx_PyThreadState_assign
19994     __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
19995     __Pyx_XGOTREF(__pyx_t_3);
19996     __Pyx_XGOTREF(__pyx_t_4);
19997     __Pyx_XGOTREF(__pyx_t_5);
19998     /*try:*/ {
19999
20000       /* "lxml/html/diff.py":13
20001  * 
20002  * try:
20003  *     from html import escape as html_escape             # <<<<<<<<<<<<<<
20004  * except ImportError:
20005  *     from cgi import escape as html_escape
20006  */
20007       __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L2_error)
20008       __Pyx_GOTREF(__pyx_t_1);
20009       __Pyx_INCREF(__pyx_n_s_escape);
20010       __Pyx_GIVEREF(__pyx_n_s_escape);
20011       PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_escape);
20012       __pyx_t_2 = __Pyx_Import(__pyx_n_s_html, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L2_error)
20013       __Pyx_GOTREF(__pyx_t_2);
20014       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20015       __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_escape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L2_error)
20016       __Pyx_GOTREF(__pyx_t_1);
20017       if (PyDict_SetItem(__pyx_d, __pyx_n_s_html_escape, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L2_error)
20018       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20019       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20020
20021       /* "lxml/html/diff.py":12
20022  * __all__ = ['html_annotate', 'htmldiff']
20023  * 
20024  * try:             # <<<<<<<<<<<<<<
20025  *     from html import escape as html_escape
20026  * except ImportError:
20027  */
20028     }
20029     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
20030     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
20031     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
20032     goto __pyx_L7_try_end;
20033     __pyx_L2_error:;
20034     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20035     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20036
20037     /* "lxml/html/diff.py":14
20038  * try:
20039  *     from html import escape as html_escape
20040  * except ImportError:             # <<<<<<<<<<<<<<
20041  *     from cgi import escape as html_escape
20042  * try:
20043  */
20044     __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
20045     if (__pyx_t_6) {
20046       __Pyx_AddTraceback("lxml.html.diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
20047       if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 14, __pyx_L4_except_error)
20048       __Pyx_GOTREF(__pyx_t_2);
20049       __Pyx_GOTREF(__pyx_t_1);
20050       __Pyx_GOTREF(__pyx_t_7);
20051
20052       /* "lxml/html/diff.py":15
20053  *     from html import escape as html_escape
20054  * except ImportError:
20055  *     from cgi import escape as html_escape             # <<<<<<<<<<<<<<
20056  * try:
20057  *     _unicode = unicode
20058  */
20059       __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 15, __pyx_L4_except_error)
20060       __Pyx_GOTREF(__pyx_t_8);
20061       __Pyx_INCREF(__pyx_n_s_escape);
20062       __Pyx_GIVEREF(__pyx_n_s_escape);
20063       PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_escape);
20064       __pyx_t_9 = __Pyx_Import(__pyx_n_s_cgi, __pyx_t_8, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 15, __pyx_L4_except_error)
20065       __Pyx_GOTREF(__pyx_t_9);
20066       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
20067       __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_escape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 15, __pyx_L4_except_error)
20068       __Pyx_GOTREF(__pyx_t_8);
20069       if (PyDict_SetItem(__pyx_d, __pyx_n_s_html_escape, __pyx_t_8) < 0) __PYX_ERR(0, 15, __pyx_L4_except_error)
20070       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
20071       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20072       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20073       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20074       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
20075       goto __pyx_L3_exception_handled;
20076     }
20077     goto __pyx_L4_except_error;
20078     __pyx_L4_except_error:;
20079
20080     /* "lxml/html/diff.py":12
20081  * __all__ = ['html_annotate', 'htmldiff']
20082  * 
20083  * try:             # <<<<<<<<<<<<<<
20084  *     from html import escape as html_escape
20085  * except ImportError:
20086  */
20087     __Pyx_XGIVEREF(__pyx_t_3);
20088     __Pyx_XGIVEREF(__pyx_t_4);
20089     __Pyx_XGIVEREF(__pyx_t_5);
20090     __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
20091     goto __pyx_L1_error;
20092     __pyx_L3_exception_handled:;
20093     __Pyx_XGIVEREF(__pyx_t_3);
20094     __Pyx_XGIVEREF(__pyx_t_4);
20095     __Pyx_XGIVEREF(__pyx_t_5);
20096     __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
20097     __pyx_L7_try_end:;
20098   }
20099
20100   /* "lxml/html/diff.py":16
20101  * except ImportError:
20102  *     from cgi import escape as html_escape
20103  * try:             # <<<<<<<<<<<<<<
20104  *     _unicode = unicode
20105  * except NameError:
20106  */
20107   {
20108     __Pyx_PyThreadState_declare
20109     __Pyx_PyThreadState_assign
20110     __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
20111     __Pyx_XGOTREF(__pyx_t_5);
20112     __Pyx_XGOTREF(__pyx_t_4);
20113     __Pyx_XGOTREF(__pyx_t_3);
20114     /*try:*/ {
20115
20116       /* "lxml/html/diff.py":17
20117  *     from cgi import escape as html_escape
20118  * try:
20119  *     _unicode = unicode             # <<<<<<<<<<<<<<
20120  * except NameError:
20121  *     # Python 3
20122  */
20123       if (PyDict_SetItem(__pyx_d, __pyx_n_s_unicode, ((PyObject *)(&PyUnicode_Type))) < 0) __PYX_ERR(0, 17, __pyx_L10_error)
20124
20125       /* "lxml/html/diff.py":16
20126  * except ImportError:
20127  *     from cgi import escape as html_escape
20128  * try:             # <<<<<<<<<<<<<<
20129  *     _unicode = unicode
20130  * except NameError:
20131  */
20132     }
20133     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
20134     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
20135     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
20136     goto __pyx_L15_try_end;
20137     __pyx_L10_error:;
20138     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20139     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20140     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
20141     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
20142     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
20143
20144     /* "lxml/html/diff.py":18
20145  * try:
20146  *     _unicode = unicode
20147  * except NameError:             # <<<<<<<<<<<<<<
20148  *     # Python 3
20149  *     _unicode = str
20150  */
20151     __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NameError);
20152     if (__pyx_t_6) {
20153       __Pyx_AddTraceback("lxml.html.diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
20154       if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L12_except_error)
20155       __Pyx_GOTREF(__pyx_t_7);
20156       __Pyx_GOTREF(__pyx_t_1);
20157       __Pyx_GOTREF(__pyx_t_2);
20158
20159       /* "lxml/html/diff.py":20
20160  * except NameError:
20161  *     # Python 3
20162  *     _unicode = str             # <<<<<<<<<<<<<<
20163  * try:
20164  *     basestring
20165  */
20166       if (PyDict_SetItem(__pyx_d, __pyx_n_s_unicode, ((PyObject *)(&PyUnicode_Type))) < 0) __PYX_ERR(0, 20, __pyx_L12_except_error)
20167       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
20168       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20169       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20170       goto __pyx_L11_exception_handled;
20171     }
20172     goto __pyx_L12_except_error;
20173     __pyx_L12_except_error:;
20174
20175     /* "lxml/html/diff.py":16
20176  * except ImportError:
20177  *     from cgi import escape as html_escape
20178  * try:             # <<<<<<<<<<<<<<
20179  *     _unicode = unicode
20180  * except NameError:
20181  */
20182     __Pyx_XGIVEREF(__pyx_t_5);
20183     __Pyx_XGIVEREF(__pyx_t_4);
20184     __Pyx_XGIVEREF(__pyx_t_3);
20185     __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
20186     goto __pyx_L1_error;
20187     __pyx_L11_exception_handled:;
20188     __Pyx_XGIVEREF(__pyx_t_5);
20189     __Pyx_XGIVEREF(__pyx_t_4);
20190     __Pyx_XGIVEREF(__pyx_t_3);
20191     __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
20192     __pyx_L15_try_end:;
20193   }
20194
20195   /* "lxml/html/diff.py":21
20196  *     # Python 3
20197  *     _unicode = str
20198  * try:             # <<<<<<<<<<<<<<
20199  *     basestring
20200  * except NameError:
20201  */
20202   {
20203     __Pyx_PyThreadState_declare
20204     __Pyx_PyThreadState_assign
20205     __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
20206     __Pyx_XGOTREF(__pyx_t_3);
20207     __Pyx_XGOTREF(__pyx_t_4);
20208     __Pyx_XGOTREF(__pyx_t_5);
20209     /*try:*/ {
20210
20211       /* "lxml/html/diff.py":22
20212  *     _unicode = str
20213  * try:
20214  *     basestring             # <<<<<<<<<<<<<<
20215  * except NameError:
20216  *     # Python 3
20217  */
20218       __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_basestring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L18_error)
20219       __Pyx_GOTREF(__pyx_t_2);
20220       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20221
20222       /* "lxml/html/diff.py":21
20223  *     # Python 3
20224  *     _unicode = str
20225  * try:             # <<<<<<<<<<<<<<
20226  *     basestring
20227  * except NameError:
20228  */
20229     }
20230     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
20231     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
20232     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
20233     goto __pyx_L23_try_end;
20234     __pyx_L18_error:;
20235     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20236     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20237     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
20238     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
20239     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
20240
20241     /* "lxml/html/diff.py":23
20242  * try:
20243  *     basestring
20244  * except NameError:             # <<<<<<<<<<<<<<
20245  *     # Python 3
20246  *     basestring = str
20247  */
20248     __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NameError);
20249     if (__pyx_t_6) {
20250       __Pyx_AddTraceback("lxml.html.diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
20251       if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 23, __pyx_L20_except_error)
20252       __Pyx_GOTREF(__pyx_t_2);
20253       __Pyx_GOTREF(__pyx_t_1);
20254       __Pyx_GOTREF(__pyx_t_7);
20255
20256       /* "lxml/html/diff.py":25
20257  * except NameError:
20258  *     # Python 3
20259  *     basestring = str             # <<<<<<<<<<<<<<
20260  * 
20261  * ############################################################
20262  */
20263       if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, ((PyObject *)(&PyUnicode_Type))) < 0) __PYX_ERR(0, 25, __pyx_L20_except_error)
20264       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
20265       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
20266       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
20267       goto __pyx_L19_exception_handled;
20268     }
20269     goto __pyx_L20_except_error;
20270     __pyx_L20_except_error:;
20271
20272     /* "lxml/html/diff.py":21
20273  *     # Python 3
20274  *     _unicode = str
20275  * try:             # <<<<<<<<<<<<<<
20276  *     basestring
20277  * except NameError:
20278  */
20279     __Pyx_XGIVEREF(__pyx_t_3);
20280     __Pyx_XGIVEREF(__pyx_t_4);
20281     __Pyx_XGIVEREF(__pyx_t_5);
20282     __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
20283     goto __pyx_L1_error;
20284     __pyx_L19_exception_handled:;
20285     __Pyx_XGIVEREF(__pyx_t_3);
20286     __Pyx_XGIVEREF(__pyx_t_4);
20287     __Pyx_XGIVEREF(__pyx_t_5);
20288     __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
20289     __pyx_L23_try_end:;
20290   }
20291
20292   /* "lxml/html/diff.py":31
20293  * ############################################################
20294  * 
20295  * def default_markup(text, version):             # <<<<<<<<<<<<<<
20296  *     return '<span title="%s">%s</span>' % (
20297  *         html_escape(_unicode(version), 1), text)
20298  */
20299   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_1default_markup, 0, __pyx_n_s_default_markup, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 31, __pyx_L1_error)
20300   __Pyx_GOTREF(__pyx_t_7);
20301   if (PyDict_SetItem(__pyx_d, __pyx_n_s_default_markup, __pyx_t_7) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
20302   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20303
20304   /* "lxml/html/diff.py":35
20305  *         html_escape(_unicode(version), 1), text)
20306  * 
20307  * def html_annotate(doclist, markup=default_markup):             # <<<<<<<<<<<<<<
20308  *     """
20309  *     doclist should be ordered from oldest to newest, like::
20310  */
20311   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_3html_annotate, 0, __pyx_n_s_html_annotate, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
20312   __Pyx_GOTREF(__pyx_t_7);
20313   if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults), 1)) __PYX_ERR(0, 35, __pyx_L1_error)
20314   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_default_markup); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
20315   __Pyx_GOTREF(__pyx_t_1);
20316   __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_7)->__pyx_arg_markup = __pyx_t_1;
20317   __Pyx_GIVEREF(__pyx_t_1);
20318   __pyx_t_1 = 0;
20319   __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_4lxml_4html_4diff_75__defaults__);
20320   if (PyDict_SetItem(__pyx_d, __pyx_n_s_html_annotate, __pyx_t_7) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
20321   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20322
20323   /* "lxml/html/diff.py":75
20324  *     return ''.join(result).strip()
20325  * 
20326  * def tokenize_annotated(doc, annotation):             # <<<<<<<<<<<<<<
20327  *     """Tokenize a document and add an annotation attribute to each token
20328  *     """
20329  */
20330   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_5tokenize_annotated, 0, __pyx_n_s_tokenize_annotated, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 75, __pyx_L1_error)
20331   __Pyx_GOTREF(__pyx_t_7);
20332   if (PyDict_SetItem(__pyx_d, __pyx_n_s_tokenize_annotated, __pyx_t_7) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
20333   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20334
20335   /* "lxml/html/diff.py":83
20336  *     return tokens
20337  * 
20338  * def html_annotate_merge_annotations(tokens_old, tokens_new):             # <<<<<<<<<<<<<<
20339  *     """Merge the annotations from tokens_old into tokens_new, when the
20340  *     tokens in the new document already existed in the old document.
20341  */
20342   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_7html_annotate_merge_annotations, 0, __pyx_n_s_html_annotate_merge_annotations, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 83, __pyx_L1_error)
20343   __Pyx_GOTREF(__pyx_t_7);
20344   if (PyDict_SetItem(__pyx_d, __pyx_n_s_html_annotate_merge_annotations, __pyx_t_7) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
20345   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20346
20347   /* "lxml/html/diff.py":96
20348  *             copy_annotations(eq_old, eq_new)
20349  * 
20350  * def copy_annotations(src, dest):             # <<<<<<<<<<<<<<
20351  *     """
20352  *     Copy annotations from the tokens listed in src to the tokens in dest
20353  */
20354   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_9copy_annotations, 0, __pyx_n_s_copy_annotations, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error)
20355   __Pyx_GOTREF(__pyx_t_7);
20356   if (PyDict_SetItem(__pyx_d, __pyx_n_s_copy_annotations, __pyx_t_7) < 0) __PYX_ERR(0, 96, __pyx_L1_error)
20357   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20358
20359   /* "lxml/html/diff.py":104
20360  *         dest_tok.annotation = src_tok.annotation
20361  * 
20362  * def compress_tokens(tokens):             # <<<<<<<<<<<<<<
20363  *     """
20364  *     Combine adjacent tokens when there is no HTML between the tokens,
20365  */
20366   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_11compress_tokens, 0, __pyx_n_s_compress_tokens, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error)
20367   __Pyx_GOTREF(__pyx_t_7);
20368   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compress_tokens, __pyx_t_7) < 0) __PYX_ERR(0, 104, __pyx_L1_error)
20369   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20370
20371   /* "lxml/html/diff.py":119
20372  *     return result
20373  * 
20374  * def compress_merge_back(tokens, tok):             # <<<<<<<<<<<<<<
20375  *     """ Merge tok into the last element of tokens (modifying the list of
20376  *     tokens in-place).  """
20377  */
20378   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_13compress_merge_back, 0, __pyx_n_s_compress_merge_back, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 119, __pyx_L1_error)
20379   __Pyx_GOTREF(__pyx_t_7);
20380   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compress_merge_back, __pyx_t_7) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
20381   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20382
20383   /* "lxml/html/diff.py":137
20384  *         tokens[-1] = merged
20385  * 
20386  * def markup_serialize_tokens(tokens, markup_func):             # <<<<<<<<<<<<<<
20387  *     """
20388  *     Serialize the list of tokens into a list of text chunks, calling
20389  */
20390   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_15markup_serialize_tokens, 0, __pyx_n_s_markup_serialize_tokens, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error)
20391   __Pyx_GOTREF(__pyx_t_7);
20392   if (PyDict_SetItem(__pyx_d, __pyx_n_s_markup_serialize_tokens, __pyx_t_7) < 0) __PYX_ERR(0, 137, __pyx_L1_error)
20393   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20394
20395   /* "lxml/html/diff.py":158
20396  * ############################################################
20397  * 
20398  * def htmldiff(old_html, new_html):             # <<<<<<<<<<<<<<
20399  *     ## FIXME: this should take parsed documents too, and use their body
20400  *     ## or other content.
20401  */
20402   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_18htmldiff, 0, __pyx_n_s_htmldiff, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 158, __pyx_L1_error)
20403   __Pyx_GOTREF(__pyx_t_7);
20404   if (PyDict_SetItem(__pyx_d, __pyx_n_s_htmldiff, __pyx_t_7) < 0) __PYX_ERR(0, 158, __pyx_L1_error)
20405   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20406
20407   /* "lxml/html/diff.py":181
20408  *     return fixup_ins_del_tags(result)
20409  * 
20410  * def htmldiff_tokens(html1_tokens, html2_tokens):             # <<<<<<<<<<<<<<
20411  *     """ Does a diff on the tokens themselves, returning a list of text
20412  *     chunks (not tokens).
20413  */
20414   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_20htmldiff_tokens, 0, __pyx_n_s_htmldiff_tokens, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error)
20415   __Pyx_GOTREF(__pyx_t_7);
20416   if (PyDict_SetItem(__pyx_d, __pyx_n_s_htmldiff_tokens, __pyx_t_7) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
20417   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20418
20419   /* "lxml/html/diff.py":219
20420  *     return result
20421  * 
20422  * def expand_tokens(tokens, equal=False):             # <<<<<<<<<<<<<<
20423  *     """Given a list of tokens, return a generator of the chunks of
20424  *     text for the data in the tokens.
20425  */
20426   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_22expand_tokens, 0, __pyx_n_s_expand_tokens, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 219, __pyx_L1_error)
20427   __Pyx_GOTREF(__pyx_t_7);
20428   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__43);
20429   if (PyDict_SetItem(__pyx_d, __pyx_n_s_expand_tokens, __pyx_t_7) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
20430   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20431
20432   /* "lxml/html/diff.py":234
20433  *             yield post
20434  * 
20435  * def merge_insert(ins_chunks, doc):             # <<<<<<<<<<<<<<
20436  *     """ doc is the already-handled document (as a list of text chunks);
20437  *     here we add <ins>ins_chunks</ins> to the end of that.  """
20438  */
20439   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_25merge_insert, 0, __pyx_n_s_merge_insert, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 234, __pyx_L1_error)
20440   __Pyx_GOTREF(__pyx_t_7);
20441   if (PyDict_SetItem(__pyx_d, __pyx_n_s_merge_insert, __pyx_t_7) < 0) __PYX_ERR(0, 234, __pyx_L1_error)
20442   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20443
20444   /* "lxml/html/diff.py":257
20445  * # segment, until we do the cleanup phase to turn them into proper
20446  * # markup:
20447  * class DEL_START:             # <<<<<<<<<<<<<<
20448  *     pass
20449  * class DEL_END:
20450  */
20451   __pyx_t_7 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_DEL_START, __pyx_n_s_DEL_START, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 257, __pyx_L1_error)
20452   __Pyx_GOTREF(__pyx_t_7);
20453   __pyx_t_1 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_DEL_START, __pyx_empty_tuple, __pyx_t_7, NULL, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error)
20454   __Pyx_GOTREF(__pyx_t_1);
20455   if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEL_START, __pyx_t_1) < 0) __PYX_ERR(0, 257, __pyx_L1_error)
20456   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20457   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20458
20459   /* "lxml/html/diff.py":259
20460  * class DEL_START:
20461  *     pass
20462  * class DEL_END:             # <<<<<<<<<<<<<<
20463  *     pass
20464  * 
20465  */
20466   __pyx_t_7 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_DEL_END, __pyx_n_s_DEL_END, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 259, __pyx_L1_error)
20467   __Pyx_GOTREF(__pyx_t_7);
20468   __pyx_t_1 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_DEL_END, __pyx_empty_tuple, __pyx_t_7, NULL, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
20469   __Pyx_GOTREF(__pyx_t_1);
20470   if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEL_END, __pyx_t_1) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
20471   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20472   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20473
20474   /* "lxml/html/diff.py":262
20475  *     pass
20476  * 
20477  * class NoDeletes(Exception):             # <<<<<<<<<<<<<<
20478  *     """ Raised when the document no longer contains any pending deletes
20479  *     (DEL_START/DEL_END) """
20480  */
20481   __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error)
20482   __Pyx_GOTREF(__pyx_t_7);
20483   __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
20484   __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
20485   PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
20486   __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
20487   __Pyx_GOTREF(__pyx_t_1);
20488   __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __pyx_n_s_NoDeletes, __pyx_n_s_NoDeletes, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, __pyx_kp_s_Raised_when_the_document_no_lon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
20489   __Pyx_GOTREF(__pyx_t_2);
20490   __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_NoDeletes, __pyx_t_7, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 262, __pyx_L1_error)
20491   __Pyx_GOTREF(__pyx_t_9);
20492   if (PyDict_SetItem(__pyx_d, __pyx_n_s_NoDeletes, __pyx_t_9) < 0) __PYX_ERR(0, 262, __pyx_L1_error)
20493   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20494   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20495   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20496   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20497
20498   /* "lxml/html/diff.py":266
20499  *     (DEL_START/DEL_END) """
20500  * 
20501  * def merge_delete(del_chunks, doc):             # <<<<<<<<<<<<<<
20502  *     """ Adds the text chunks in del_chunks to the document doc (another
20503  *     list of text chunks) with marker to show it is a delete.
20504  */
20505   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_27merge_delete, 0, __pyx_n_s_merge_delete, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 266, __pyx_L1_error)
20506   __Pyx_GOTREF(__pyx_t_7);
20507   if (PyDict_SetItem(__pyx_d, __pyx_n_s_merge_delete, __pyx_t_7) < 0) __PYX_ERR(0, 266, __pyx_L1_error)
20508   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20509
20510   /* "lxml/html/diff.py":274
20511  *     doc.append(DEL_END)
20512  * 
20513  * def cleanup_delete(chunks):             # <<<<<<<<<<<<<<
20514  *     """ Cleans up any DEL_START/DEL_END markers in the document, replacing
20515  *     them with <del></del>.  To do this while keeping the document
20516  */
20517   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_29cleanup_delete, 0, __pyx_n_s_cleanup_delete, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L1_error)
20518   __Pyx_GOTREF(__pyx_t_7);
20519   if (PyDict_SetItem(__pyx_d, __pyx_n_s_cleanup_delete, __pyx_t_7) < 0) __PYX_ERR(0, 274, __pyx_L1_error)
20520   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20521
20522   /* "lxml/html/diff.py":313
20523  *     return chunks
20524  * 
20525  * def split_unbalanced(chunks):             # <<<<<<<<<<<<<<
20526  *     """Return (unbalanced_start, balanced, unbalanced_end), where each is
20527  *     a list of text and tag chunks.
20528  */
20529   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_31split_unbalanced, 0, __pyx_n_s_split_unbalanced, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 313, __pyx_L1_error)
20530   __Pyx_GOTREF(__pyx_t_7);
20531   if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_unbalanced, __pyx_t_7) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
20532   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20533
20534   /* "lxml/html/diff.py":353
20535  *     return start, balanced, end
20536  * 
20537  * def split_delete(chunks):             # <<<<<<<<<<<<<<
20538  *     """ Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
20539  *     stuff_after_DEL_END).  Returns the first case found (there may be
20540  */
20541   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_33split_delete, 0, __pyx_n_s_split_delete, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 353, __pyx_L1_error)
20542   __Pyx_GOTREF(__pyx_t_7);
20543   if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_delete, __pyx_t_7) < 0) __PYX_ERR(0, 353, __pyx_L1_error)
20544   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20545
20546   /* "lxml/html/diff.py":365
20547  *     return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
20548  * 
20549  * def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):             # <<<<<<<<<<<<<<
20550  *     """ pre_delete and post_delete implicitly point to a place in the
20551  *     document (where the two were split).  This moves that point (by
20552  */
20553   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_35locate_unbalanced_start, 0, __pyx_n_s_locate_unbalanced_start, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__55)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 365, __pyx_L1_error)
20554   __Pyx_GOTREF(__pyx_t_7);
20555   if (PyDict_SetItem(__pyx_d, __pyx_n_s_locate_unbalanced_start, __pyx_t_7) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
20556   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20557
20558   /* "lxml/html/diff.py":415
20559  *             break
20560  * 
20561  * def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):             # <<<<<<<<<<<<<<
20562  *     """ like locate_unbalanced_start, except handling end tags and
20563  *     possibly moving the point earlier in the document.  """
20564  */
20565   __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_37locate_unbalanced_end, 0, __pyx_n_s_locate_unbalanced_end, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 415, __pyx_L1_error)
20566   __Pyx_GOTREF(__pyx_t_7);
20567   if (PyDict_SetItem(__pyx_d, __pyx_n_s_locate_unbalanced_end, __pyx_t_7) < 0) __PYX_ERR(0, 415, __pyx_L1_error)
20568   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20569
20570   /* "lxml/html/diff.py":441
20571  *             break
20572  * 
20573  * class token(_unicode):             # <<<<<<<<<<<<<<
20574  *     """ Represents a diffable token, generally a word that is displayed to
20575  *     the user.  Opening tags are attached to this token when they are
20576  */
20577   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 441, __pyx_L1_error)
20578   __Pyx_GOTREF(__pyx_t_7);
20579   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error)
20580   __Pyx_GOTREF(__pyx_t_1);
20581   __Pyx_GIVEREF(__pyx_t_7);
20582   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
20583   __pyx_t_7 = 0;
20584   __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 441, __pyx_L1_error)
20585   __Pyx_GOTREF(__pyx_t_7);
20586   __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __pyx_n_s_token, __pyx_n_s_token, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, __pyx_kp_s_Represents_a_diffable_token_gen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 441, __pyx_L1_error)
20587   __Pyx_GOTREF(__pyx_t_2);
20588
20589   /* "lxml/html/diff.py":456
20590  *     # When this is true, the token will be eliminated from the
20591  *     # displayed diff if no change has occurred:
20592  *     hide_when_equal = False             # <<<<<<<<<<<<<<
20593  * 
20594  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):
20595  */
20596   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_hide_when_equal, Py_False) < 0) __PYX_ERR(0, 456, __pyx_L1_error)
20597
20598   /* "lxml/html/diff.py":458
20599  *     hide_when_equal = False
20600  * 
20601  *     def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):             # <<<<<<<<<<<<<<
20602  *         obj = _unicode.__new__(cls, text)
20603  * 
20604  */
20605   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_5token_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_token___new, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 458, __pyx_L1_error)
20606   __Pyx_GOTREF(__pyx_t_9);
20607   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_9, __pyx_tuple__60);
20608   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_new, __pyx_t_9) < 0) __PYX_ERR(0, 458, __pyx_L1_error)
20609   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20610
20611   /* "lxml/html/diff.py":475
20612  *         return obj
20613  * 
20614  *     def __repr__(self):             # <<<<<<<<<<<<<<
20615  *         return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
20616  *                                           self.post_tags, self.trailing_whitespace)
20617  */
20618   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_5token_3__repr__, 0, __pyx_n_s_token___repr, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 475, __pyx_L1_error)
20619   __Pyx_GOTREF(__pyx_t_9);
20620   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_repr, __pyx_t_9) < 0) __PYX_ERR(0, 475, __pyx_L1_error)
20621   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20622
20623   /* "lxml/html/diff.py":479
20624  *                                           self.post_tags, self.trailing_whitespace)
20625  * 
20626  *     def html(self):             # <<<<<<<<<<<<<<
20627  *         return _unicode(self)
20628  * 
20629  */
20630   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_5token_5html, 0, __pyx_n_s_token_html, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
20631   __Pyx_GOTREF(__pyx_t_9);
20632   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_html, __pyx_t_9) < 0) __PYX_ERR(0, 479, __pyx_L1_error)
20633   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20634
20635   /* "lxml/html/diff.py":441
20636  *             break
20637  * 
20638  * class token(_unicode):             # <<<<<<<<<<<<<<
20639  *     """ Represents a diffable token, generally a word that is displayed to
20640  *     the user.  Opening tags are attached to this token when they are
20641  */
20642   __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_token, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 441, __pyx_L1_error)
20643   __Pyx_GOTREF(__pyx_t_9);
20644   if (PyDict_SetItem(__pyx_d, __pyx_n_s_token, __pyx_t_9) < 0) __PYX_ERR(0, 441, __pyx_L1_error)
20645   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20646   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20647   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20648   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20649
20650   /* "lxml/html/diff.py":482
20651  *         return _unicode(self)
20652  * 
20653  * class tag_token(token):             # <<<<<<<<<<<<<<
20654  * 
20655  *     """ Represents a token that is actually a tag.  Currently this is just
20656  */
20657   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
20658   __Pyx_GOTREF(__pyx_t_1);
20659   __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 482, __pyx_L1_error)
20660   __Pyx_GOTREF(__pyx_t_7);
20661   __Pyx_GIVEREF(__pyx_t_1);
20662   PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
20663   __pyx_t_1 = 0;
20664   __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
20665   __Pyx_GOTREF(__pyx_t_1);
20666   __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __pyx_n_s_tag_token_2, __pyx_n_s_tag_token_2, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, __pyx_kp_s_Represents_a_token_that_is_actu); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
20667   __Pyx_GOTREF(__pyx_t_2);
20668
20669   /* "lxml/html/diff.py":488
20670  *     is only represented in a document by a tag.  """
20671  * 
20672  *     def __new__(cls, tag, data, html_repr, pre_tags=None,             # <<<<<<<<<<<<<<
20673  *                 post_tags=None, trailing_whitespace=""):
20674  *         obj = token.__new__(cls, "%s: %s" % (type, data),
20675  */
20676   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_9tag_token_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_tag_token___new, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 488, __pyx_L1_error)
20677   __Pyx_GOTREF(__pyx_t_9);
20678   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_9, __pyx_tuple__67);
20679   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_new, __pyx_t_9) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
20680   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20681
20682   /* "lxml/html/diff.py":499
20683  *         return obj
20684  * 
20685  *     def __repr__(self):             # <<<<<<<<<<<<<<
20686  *         return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
20687  *             self.tag,
20688  */
20689   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_9tag_token_3__repr__, 0, __pyx_n_s_tag_token___repr, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 499, __pyx_L1_error)
20690   __Pyx_GOTREF(__pyx_t_9);
20691   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_repr, __pyx_t_9) < 0) __PYX_ERR(0, 499, __pyx_L1_error)
20692   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20693
20694   /* "lxml/html/diff.py":507
20695  *             self.post_tags,
20696  *             self.trailing_whitespace)
20697  *     def html(self):             # <<<<<<<<<<<<<<
20698  *         return self.html_repr
20699  * 
20700  */
20701   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_9tag_token_5html, 0, __pyx_n_s_tag_token_html, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 507, __pyx_L1_error)
20702   __Pyx_GOTREF(__pyx_t_9);
20703   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_html, __pyx_t_9) < 0) __PYX_ERR(0, 507, __pyx_L1_error)
20704   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20705
20706   /* "lxml/html/diff.py":482
20707  *         return _unicode(self)
20708  * 
20709  * class tag_token(token):             # <<<<<<<<<<<<<<
20710  * 
20711  *     """ Represents a token that is actually a tag.  Currently this is just
20712  */
20713   __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_tag_token_2, __pyx_t_7, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 482, __pyx_L1_error)
20714   __Pyx_GOTREF(__pyx_t_9);
20715   if (PyDict_SetItem(__pyx_d, __pyx_n_s_tag_token_2, __pyx_t_9) < 0) __PYX_ERR(0, 482, __pyx_L1_error)
20716   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20717   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20718   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20719   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20720
20721   /* "lxml/html/diff.py":510
20722  *         return self.html_repr
20723  * 
20724  * class href_token(token):             # <<<<<<<<<<<<<<
20725  * 
20726  *     """ Represents the href in an anchor tag.  Unlike other words, we only
20727  */
20728   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_token); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 510, __pyx_L1_error)
20729   __Pyx_GOTREF(__pyx_t_7);
20730   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
20731   __Pyx_GOTREF(__pyx_t_1);
20732   __Pyx_GIVEREF(__pyx_t_7);
20733   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
20734   __pyx_t_7 = 0;
20735   __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 510, __pyx_L1_error)
20736   __Pyx_GOTREF(__pyx_t_7);
20737   __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __pyx_n_s_href_token, __pyx_n_s_href_token, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, __pyx_kp_s_Represents_the_href_in_an_ancho); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
20738   __Pyx_GOTREF(__pyx_t_2);
20739
20740   /* "lxml/html/diff.py":515
20741  *     show the href when it changes.  """
20742  * 
20743  *     hide_when_equal = True             # <<<<<<<<<<<<<<
20744  * 
20745  *     def html(self):
20746  */
20747   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_hide_when_equal, Py_True) < 0) __PYX_ERR(0, 515, __pyx_L1_error)
20748
20749   /* "lxml/html/diff.py":517
20750  *     hide_when_equal = True
20751  * 
20752  *     def html(self):             # <<<<<<<<<<<<<<
20753  *         return ' Link: %s' % self
20754  * 
20755  */
20756   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_10href_token_1html, 0, __pyx_n_s_href_token_html, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L1_error)
20757   __Pyx_GOTREF(__pyx_t_9);
20758   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_html, __pyx_t_9) < 0) __PYX_ERR(0, 517, __pyx_L1_error)
20759   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20760
20761   /* "lxml/html/diff.py":510
20762  *         return self.html_repr
20763  * 
20764  * class href_token(token):             # <<<<<<<<<<<<<<
20765  * 
20766  *     """ Represents the href in an anchor tag.  Unlike other words, we only
20767  */
20768   __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_href_token, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 510, __pyx_L1_error)
20769   __Pyx_GOTREF(__pyx_t_9);
20770   if (PyDict_SetItem(__pyx_d, __pyx_n_s_href_token, __pyx_t_9) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
20771   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20772   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20773   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20774   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20775
20776   /* "lxml/html/diff.py":520
20777  *         return ' Link: %s' % self
20778  * 
20779  * def tokenize(html, include_hrefs=True):             # <<<<<<<<<<<<<<
20780  *     """
20781  *     Parse the given HTML and returns token objects (words with attached tags).
20782  */
20783   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_39tokenize, 0, __pyx_n_s_tokenize, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error)
20784   __Pyx_GOTREF(__pyx_t_1);
20785   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__76);
20786   if (PyDict_SetItem(__pyx_d, __pyx_n_s_tokenize, __pyx_t_1) < 0) __PYX_ERR(0, 520, __pyx_L1_error)
20787   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20788
20789   /* "lxml/html/diff.py":544
20790  *     return fixup_chunks(chunks)
20791  * 
20792  * def parse_html(html, cleanup=True):             # <<<<<<<<<<<<<<
20793  *     """
20794  *     Parses an HTML fragment, returning an lxml element.  Note that the HTML will be
20795  */
20796   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_41parse_html, 0, __pyx_n_s_parse_html, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 544, __pyx_L1_error)
20797   __Pyx_GOTREF(__pyx_t_1);
20798   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__79);
20799   if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_html, __pyx_t_1) < 0) __PYX_ERR(0, 544, __pyx_L1_error)
20800   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20801
20802   /* "lxml/html/diff.py":557
20803  *     return fragment_fromstring(html, create_parent=True)
20804  * 
20805  * _body_re = re.compile(r'<body.*?>', re.I|re.S)             # <<<<<<<<<<<<<<
20806  * _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
20807  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
20808  */
20809   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
20810   __Pyx_GOTREF(__pyx_t_1);
20811   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 557, __pyx_L1_error)
20812   __Pyx_GOTREF(__pyx_t_7);
20813   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20814   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
20815   __Pyx_GOTREF(__pyx_t_1);
20816   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_I); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 557, __pyx_L1_error)
20817   __Pyx_GOTREF(__pyx_t_2);
20818   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20819   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
20820   __Pyx_GOTREF(__pyx_t_1);
20821   __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_S); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 557, __pyx_L1_error)
20822   __Pyx_GOTREF(__pyx_t_9);
20823   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20824   __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
20825   __Pyx_GOTREF(__pyx_t_1);
20826   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20827   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20828   __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 557, __pyx_L1_error)
20829   __Pyx_GOTREF(__pyx_t_9);
20830   __Pyx_INCREF(__pyx_kp_u_body);
20831   __Pyx_GIVEREF(__pyx_kp_u_body);
20832   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_body);
20833   __Pyx_GIVEREF(__pyx_t_1);
20834   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
20835   __pyx_t_1 = 0;
20836   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
20837   __Pyx_GOTREF(__pyx_t_1);
20838   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20839   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20840   if (PyDict_SetItem(__pyx_d, __pyx_n_s_body_re, __pyx_t_1) < 0) __PYX_ERR(0, 557, __pyx_L1_error)
20841   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20842
20843   /* "lxml/html/diff.py":558
20844  * 
20845  * _body_re = re.compile(r'<body.*?>', re.I|re.S)
20846  * _end_body_re = re.compile(r'</body.*?>', re.I|re.S)             # <<<<<<<<<<<<<<
20847  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
20848  * 
20849  */
20850   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
20851   __Pyx_GOTREF(__pyx_t_1);
20852   __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 558, __pyx_L1_error)
20853   __Pyx_GOTREF(__pyx_t_9);
20854   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20855   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
20856   __Pyx_GOTREF(__pyx_t_1);
20857   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_I); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 558, __pyx_L1_error)
20858   __Pyx_GOTREF(__pyx_t_7);
20859   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20860   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
20861   __Pyx_GOTREF(__pyx_t_1);
20862   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_S); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
20863   __Pyx_GOTREF(__pyx_t_2);
20864   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20865   __pyx_t_1 = PyNumber_Or(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
20866   __Pyx_GOTREF(__pyx_t_1);
20867   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20868   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20869   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
20870   __Pyx_GOTREF(__pyx_t_2);
20871   __Pyx_INCREF(__pyx_kp_u_body_2);
20872   __Pyx_GIVEREF(__pyx_kp_u_body_2);
20873   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_body_2);
20874   __Pyx_GIVEREF(__pyx_t_1);
20875   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
20876   __pyx_t_1 = 0;
20877   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
20878   __Pyx_GOTREF(__pyx_t_1);
20879   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20880   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20881   if (PyDict_SetItem(__pyx_d, __pyx_n_s_end_body_re, __pyx_t_1) < 0) __PYX_ERR(0, 558, __pyx_L1_error)
20882   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20883
20884   /* "lxml/html/diff.py":559
20885  * _body_re = re.compile(r'<body.*?>', re.I|re.S)
20886  * _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
20887  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)             # <<<<<<<<<<<<<<
20888  * 
20889  * def cleanup_html(html):
20890  */
20891   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
20892   __Pyx_GOTREF(__pyx_t_1);
20893   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L1_error)
20894   __Pyx_GOTREF(__pyx_t_2);
20895   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20896   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
20897   __Pyx_GOTREF(__pyx_t_1);
20898   __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_I); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 559, __pyx_L1_error)
20899   __Pyx_GOTREF(__pyx_t_9);
20900   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20901   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
20902   __Pyx_GOTREF(__pyx_t_1);
20903   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_S); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 559, __pyx_L1_error)
20904   __Pyx_GOTREF(__pyx_t_7);
20905   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20906   __pyx_t_1 = PyNumber_Or(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
20907   __Pyx_GOTREF(__pyx_t_1);
20908   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
20909   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20910   __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 559, __pyx_L1_error)
20911   __Pyx_GOTREF(__pyx_t_7);
20912   __Pyx_INCREF(__pyx_kp_u_ins_del);
20913   __Pyx_GIVEREF(__pyx_kp_u_ins_del);
20914   PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_ins_del);
20915   __Pyx_GIVEREF(__pyx_t_1);
20916   PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
20917   __pyx_t_1 = 0;
20918   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
20919   __Pyx_GOTREF(__pyx_t_1);
20920   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20921   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20922   if (PyDict_SetItem(__pyx_d, __pyx_n_s_ins_del_re, __pyx_t_1) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
20923   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20924
20925   /* "lxml/html/diff.py":561
20926  * _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
20927  * 
20928  * def cleanup_html(html):             # <<<<<<<<<<<<<<
20929  *     """ This 'cleans' the HTML, meaning that any page structure is removed
20930  *     (only the contents of <body> are used, if there is any <body).
20931  */
20932   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_43cleanup_html, 0, __pyx_n_s_cleanup_html, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
20933   __Pyx_GOTREF(__pyx_t_1);
20934   if (PyDict_SetItem(__pyx_d, __pyx_n_s_cleanup_html, __pyx_t_1) < 0) __PYX_ERR(0, 561, __pyx_L1_error)
20935   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20936
20937   /* "lxml/html/diff.py":575
20938  * 
20939  * 
20940  * end_whitespace_re = re.compile(r'[ \t\n\r]$')             # <<<<<<<<<<<<<<
20941  * 
20942  * def split_trailing_whitespace(word):
20943  */
20944   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
20945   __Pyx_GOTREF(__pyx_t_1);
20946   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 575, __pyx_L1_error)
20947   __Pyx_GOTREF(__pyx_t_7);
20948   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20949   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
20950   __Pyx_GOTREF(__pyx_t_1);
20951   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20952   if (PyDict_SetItem(__pyx_d, __pyx_n_s_end_whitespace_re, __pyx_t_1) < 0) __PYX_ERR(0, 575, __pyx_L1_error)
20953   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20954
20955   /* "lxml/html/diff.py":577
20956  * end_whitespace_re = re.compile(r'[ \t\n\r]$')
20957  * 
20958  * def split_trailing_whitespace(word):             # <<<<<<<<<<<<<<
20959  *     """
20960  *     This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
20961  */
20962   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_45split_trailing_whitespace, 0, __pyx_n_s_split_trailing_whitespace, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__84)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 577, __pyx_L1_error)
20963   __Pyx_GOTREF(__pyx_t_1);
20964   if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_trailing_whitespace, __pyx_t_1) < 0) __PYX_ERR(0, 577, __pyx_L1_error)
20965   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20966
20967   /* "lxml/html/diff.py":585
20968  * 
20969  * 
20970  * def fixup_chunks(chunks):             # <<<<<<<<<<<<<<
20971  *     """
20972  *     This function takes a list of chunks and produces a list of tokens.
20973  */
20974   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_47fixup_chunks, 0, __pyx_n_s_fixup_chunks, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__86)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 585, __pyx_L1_error)
20975   __Pyx_GOTREF(__pyx_t_1);
20976   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fixup_chunks, __pyx_t_1) < 0) __PYX_ERR(0, 585, __pyx_L1_error)
20977   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20978
20979   /* "lxml/html/diff.py":640
20980  * # All the tags in HTML that don't require end tags:
20981  * empty_tags = (
20982  *     'param', 'img', 'area', 'br', 'basefont', 'input',             # <<<<<<<<<<<<<<
20983  *     'base', 'meta', 'link', 'col')
20984  * 
20985  */
20986   if (PyDict_SetItem(__pyx_d, __pyx_n_s_empty_tags, __pyx_tuple__87) < 0) __PYX_ERR(0, 639, __pyx_L1_error)
20987
20988   /* "lxml/html/diff.py":644
20989  * 
20990  * block_level_tags = (
20991  *     'address',             # <<<<<<<<<<<<<<
20992  *     'blockquote',
20993  *     'center',
20994  */
20995   if (PyDict_SetItem(__pyx_d, __pyx_n_s_block_level_tags, __pyx_tuple__88) < 0) __PYX_ERR(0, 643, __pyx_L1_error)
20996
20997   /* "lxml/html/diff.py":671
20998  * 
20999  * block_level_container_tags = (
21000  *     'dd',             # <<<<<<<<<<<<<<
21001  *     'dt',
21002  *     'frameset',
21003  */
21004   if (PyDict_SetItem(__pyx_d, __pyx_n_s_block_level_container_tags, __pyx_tuple__89) < 0) __PYX_ERR(0, 670, __pyx_L1_error)
21005
21006   /* "lxml/html/diff.py":684
21007  * 
21008  * 
21009  * def flatten_el(el, include_hrefs, skip_tag=False):             # <<<<<<<<<<<<<<
21010  *     """ Takes an lxml element el, and generates all the text chunks for
21011  *     that tag.  Each start tag is a chunk, each word is a chunk, and each
21012  */
21013   __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_49flatten_el, 0, __pyx_n_s_flatten_el, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
21014   __Pyx_GOTREF(__pyx_t_1);
21015   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__91);
21016   if (PyDict_SetItem(__pyx_d, __pyx_n_s_flatten_el, __pyx_t_1) < 0) __PYX_ERR(0, 684, __pyx_L1_error)
21017   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21018
21019   /* "lxml/html/diff.py":712
21020  *             yield html_escape(word)
21021  * 
21022  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)             # <<<<<<<<<<<<<<
21023  * 
21024  * def split_words(text):
21025  */
21026   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
21027   __Pyx_GOTREF(__pyx_t_1);
21028   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 712, __pyx_L1_error)
21029   __Pyx_GOTREF(__pyx_t_7);
21030   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21031   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
21032   __Pyx_GOTREF(__pyx_t_1);
21033   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_U); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
21034   __Pyx_GOTREF(__pyx_t_2);
21035   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21036   __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
21037   __Pyx_GOTREF(__pyx_t_1);
21038   __Pyx_INCREF(__pyx_kp_u_S_s);
21039   __Pyx_GIVEREF(__pyx_kp_u_S_s);
21040   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_S_s);
21041   __Pyx_GIVEREF(__pyx_t_2);
21042   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
21043   __pyx_t_2 = 0;
21044   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
21045   __Pyx_GOTREF(__pyx_t_2);
21046   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
21047   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21048   if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_words_re, __pyx_t_2) < 0) __PYX_ERR(0, 712, __pyx_L1_error)
21049   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21050
21051   /* "lxml/html/diff.py":714
21052  * split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
21053  * 
21054  * def split_words(text):             # <<<<<<<<<<<<<<
21055  *     """ Splits some text into words. Includes trailing whitespace
21056  *     on each word when appropriate.  """
21057  */
21058   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_52split_words, 0, __pyx_n_s_split_words, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__93)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 714, __pyx_L1_error)
21059   __Pyx_GOTREF(__pyx_t_2);
21060   if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_words, __pyx_t_2) < 0) __PYX_ERR(0, 714, __pyx_L1_error)
21061   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21062
21063   /* "lxml/html/diff.py":723
21064  *     return words
21065  * 
21066  * start_whitespace_re = re.compile(r'^[ \t\n\r]')             # <<<<<<<<<<<<<<
21067  * 
21068  * def start_tag(el):
21069  */
21070   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error)
21071   __Pyx_GOTREF(__pyx_t_2);
21072   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
21073   __Pyx_GOTREF(__pyx_t_1);
21074   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21075   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error)
21076   __Pyx_GOTREF(__pyx_t_2);
21077   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21078   if (PyDict_SetItem(__pyx_d, __pyx_n_s_start_whitespace_re, __pyx_t_2) < 0) __PYX_ERR(0, 723, __pyx_L1_error)
21079   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21080
21081   /* "lxml/html/diff.py":725
21082  * start_whitespace_re = re.compile(r'^[ \t\n\r]')
21083  * 
21084  * def start_tag(el):             # <<<<<<<<<<<<<<
21085  *     """
21086  *     The text representation of the start tag for a tag.
21087  */
21088   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_54start_tag, 0, __pyx_n_s_start_tag, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__96)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 725, __pyx_L1_error)
21089   __Pyx_GOTREF(__pyx_t_2);
21090   if (PyDict_SetItem(__pyx_d, __pyx_n_s_start_tag, __pyx_t_2) < 0) __PYX_ERR(0, 725, __pyx_L1_error)
21091   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21092
21093   /* "lxml/html/diff.py":733
21094  *                          for name, value in el.attrib.items()]))
21095  * 
21096  * def end_tag(el):             # <<<<<<<<<<<<<<
21097  *     """ The text representation of an end tag for a tag.  Includes
21098  *     trailing whitespace when appropriate.  """
21099  */
21100   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_56end_tag, 0, __pyx_n_s_end_tag, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__98)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 733, __pyx_L1_error)
21101   __Pyx_GOTREF(__pyx_t_2);
21102   if (PyDict_SetItem(__pyx_d, __pyx_n_s_end_tag, __pyx_t_2) < 0) __PYX_ERR(0, 733, __pyx_L1_error)
21103   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21104
21105   /* "lxml/html/diff.py":742
21106  *     return '</%s>%s' % (el.tag, extra)
21107  * 
21108  * def is_word(tok):             # <<<<<<<<<<<<<<
21109  *     return not tok.startswith('<')
21110  * 
21111  */
21112   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_58is_word, 0, __pyx_n_s_is_word, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__100)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
21113   __Pyx_GOTREF(__pyx_t_2);
21114   if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_word, __pyx_t_2) < 0) __PYX_ERR(0, 742, __pyx_L1_error)
21115   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21116
21117   /* "lxml/html/diff.py":745
21118  *     return not tok.startswith('<')
21119  * 
21120  * def is_end_tag(tok):             # <<<<<<<<<<<<<<
21121  *     return tok.startswith('</')
21122  * 
21123  */
21124   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_60is_end_tag, 0, __pyx_n_s_is_end_tag, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__102)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 745, __pyx_L1_error)
21125   __Pyx_GOTREF(__pyx_t_2);
21126   if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_end_tag, __pyx_t_2) < 0) __PYX_ERR(0, 745, __pyx_L1_error)
21127   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21128
21129   /* "lxml/html/diff.py":748
21130  *     return tok.startswith('</')
21131  * 
21132  * def is_start_tag(tok):             # <<<<<<<<<<<<<<
21133  *     return tok.startswith('<') and not tok.startswith('</')
21134  * 
21135  */
21136   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_62is_start_tag, 0, __pyx_n_s_is_start_tag, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__104)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 748, __pyx_L1_error)
21137   __Pyx_GOTREF(__pyx_t_2);
21138   if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_start_tag, __pyx_t_2) < 0) __PYX_ERR(0, 748, __pyx_L1_error)
21139   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21140
21141   /* "lxml/html/diff.py":751
21142  *     return tok.startswith('<') and not tok.startswith('</')
21143  * 
21144  * def fixup_ins_del_tags(html):             # <<<<<<<<<<<<<<
21145  *     """ Given an html string, move any <ins> or <del> tags inside of any
21146  *     block-level elements, e.g. transform <ins><p>word</p></ins> to
21147  */
21148   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_64fixup_ins_del_tags, 0, __pyx_n_s_fixup_ins_del_tags, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__106)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error)
21149   __Pyx_GOTREF(__pyx_t_2);
21150   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fixup_ins_del_tags, __pyx_t_2) < 0) __PYX_ERR(0, 751, __pyx_L1_error)
21151   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21152
21153   /* "lxml/html/diff.py":760
21154  *     return html
21155  * 
21156  * def serialize_html_fragment(el, skip_outer=False):             # <<<<<<<<<<<<<<
21157  *     """ Serialize a single lxml element as HTML.  The serialized form
21158  *     includes the elements tail.
21159  */
21160   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_66serialize_html_fragment, 0, __pyx_n_s_serialize_html_fragment, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__108)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
21161   __Pyx_GOTREF(__pyx_t_2);
21162   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__109);
21163   if (PyDict_SetItem(__pyx_d, __pyx_n_s_serialize_html_fragment, __pyx_t_2) < 0) __PYX_ERR(0, 760, __pyx_L1_error)
21164   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21165
21166   /* "lxml/html/diff.py":778
21167  *         return html
21168  * 
21169  * def _fixup_ins_del_tags(doc):             # <<<<<<<<<<<<<<
21170  *     """fixup_ins_del_tags that works on an lxml document in-place
21171  *     """
21172  */
21173   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_68_fixup_ins_del_tags, 0, __pyx_n_s_fixup_ins_del_tags_2, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__111)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 778, __pyx_L1_error)
21174   __Pyx_GOTREF(__pyx_t_2);
21175   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fixup_ins_del_tags_2, __pyx_t_2) < 0) __PYX_ERR(0, 778, __pyx_L1_error)
21176   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21177
21178   /* "lxml/html/diff.py":789
21179  *             #_merge_element_contents(el)
21180  * 
21181  * def _contains_block_level_tag(el):             # <<<<<<<<<<<<<<
21182  *     """True if the element contains any block-level elements, like <p>, <td>, etc.
21183  *     """
21184  */
21185   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_70_contains_block_level_tag, 0, __pyx_n_s_contains_block_level_tag, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__113)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error)
21186   __Pyx_GOTREF(__pyx_t_2);
21187   if (PyDict_SetItem(__pyx_d, __pyx_n_s_contains_block_level_tag, __pyx_t_2) < 0) __PYX_ERR(0, 789, __pyx_L1_error)
21188   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21189
21190   /* "lxml/html/diff.py":799
21191  *     return False
21192  * 
21193  * def _move_el_inside_block(el, tag):             # <<<<<<<<<<<<<<
21194  *     """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
21195  *     and moves them inside any block-level tags.  """
21196  */
21197   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_72_move_el_inside_block, 0, __pyx_n_s_move_el_inside_block, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__115)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 799, __pyx_L1_error)
21198   __Pyx_GOTREF(__pyx_t_2);
21199   if (PyDict_SetItem(__pyx_d, __pyx_n_s_move_el_inside_block, __pyx_t_2) < 0) __PYX_ERR(0, 799, __pyx_L1_error)
21200   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21201
21202   /* "lxml/html/diff.py":831
21203  *         el.insert(0, text_tag)
21204  * 
21205  * def _merge_element_contents(el):             # <<<<<<<<<<<<<<
21206  *     """
21207  *     Removes an element, but merges its contents into its place, e.g.,
21208  */
21209   __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_74_merge_element_contents, 0, __pyx_n_s_merge_element_contents, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__117)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 831, __pyx_L1_error)
21210   __Pyx_GOTREF(__pyx_t_2);
21211   if (PyDict_SetItem(__pyx_d, __pyx_n_s_merge_element_contents, __pyx_t_2) < 0) __PYX_ERR(0, 831, __pyx_L1_error)
21212   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21213
21214   /* "lxml/html/diff.py":865
21215  *     parent[index:index+1] = el.getchildren()
21216  * 
21217  * class InsensitiveSequenceMatcher(difflib.SequenceMatcher):             # <<<<<<<<<<<<<<
21218  *     """
21219  *     Acts like SequenceMatcher, but tries not to find very small equal
21220  */
21221   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_difflib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 865, __pyx_L1_error)
21222   __Pyx_GOTREF(__pyx_t_2);
21223   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SequenceMatcher); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
21224   __Pyx_GOTREF(__pyx_t_1);
21225   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21226   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 865, __pyx_L1_error)
21227   __Pyx_GOTREF(__pyx_t_2);
21228   __Pyx_GIVEREF(__pyx_t_1);
21229   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
21230   __pyx_t_1 = 0;
21231   __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
21232   __Pyx_GOTREF(__pyx_t_1);
21233   __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_InsensitiveSequenceMatcher, __pyx_n_s_InsensitiveSequenceMatcher, (PyObject *) NULL, __pyx_n_s_lxml_html_diff, __pyx_kp_s_Acts_like_SequenceMatcher_but_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 865, __pyx_L1_error)
21234   __Pyx_GOTREF(__pyx_t_7);
21235
21236   /* "lxml/html/diff.py":871
21237  *     """
21238  * 
21239  *     threshold = 2             # <<<<<<<<<<<<<<
21240  * 
21241  *     def get_matching_blocks(self):
21242  */
21243   if (__Pyx_SetNameInClass(__pyx_t_7, __pyx_n_s_threshold, __pyx_int_2) < 0) __PYX_ERR(0, 871, __pyx_L1_error)
21244
21245   /* "lxml/html/diff.py":873
21246  *     threshold = 2
21247  * 
21248  *     def get_matching_blocks(self):             # <<<<<<<<<<<<<<
21249  *         size = min(len(self.b), len(self.b))
21250  *         threshold = min(self.threshold, size / 4)
21251  */
21252   __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_4lxml_4html_4diff_26InsensitiveSequenceMatcher_1get_matching_blocks, 0, __pyx_n_s_InsensitiveSequenceMatcher_get_m, NULL, __pyx_n_s_lxml_html_diff, __pyx_d, ((PyObject *)__pyx_codeobj__119)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 873, __pyx_L1_error)
21253   __Pyx_GOTREF(__pyx_t_9);
21254   if (__Pyx_SetNameInClass(__pyx_t_7, __pyx_n_s_get_matching_blocks, __pyx_t_9) < 0) __PYX_ERR(0, 873, __pyx_L1_error)
21255   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21256
21257   /* "lxml/html/diff.py":865
21258  *     parent[index:index+1] = el.getchildren()
21259  * 
21260  * class InsensitiveSequenceMatcher(difflib.SequenceMatcher):             # <<<<<<<<<<<<<<
21261  *     """
21262  *     Acts like SequenceMatcher, but tries not to find very small equal
21263  */
21264   __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_InsensitiveSequenceMatcher, __pyx_t_2, __pyx_t_7, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 865, __pyx_L1_error)
21265   __Pyx_GOTREF(__pyx_t_9);
21266   if (PyDict_SetItem(__pyx_d, __pyx_n_s_InsensitiveSequenceMatcher, __pyx_t_9) < 0) __PYX_ERR(0, 865, __pyx_L1_error)
21267   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21268   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
21269   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21270   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21271
21272   /* "lxml/html/diff.py":881
21273  *                 or not item[2]]
21274  * 
21275  * if __name__ == '__main__':             # <<<<<<<<<<<<<<
21276  *     from lxml.html import _diffcommand
21277  *     _diffcommand.main()
21278  */
21279   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 881, __pyx_L1_error)
21280   __Pyx_GOTREF(__pyx_t_2);
21281   __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_main, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 881, __pyx_L1_error)
21282   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21283   if (__pyx_t_10) {
21284
21285     /* "lxml/html/diff.py":882
21286  * 
21287  * if __name__ == '__main__':
21288  *     from lxml.html import _diffcommand             # <<<<<<<<<<<<<<
21289  *     _diffcommand.main()
21290  * 
21291  */
21292     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 882, __pyx_L1_error)
21293     __Pyx_GOTREF(__pyx_t_2);
21294     __Pyx_INCREF(__pyx_n_s_diffcommand);
21295     __Pyx_GIVEREF(__pyx_n_s_diffcommand);
21296     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_diffcommand);
21297     __pyx_t_1 = __Pyx_Import(__pyx_n_s_lxml_html, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
21298     __Pyx_GOTREF(__pyx_t_1);
21299     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21300     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_diffcommand); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 882, __pyx_L1_error)
21301     __Pyx_GOTREF(__pyx_t_2);
21302     if (PyDict_SetItem(__pyx_d, __pyx_n_s_diffcommand, __pyx_t_2) < 0) __PYX_ERR(0, 882, __pyx_L1_error)
21303     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21304     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21305
21306     /* "lxml/html/diff.py":883
21307  * if __name__ == '__main__':
21308  *     from lxml.html import _diffcommand
21309  *     _diffcommand.main()             # <<<<<<<<<<<<<<
21310  * 
21311  */
21312     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_diffcommand); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 883, __pyx_L1_error)
21313     __Pyx_GOTREF(__pyx_t_1);
21314     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_main_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error)
21315     __Pyx_GOTREF(__pyx_t_2);
21316     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21317     __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 883, __pyx_L1_error)
21318     __Pyx_GOTREF(__pyx_t_1);
21319     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21320     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21321
21322     /* "lxml/html/diff.py":881
21323  *                 or not item[2]]
21324  * 
21325  * if __name__ == '__main__':             # <<<<<<<<<<<<<<
21326  *     from lxml.html import _diffcommand
21327  *     _diffcommand.main()
21328  */
21329   }
21330
21331   /* "lxml/html/diff.py":1
21332  * # cython: language_level=3             # <<<<<<<<<<<<<<
21333  * 
21334  * from __future__ import absolute_import
21335  */
21336   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
21337   __Pyx_GOTREF(__pyx_t_1);
21338   if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_html_annotate_line_35, __pyx_kp_u_doclist_should_be_ordered_from) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
21339   if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_locate_unbalanced_start_line_365, __pyx_kp_u_pre_delete_and_post_delete_impl) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
21340   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
21341   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21342
21343   /*--- Wrapped vars code ---*/
21344
21345   if (__Pyx_RegisterCleanup()) __PYX_ERR(0, 1, __pyx_L1_error);
21346   goto __pyx_L0;
21347   __pyx_L1_error:;
21348   __Pyx_XDECREF(__pyx_t_1);
21349   __Pyx_XDECREF(__pyx_t_2);
21350   __Pyx_XDECREF(__pyx_t_7);
21351   __Pyx_XDECREF(__pyx_t_8);
21352   __Pyx_XDECREF(__pyx_t_9);
21353   if (__pyx_m) {
21354     if (__pyx_d) {
21355       __Pyx_AddTraceback("init lxml.html.diff", __pyx_clineno, __pyx_lineno, __pyx_filename);
21356     }
21357     Py_CLEAR(__pyx_m);
21358   } else if (!PyErr_Occurred()) {
21359     PyErr_SetString(PyExc_ImportError, "init lxml.html.diff");
21360   }
21361   __pyx_L0:;
21362   __Pyx_RefNannyFinishContext();
21363   #if CYTHON_PEP489_MULTI_PHASE_INIT
21364   return (__pyx_m != NULL) ? 0 : -1;
21365   #elif PY_MAJOR_VERSION >= 3
21366   return __pyx_m;
21367   #else
21368   return;
21369   #endif
21370 }
21371
21372 static CYTHON_SMALL_CODE void __Pyx_CleanupGlobals(void) {
21373   Py_CLEAR(__pyx_slice__3);
21374   Py_CLEAR(__pyx_codeobj__4);
21375   Py_CLEAR(__pyx_codeobj__5);
21376   Py_CLEAR(__pyx_slice__7);
21377   Py_CLEAR(__pyx_tuple__16);
21378   Py_CLEAR(__pyx_codeobj__17);
21379   Py_CLEAR(__pyx_tuple__21);
21380   Py_CLEAR(__pyx_slice__22);
21381   Py_CLEAR(__pyx_tuple__23);
21382   Py_CLEAR(__pyx_codeobj__24);
21383   Py_CLEAR(__pyx_tuple__25);
21384   Py_CLEAR(__pyx_codeobj__26);
21385   Py_CLEAR(__pyx_tuple__27);
21386   Py_CLEAR(__pyx_codeobj__28);
21387   Py_CLEAR(__pyx_tuple__29);
21388   Py_CLEAR(__pyx_codeobj__30);
21389   Py_CLEAR(__pyx_tuple__31);
21390   Py_CLEAR(__pyx_codeobj__32);
21391   Py_CLEAR(__pyx_tuple__33);
21392   Py_CLEAR(__pyx_codeobj__34);
21393   Py_CLEAR(__pyx_tuple__35);
21394   Py_CLEAR(__pyx_codeobj__36);
21395   Py_CLEAR(__pyx_tuple__37);
21396   Py_CLEAR(__pyx_tuple__38);
21397   Py_CLEAR(__pyx_codeobj__39);
21398   Py_CLEAR(__pyx_tuple__40);
21399   Py_CLEAR(__pyx_codeobj__41);
21400   Py_CLEAR(__pyx_tuple__42);
21401   Py_CLEAR(__pyx_tuple__43);
21402   Py_CLEAR(__pyx_tuple__44);
21403   Py_CLEAR(__pyx_codeobj__45);
21404   Py_CLEAR(__pyx_tuple__46);
21405   Py_CLEAR(__pyx_codeobj__47);
21406   Py_CLEAR(__pyx_tuple__48);
21407   Py_CLEAR(__pyx_codeobj__49);
21408   Py_CLEAR(__pyx_tuple__50);
21409   Py_CLEAR(__pyx_codeobj__51);
21410   Py_CLEAR(__pyx_tuple__52);
21411   Py_CLEAR(__pyx_codeobj__53);
21412   Py_CLEAR(__pyx_tuple__54);
21413   Py_CLEAR(__pyx_codeobj__55);
21414   Py_CLEAR(__pyx_tuple__56);
21415   Py_CLEAR(__pyx_codeobj__57);
21416   Py_CLEAR(__pyx_tuple__58);
21417   Py_CLEAR(__pyx_codeobj__59);
21418   Py_CLEAR(__pyx_tuple__60);
21419   Py_CLEAR(__pyx_tuple__61);
21420   Py_CLEAR(__pyx_codeobj__62);
21421   Py_CLEAR(__pyx_tuple__63);
21422   Py_CLEAR(__pyx_codeobj__64);
21423   Py_CLEAR(__pyx_tuple__65);
21424   Py_CLEAR(__pyx_codeobj__66);
21425   Py_CLEAR(__pyx_tuple__67);
21426   Py_CLEAR(__pyx_tuple__68);
21427   Py_CLEAR(__pyx_codeobj__69);
21428   Py_CLEAR(__pyx_tuple__70);
21429   Py_CLEAR(__pyx_codeobj__71);
21430   Py_CLEAR(__pyx_tuple__72);
21431   Py_CLEAR(__pyx_codeobj__73);
21432   Py_CLEAR(__pyx_tuple__74);
21433   Py_CLEAR(__pyx_codeobj__75);
21434   Py_CLEAR(__pyx_tuple__76);
21435   Py_CLEAR(__pyx_tuple__77);
21436   Py_CLEAR(__pyx_codeobj__78);
21437   Py_CLEAR(__pyx_tuple__79);
21438   Py_CLEAR(__pyx_tuple__80);
21439   Py_CLEAR(__pyx_codeobj__81);
21440   Py_CLEAR(__pyx_tuple__82);
21441   Py_CLEAR(__pyx_tuple__83);
21442   Py_CLEAR(__pyx_codeobj__84);
21443   Py_CLEAR(__pyx_tuple__85);
21444   Py_CLEAR(__pyx_codeobj__86);
21445   Py_CLEAR(__pyx_tuple__87);
21446   Py_CLEAR(__pyx_tuple__88);
21447   Py_CLEAR(__pyx_tuple__89);
21448   Py_CLEAR(__pyx_tuple__90);
21449   Py_CLEAR(__pyx_tuple__91);
21450   Py_CLEAR(__pyx_tuple__92);
21451   Py_CLEAR(__pyx_codeobj__93);
21452   Py_CLEAR(__pyx_tuple__94);
21453   Py_CLEAR(__pyx_tuple__95);
21454   Py_CLEAR(__pyx_codeobj__96);
21455   Py_CLEAR(__pyx_tuple__97);
21456   Py_CLEAR(__pyx_codeobj__98);
21457   Py_CLEAR(__pyx_tuple__99);
21458   Py_CLEAR(__pyx_codeobj__100);
21459   Py_CLEAR(__pyx_tuple__101);
21460   Py_CLEAR(__pyx_codeobj__102);
21461   Py_CLEAR(__pyx_tuple__103);
21462   Py_CLEAR(__pyx_codeobj__104);
21463   Py_CLEAR(__pyx_tuple__105);
21464   Py_CLEAR(__pyx_codeobj__106);
21465   Py_CLEAR(__pyx_tuple__107);
21466   Py_CLEAR(__pyx_codeobj__108);
21467   Py_CLEAR(__pyx_tuple__109);
21468   Py_CLEAR(__pyx_tuple__110);
21469   Py_CLEAR(__pyx_codeobj__111);
21470   Py_CLEAR(__pyx_tuple__112);
21471   Py_CLEAR(__pyx_codeobj__113);
21472   Py_CLEAR(__pyx_tuple__114);
21473   Py_CLEAR(__pyx_codeobj__115);
21474   Py_CLEAR(__pyx_tuple__116);
21475   Py_CLEAR(__pyx_codeobj__117);
21476   Py_CLEAR(__pyx_tuple__118);
21477   Py_CLEAR(__pyx_codeobj__119);
21478   /* CodeObjectCache.cleanup */
21479   if (__pyx_code_cache.entries) {
21480       __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
21481       int i, count = __pyx_code_cache.count;
21482       __pyx_code_cache.count = 0;
21483       __pyx_code_cache.max_count = 0;
21484       __pyx_code_cache.entries = NULL;
21485       for (i=0; i<count; i++) {
21486           Py_DECREF(entries[i].code_object);
21487       }
21488       PyMem_Free(entries);
21489   }
21490
21491 Py_CLEAR(__pyx_umethod_PyList_Type_pop.method);
21492 }
21493 static void __pyx_module_cleanup(CYTHON_UNUSED PyObject *self) {
21494   /*--- Global cleanup code ---*/
21495   __Pyx_CleanupGlobals();
21496   /*--- Type import cleanup code ---*/
21497   /*--- Builtin cleanup code ---*/
21498   Py_CLEAR(__pyx_builtin_ImportError);
21499   Py_CLEAR(__pyx_builtin_NameError);
21500   Py_CLEAR(__pyx_builtin_zip);
21501   Py_CLEAR(__pyx_builtin_ValueError);
21502   /*--- Intern cleanup code ---*/
21503   Py_CLEAR(__pyx_empty_tuple);
21504   while (__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens > 0) {
21505     PyObject* o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct__markup_serialize_tokens];
21506     (*Py_TYPE(o)->tp_free)(o);
21507   }
21508   while (__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens > 0) {
21509     PyObject* o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_1_expand_tokens];
21510     (*Py_TYPE(o)->tp_free)(o);
21511   }
21512   while (__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el > 0) {
21513     PyObject* o = (PyObject*)__pyx_freelist_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el[--__pyx_freecount_4lxml_4html_4diff___pyx_scope_struct_2_flatten_el];
21514     (*Py_TYPE(o)->tp_free)(o);
21515   }
21516   Py_CLEAR(__pyx_d);
21517   Py_CLEAR(__pyx_cython_runtime);
21518   Py_CLEAR(__pyx_b);
21519 }
21520
21521 /* --- Runtime support code --- */
21522 /* Refnanny */
21523 #if CYTHON_REFNANNY
21524 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
21525     PyObject *m = NULL, *p = NULL;
21526     void *r = NULL;
21527     m = PyImport_ImportModule(modname);
21528     if (!m) goto end;
21529     p = PyObject_GetAttrString(m, "RefNannyAPI");
21530     if (!p) goto end;
21531     r = PyLong_AsVoidPtr(p);
21532 end:
21533     Py_XDECREF(p);
21534     Py_XDECREF(m);
21535     return (__Pyx_RefNannyAPIStruct *)r;
21536 }
21537 #endif
21538
21539 /* PyObjectGetAttrStr */
21540 #if CYTHON_USE_TYPE_SLOTS
21541 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
21542     PyTypeObject* tp = Py_TYPE(obj);
21543     if (likely(tp->tp_getattro))
21544         return tp->tp_getattro(obj, attr_name);
21545 #if PY_MAJOR_VERSION < 3
21546     if (likely(tp->tp_getattr))
21547         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
21548 #endif
21549     return PyObject_GetAttr(obj, attr_name);
21550 }
21551 #endif
21552
21553 /* GetBuiltinName */
21554 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
21555     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
21556     if (unlikely(!result)) {
21557         PyErr_Format(PyExc_NameError,
21558 #if PY_MAJOR_VERSION >= 3
21559             "name '%U' is not defined", name);
21560 #else
21561             "name '%.200s' is not defined", PyString_AS_STRING(name));
21562 #endif
21563     }
21564     return result;
21565 }
21566
21567 /* RaiseArgTupleInvalid */
21568 static void __Pyx_RaiseArgtupleInvalid(
21569     const char* func_name,
21570     int exact,
21571     Py_ssize_t num_min,
21572     Py_ssize_t num_max,
21573     Py_ssize_t num_found)
21574 {
21575     Py_ssize_t num_expected;
21576     const char *more_or_less;
21577     if (num_found < num_min) {
21578         num_expected = num_min;
21579         more_or_less = "at least";
21580     } else {
21581         num_expected = num_max;
21582         more_or_less = "at most";
21583     }
21584     if (exact) {
21585         more_or_less = "exactly";
21586     }
21587     PyErr_Format(PyExc_TypeError,
21588                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
21589                  func_name, more_or_less, num_expected,
21590                  (num_expected == 1) ? "" : "s", num_found);
21591 }
21592
21593 /* RaiseDoubleKeywords */
21594 static void __Pyx_RaiseDoubleKeywordsError(
21595     const char* func_name,
21596     PyObject* kw_name)
21597 {
21598     PyErr_Format(PyExc_TypeError,
21599         #if PY_MAJOR_VERSION >= 3
21600         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
21601         #else
21602         "%s() got multiple values for keyword argument '%s'", func_name,
21603         PyString_AsString(kw_name));
21604         #endif
21605 }
21606
21607 /* ParseKeywords */
21608 static int __Pyx_ParseOptionalKeywords(
21609     PyObject *kwds,
21610     PyObject **argnames[],
21611     PyObject *kwds2,
21612     PyObject *values[],
21613     Py_ssize_t num_pos_args,
21614     const char* function_name)
21615 {
21616     PyObject *key = 0, *value = 0;
21617     Py_ssize_t pos = 0;
21618     PyObject*** name;
21619     PyObject*** first_kw_arg = argnames + num_pos_args;
21620     while (PyDict_Next(kwds, &pos, &key, &value)) {
21621         name = first_kw_arg;
21622         while (*name && (**name != key)) name++;
21623         if (*name) {
21624             values[name-argnames] = value;
21625             continue;
21626         }
21627         name = first_kw_arg;
21628         #if PY_MAJOR_VERSION < 3
21629         if (likely(PyString_Check(key))) {
21630             while (*name) {
21631                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
21632                         && _PyString_Eq(**name, key)) {
21633                     values[name-argnames] = value;
21634                     break;
21635                 }
21636                 name++;
21637             }
21638             if (*name) continue;
21639             else {
21640                 PyObject*** argname = argnames;
21641                 while (argname != first_kw_arg) {
21642                     if ((**argname == key) || (
21643                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
21644                              && _PyString_Eq(**argname, key))) {
21645                         goto arg_passed_twice;
21646                     }
21647                     argname++;
21648                 }
21649             }
21650         } else
21651         #endif
21652         if (likely(PyUnicode_Check(key))) {
21653             while (*name) {
21654                 int cmp = (**name == key) ? 0 :
21655                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
21656                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
21657                 #endif
21658                     PyUnicode_Compare(**name, key);
21659                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
21660                 if (cmp == 0) {
21661                     values[name-argnames] = value;
21662                     break;
21663                 }
21664                 name++;
21665             }
21666             if (*name) continue;
21667             else {
21668                 PyObject*** argname = argnames;
21669                 while (argname != first_kw_arg) {
21670                     int cmp = (**argname == key) ? 0 :
21671                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
21672                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
21673                     #endif
21674                         PyUnicode_Compare(**argname, key);
21675                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
21676                     if (cmp == 0) goto arg_passed_twice;
21677                     argname++;
21678                 }
21679             }
21680         } else
21681             goto invalid_keyword_type;
21682         if (kwds2) {
21683             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
21684         } else {
21685             goto invalid_keyword;
21686         }
21687     }
21688     return 0;
21689 arg_passed_twice:
21690     __Pyx_RaiseDoubleKeywordsError(function_name, key);
21691     goto bad;
21692 invalid_keyword_type:
21693     PyErr_Format(PyExc_TypeError,
21694         "%.200s() keywords must be strings", function_name);
21695     goto bad;
21696 invalid_keyword:
21697     PyErr_Format(PyExc_TypeError,
21698     #if PY_MAJOR_VERSION < 3
21699         "%.200s() got an unexpected keyword argument '%.200s'",
21700         function_name, PyString_AsString(key));
21701     #else
21702         "%s() got an unexpected keyword argument '%U'",
21703         function_name, key);
21704     #endif
21705 bad:
21706     return -1;
21707 }
21708
21709 /* PyDictVersioning */
21710 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
21711 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
21712     PyObject *dict = Py_TYPE(obj)->tp_dict;
21713     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
21714 }
21715 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
21716     PyObject **dictptr = NULL;
21717     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
21718     if (offset) {
21719 #if CYTHON_COMPILING_IN_CPYTHON
21720         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
21721 #else
21722         dictptr = _PyObject_GetDictPtr(obj);
21723 #endif
21724     }
21725     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
21726 }
21727 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
21728     PyObject *dict = Py_TYPE(obj)->tp_dict;
21729     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
21730         return 0;
21731     return obj_dict_version == __Pyx_get_object_dict_version(obj);
21732 }
21733 #endif
21734
21735 /* GetModuleGlobalName */
21736 #if CYTHON_USE_DICT_VERSIONS
21737 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
21738 #else
21739 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
21740 #endif
21741 {
21742     PyObject *result;
21743 #if !CYTHON_AVOID_BORROWED_REFS
21744 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
21745     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
21746     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
21747     if (likely(result)) {
21748         return __Pyx_NewRef(result);
21749     } else if (unlikely(PyErr_Occurred())) {
21750         return NULL;
21751     }
21752 #else
21753     result = PyDict_GetItem(__pyx_d, name);
21754     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
21755     if (likely(result)) {
21756         return __Pyx_NewRef(result);
21757     }
21758 #endif
21759 #else
21760     result = PyObject_GetItem(__pyx_d, name);
21761     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
21762     if (likely(result)) {
21763         return __Pyx_NewRef(result);
21764     }
21765     PyErr_Clear();
21766 #endif
21767     return __Pyx_GetBuiltinName(name);
21768 }
21769
21770 /* PyCFunctionFastCall */
21771 #if CYTHON_FAST_PYCCALL
21772 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
21773     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
21774     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
21775     PyObject *self = PyCFunction_GET_SELF(func);
21776     int flags = PyCFunction_GET_FLAGS(func);
21777     assert(PyCFunction_Check(func));
21778     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
21779     assert(nargs >= 0);
21780     assert(nargs == 0 || args != NULL);
21781     /* _PyCFunction_FastCallDict() must not be called with an exception set,
21782        because it may clear it (directly or indirectly) and so the
21783        caller loses its exception */
21784     assert(!PyErr_Occurred());
21785     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
21786         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
21787     } else {
21788         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
21789     }
21790 }
21791 #endif
21792
21793 /* PyFunctionFastCall */
21794 #if CYTHON_FAST_PYCALL
21795 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
21796                                                PyObject *globals) {
21797     PyFrameObject *f;
21798     PyThreadState *tstate = __Pyx_PyThreadState_Current;
21799     PyObject **fastlocals;
21800     Py_ssize_t i;
21801     PyObject *result;
21802     assert(globals != NULL);
21803     /* XXX Perhaps we should create a specialized
21804        PyFrame_New() that doesn't take locals, but does
21805        take builtins without sanity checking them.
21806        */
21807     assert(tstate != NULL);
21808     f = PyFrame_New(tstate, co, globals, NULL);
21809     if (f == NULL) {
21810         return NULL;
21811     }
21812     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
21813     for (i = 0; i < na; i++) {
21814         Py_INCREF(*args);
21815         fastlocals[i] = *args++;
21816     }
21817     result = PyEval_EvalFrameEx(f,0);
21818     ++tstate->recursion_depth;
21819     Py_DECREF(f);
21820     --tstate->recursion_depth;
21821     return result;
21822 }
21823 #if 1 || PY_VERSION_HEX < 0x030600B1
21824 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
21825     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
21826     PyObject *globals = PyFunction_GET_GLOBALS(func);
21827     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
21828     PyObject *closure;
21829 #if PY_MAJOR_VERSION >= 3
21830     PyObject *kwdefs;
21831 #endif
21832     PyObject *kwtuple, **k;
21833     PyObject **d;
21834     Py_ssize_t nd;
21835     Py_ssize_t nk;
21836     PyObject *result;
21837     assert(kwargs == NULL || PyDict_Check(kwargs));
21838     nk = kwargs ? PyDict_Size(kwargs) : 0;
21839     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
21840         return NULL;
21841     }
21842     if (
21843 #if PY_MAJOR_VERSION >= 3
21844             co->co_kwonlyargcount == 0 &&
21845 #endif
21846             likely(kwargs == NULL || nk == 0) &&
21847             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
21848         if (argdefs == NULL && co->co_argcount == nargs) {
21849             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
21850             goto done;
21851         }
21852         else if (nargs == 0 && argdefs != NULL
21853                  && co->co_argcount == Py_SIZE(argdefs)) {
21854             /* function called with no arguments, but all parameters have
21855                a default value: use default values as arguments .*/
21856             args = &PyTuple_GET_ITEM(argdefs, 0);
21857             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
21858             goto done;
21859         }
21860     }
21861     if (kwargs != NULL) {
21862         Py_ssize_t pos, i;
21863         kwtuple = PyTuple_New(2 * nk);
21864         if (kwtuple == NULL) {
21865             result = NULL;
21866             goto done;
21867         }
21868         k = &PyTuple_GET_ITEM(kwtuple, 0);
21869         pos = i = 0;
21870         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
21871             Py_INCREF(k[i]);
21872             Py_INCREF(k[i+1]);
21873             i += 2;
21874         }
21875         nk = i / 2;
21876     }
21877     else {
21878         kwtuple = NULL;
21879         k = NULL;
21880     }
21881     closure = PyFunction_GET_CLOSURE(func);
21882 #if PY_MAJOR_VERSION >= 3
21883     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
21884 #endif
21885     if (argdefs != NULL) {
21886         d = &PyTuple_GET_ITEM(argdefs, 0);
21887         nd = Py_SIZE(argdefs);
21888     }
21889     else {
21890         d = NULL;
21891         nd = 0;
21892     }
21893 #if PY_MAJOR_VERSION >= 3
21894     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
21895                                args, (int)nargs,
21896                                k, (int)nk,
21897                                d, (int)nd, kwdefs, closure);
21898 #else
21899     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
21900                                args, (int)nargs,
21901                                k, (int)nk,
21902                                d, (int)nd, closure);
21903 #endif
21904     Py_XDECREF(kwtuple);
21905 done:
21906     Py_LeaveRecursiveCall();
21907     return result;
21908 }
21909 #endif
21910 #endif
21911
21912 /* PyObjectCall */
21913 #if CYTHON_COMPILING_IN_CPYTHON
21914 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
21915     PyObject *result;
21916     ternaryfunc call = func->ob_type->tp_call;
21917     if (unlikely(!call))
21918         return PyObject_Call(func, arg, kw);
21919     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
21920         return NULL;
21921     result = (*call)(func, arg, kw);
21922     Py_LeaveRecursiveCall();
21923     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
21924         PyErr_SetString(
21925             PyExc_SystemError,
21926             "NULL result without error in PyObject_Call");
21927     }
21928     return result;
21929 }
21930 #endif
21931
21932 /* PyObjectCall2Args */
21933 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
21934     PyObject *args, *result = NULL;
21935     #if CYTHON_FAST_PYCALL
21936     if (PyFunction_Check(function)) {
21937         PyObject *args[2] = {arg1, arg2};
21938         return __Pyx_PyFunction_FastCall(function, args, 2);
21939     }
21940     #endif
21941     #if CYTHON_FAST_PYCCALL
21942     if (__Pyx_PyFastCFunction_Check(function)) {
21943         PyObject *args[2] = {arg1, arg2};
21944         return __Pyx_PyCFunction_FastCall(function, args, 2);
21945     }
21946     #endif
21947     args = PyTuple_New(2);
21948     if (unlikely(!args)) goto done;
21949     Py_INCREF(arg1);
21950     PyTuple_SET_ITEM(args, 0, arg1);
21951     Py_INCREF(arg2);
21952     PyTuple_SET_ITEM(args, 1, arg2);
21953     Py_INCREF(function);
21954     result = __Pyx_PyObject_Call(function, args, NULL);
21955     Py_DECREF(args);
21956     Py_DECREF(function);
21957 done:
21958     return result;
21959 }
21960
21961 /* PyObjectCallMethO */
21962 #if CYTHON_COMPILING_IN_CPYTHON
21963 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
21964     PyObject *self, *result;
21965     PyCFunction cfunc;
21966     cfunc = PyCFunction_GET_FUNCTION(func);
21967     self = PyCFunction_GET_SELF(func);
21968     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
21969         return NULL;
21970     result = cfunc(self, arg);
21971     Py_LeaveRecursiveCall();
21972     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
21973         PyErr_SetString(
21974             PyExc_SystemError,
21975             "NULL result without error in PyObject_Call");
21976     }
21977     return result;
21978 }
21979 #endif
21980
21981 /* PyObjectCallOneArg */
21982 #if CYTHON_COMPILING_IN_CPYTHON
21983 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
21984     PyObject *result;
21985     PyObject *args = PyTuple_New(1);
21986     if (unlikely(!args)) return NULL;
21987     Py_INCREF(arg);
21988     PyTuple_SET_ITEM(args, 0, arg);
21989     result = __Pyx_PyObject_Call(func, args, NULL);
21990     Py_DECREF(args);
21991     return result;
21992 }
21993 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
21994 #if CYTHON_FAST_PYCALL
21995     if (PyFunction_Check(func)) {
21996         return __Pyx_PyFunction_FastCall(func, &arg, 1);
21997     }
21998 #endif
21999     if (likely(PyCFunction_Check(func))) {
22000         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
22001             return __Pyx_PyObject_CallMethO(func, arg);
22002 #if CYTHON_FAST_PYCCALL
22003         } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
22004             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
22005 #endif
22006         }
22007     }
22008     return __Pyx__PyObject_CallOneArg(func, arg);
22009 }
22010 #else
22011 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
22012     PyObject *result;
22013     PyObject *args = PyTuple_Pack(1, arg);
22014     if (unlikely(!args)) return NULL;
22015     result = __Pyx_PyObject_Call(func, args, NULL);
22016     Py_DECREF(args);
22017     return result;
22018 }
22019 #endif
22020
22021 /* PyObjectFormatAndDecref */
22022 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
22023     if (unlikely(!s)) return NULL;
22024     if (likely(PyUnicode_CheckExact(s))) return s;
22025     #if PY_MAJOR_VERSION < 3
22026     if (likely(PyString_CheckExact(s))) {
22027         PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
22028         Py_DECREF(s);
22029         return result;
22030     }
22031     #endif
22032     return __Pyx_PyObject_FormatAndDecref(s, f);
22033 }
22034 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
22035     PyObject *result = PyObject_Format(s, f);
22036     Py_DECREF(s);
22037     return result;
22038 }
22039
22040 /* JoinPyUnicode */
22041 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
22042                                       CYTHON_UNUSED Py_UCS4 max_char) {
22043 #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
22044     PyObject *result_uval;
22045     int result_ukind;
22046     Py_ssize_t i, char_pos;
22047     void *result_udata;
22048 #if CYTHON_PEP393_ENABLED
22049     result_uval = PyUnicode_New(result_ulength, max_char);
22050     if (unlikely(!result_uval)) return NULL;
22051     result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
22052     result_udata = PyUnicode_DATA(result_uval);
22053 #else
22054     result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
22055     if (unlikely(!result_uval)) return NULL;
22056     result_ukind = sizeof(Py_UNICODE);
22057     result_udata = PyUnicode_AS_UNICODE(result_uval);
22058 #endif
22059     char_pos = 0;
22060     for (i=0; i < value_count; i++) {
22061         int ukind;
22062         Py_ssize_t ulength;
22063         void *udata;
22064         PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
22065         if (unlikely(__Pyx_PyUnicode_READY(uval)))
22066             goto bad;
22067         ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
22068         if (unlikely(!ulength))
22069             continue;
22070         if (unlikely(char_pos + ulength < 0))
22071             goto overflow;
22072         ukind = __Pyx_PyUnicode_KIND(uval);
22073         udata = __Pyx_PyUnicode_DATA(uval);
22074         if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
22075             memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
22076         } else {
22077             #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
22078             _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
22079             #else
22080             Py_ssize_t j;
22081             for (j=0; j < ulength; j++) {
22082                 Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
22083                 __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
22084             }
22085             #endif
22086         }
22087         char_pos += ulength;
22088     }
22089     return result_uval;
22090 overflow:
22091     PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
22092 bad:
22093     Py_DECREF(result_uval);
22094     return NULL;
22095 #else
22096     result_ulength++;
22097     value_count++;
22098     return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
22099 #endif
22100 }
22101
22102 /* RaiseTooManyValuesToUnpack */
22103 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
22104     PyErr_Format(PyExc_ValueError,
22105                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
22106 }
22107
22108 /* RaiseNeedMoreValuesToUnpack */
22109 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
22110     PyErr_Format(PyExc_ValueError,
22111                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
22112                  index, (index == 1) ? "" : "s");
22113 }
22114
22115 /* IterFinish */
22116 static CYTHON_INLINE int __Pyx_IterFinish(void) {
22117 #if CYTHON_FAST_THREAD_STATE
22118     PyThreadState *tstate = __Pyx_PyThreadState_Current;
22119     PyObject* exc_type = tstate->curexc_type;
22120     if (unlikely(exc_type)) {
22121         if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
22122             PyObject *exc_value, *exc_tb;
22123             exc_value = tstate->curexc_value;
22124             exc_tb = tstate->curexc_traceback;
22125             tstate->curexc_type = 0;
22126             tstate->curexc_value = 0;
22127             tstate->curexc_traceback = 0;
22128             Py_DECREF(exc_type);
22129             Py_XDECREF(exc_value);
22130             Py_XDECREF(exc_tb);
22131             return 0;
22132         } else {
22133             return -1;
22134         }
22135     }
22136     return 0;
22137 #else
22138     if (unlikely(PyErr_Occurred())) {
22139         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
22140             PyErr_Clear();
22141             return 0;
22142         } else {
22143             return -1;
22144         }
22145     }
22146     return 0;
22147 #endif
22148 }
22149
22150 /* UnpackItemEndCheck */
22151 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
22152     if (unlikely(retval)) {
22153         Py_DECREF(retval);
22154         __Pyx_RaiseTooManyValuesError(expected);
22155         return -1;
22156     } else {
22157         return __Pyx_IterFinish();
22158     }
22159     return 0;
22160 }
22161
22162 /* GetItemInt */
22163 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
22164     PyObject *r;
22165     if (!j) return NULL;
22166     r = PyObject_GetItem(o, j);
22167     Py_DECREF(j);
22168     return r;
22169 }
22170 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
22171                                                               CYTHON_NCP_UNUSED int wraparound,
22172                                                               CYTHON_NCP_UNUSED int boundscheck) {
22173 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
22174     Py_ssize_t wrapped_i = i;
22175     if (wraparound & unlikely(i < 0)) {
22176         wrapped_i += PyList_GET_SIZE(o);
22177     }
22178     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
22179         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
22180         Py_INCREF(r);
22181         return r;
22182     }
22183     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
22184 #else
22185     return PySequence_GetItem(o, i);
22186 #endif
22187 }
22188 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
22189                                                               CYTHON_NCP_UNUSED int wraparound,
22190                                                               CYTHON_NCP_UNUSED int boundscheck) {
22191 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
22192     Py_ssize_t wrapped_i = i;
22193     if (wraparound & unlikely(i < 0)) {
22194         wrapped_i += PyTuple_GET_SIZE(o);
22195     }
22196     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
22197         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
22198         Py_INCREF(r);
22199         return r;
22200     }
22201     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
22202 #else
22203     return PySequence_GetItem(o, i);
22204 #endif
22205 }
22206 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
22207                                                      CYTHON_NCP_UNUSED int wraparound,
22208                                                      CYTHON_NCP_UNUSED int boundscheck) {
22209 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
22210     if (is_list || PyList_CheckExact(o)) {
22211         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
22212         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
22213             PyObject *r = PyList_GET_ITEM(o, n);
22214             Py_INCREF(r);
22215             return r;
22216         }
22217     }
22218     else if (PyTuple_CheckExact(o)) {
22219         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
22220         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
22221             PyObject *r = PyTuple_GET_ITEM(o, n);
22222             Py_INCREF(r);
22223             return r;
22224         }
22225     } else {
22226         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
22227         if (likely(m && m->sq_item)) {
22228             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
22229                 Py_ssize_t l = m->sq_length(o);
22230                 if (likely(l >= 0)) {
22231                     i += l;
22232                 } else {
22233                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
22234                         return NULL;
22235                     PyErr_Clear();
22236                 }
22237             }
22238             return m->sq_item(o, i);
22239         }
22240     }
22241 #else
22242     if (is_list || PySequence_Check(o)) {
22243         return PySequence_GetItem(o, i);
22244     }
22245 #endif
22246     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
22247 }
22248
22249 /* SliceTupleAndList */
22250 #if CYTHON_COMPILING_IN_CPYTHON
22251 static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
22252     Py_ssize_t start = *_start, stop = *_stop, length = *_length;
22253     if (start < 0) {
22254         start += length;
22255         if (start < 0)
22256             start = 0;
22257     }
22258     if (stop < 0)
22259         stop += length;
22260     else if (stop > length)
22261         stop = length;
22262     *_length = stop - start;
22263     *_start = start;
22264     *_stop = stop;
22265 }
22266 static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
22267     PyObject *v;
22268     Py_ssize_t i;
22269     for (i = 0; i < length; i++) {
22270         v = dest[i] = src[i];
22271         Py_INCREF(v);
22272     }
22273 }
22274 static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
22275             PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
22276     PyObject* dest;
22277     Py_ssize_t length = PyList_GET_SIZE(src);
22278     __Pyx_crop_slice(&start, &stop, &length);
22279     if (unlikely(length <= 0))
22280         return PyList_New(0);
22281     dest = PyList_New(length);
22282     if (unlikely(!dest))
22283         return NULL;
22284     __Pyx_copy_object_array(
22285         ((PyListObject*)src)->ob_item + start,
22286         ((PyListObject*)dest)->ob_item,
22287         length);
22288     return dest;
22289 }
22290 static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
22291             PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
22292     PyObject* dest;
22293     Py_ssize_t length = PyTuple_GET_SIZE(src);
22294     __Pyx_crop_slice(&start, &stop, &length);
22295     if (unlikely(length <= 0))
22296         return PyTuple_New(0);
22297     dest = PyTuple_New(length);
22298     if (unlikely(!dest))
22299         return NULL;
22300     __Pyx_copy_object_array(
22301         ((PyTupleObject*)src)->ob_item + start,
22302         ((PyTupleObject*)dest)->ob_item,
22303         length);
22304     return dest;
22305 }
22306 #endif
22307
22308 /* PyObjectCallNoArg */
22309 #if CYTHON_COMPILING_IN_CPYTHON
22310 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
22311 #if CYTHON_FAST_PYCALL
22312     if (PyFunction_Check(func)) {
22313         return __Pyx_PyFunction_FastCall(func, NULL, 0);
22314     }
22315 #endif
22316 #ifdef __Pyx_CyFunction_USED
22317     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
22318 #else
22319     if (likely(PyCFunction_Check(func)))
22320 #endif
22321     {
22322         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
22323             return __Pyx_PyObject_CallMethO(func, NULL);
22324         }
22325     }
22326     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
22327 }
22328 #endif
22329
22330 /* PyObjectSetAttrStr */
22331 #if CYTHON_USE_TYPE_SLOTS
22332 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
22333     PyTypeObject* tp = Py_TYPE(obj);
22334     if (likely(tp->tp_setattro))
22335         return tp->tp_setattro(obj, attr_name, value);
22336 #if PY_MAJOR_VERSION < 3
22337     if (likely(tp->tp_setattr))
22338         return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
22339 #endif
22340     return PyObject_SetAttr(obj, attr_name, value);
22341 }
22342 #endif
22343
22344 /* BytesEquals */
22345 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
22346 #if CYTHON_COMPILING_IN_PYPY
22347     return PyObject_RichCompareBool(s1, s2, equals);
22348 #else
22349     if (s1 == s2) {
22350         return (equals == Py_EQ);
22351     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
22352         const char *ps1, *ps2;
22353         Py_ssize_t length = PyBytes_GET_SIZE(s1);
22354         if (length != PyBytes_GET_SIZE(s2))
22355             return (equals == Py_NE);
22356         ps1 = PyBytes_AS_STRING(s1);
22357         ps2 = PyBytes_AS_STRING(s2);
22358         if (ps1[0] != ps2[0]) {
22359             return (equals == Py_NE);
22360         } else if (length == 1) {
22361             return (equals == Py_EQ);
22362         } else {
22363             int result;
22364 #if CYTHON_USE_UNICODE_INTERNALS
22365             Py_hash_t hash1, hash2;
22366             hash1 = ((PyBytesObject*)s1)->ob_shash;
22367             hash2 = ((PyBytesObject*)s2)->ob_shash;
22368             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
22369                 return (equals == Py_NE);
22370             }
22371 #endif
22372             result = memcmp(ps1, ps2, (size_t)length);
22373             return (equals == Py_EQ) ? (result == 0) : (result != 0);
22374         }
22375     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
22376         return (equals == Py_NE);
22377     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
22378         return (equals == Py_NE);
22379     } else {
22380         int result;
22381         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
22382         if (!py_result)
22383             return -1;
22384         result = __Pyx_PyObject_IsTrue(py_result);
22385         Py_DECREF(py_result);
22386         return result;
22387     }
22388 #endif
22389 }
22390
22391 /* UnicodeEquals */
22392 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
22393 #if CYTHON_COMPILING_IN_PYPY
22394     return PyObject_RichCompareBool(s1, s2, equals);
22395 #else
22396 #if PY_MAJOR_VERSION < 3
22397     PyObject* owned_ref = NULL;
22398 #endif
22399     int s1_is_unicode, s2_is_unicode;
22400     if (s1 == s2) {
22401         goto return_eq;
22402     }
22403     s1_is_unicode = PyUnicode_CheckExact(s1);
22404     s2_is_unicode = PyUnicode_CheckExact(s2);
22405 #if PY_MAJOR_VERSION < 3
22406     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
22407         owned_ref = PyUnicode_FromObject(s2);
22408         if (unlikely(!owned_ref))
22409             return -1;
22410         s2 = owned_ref;
22411         s2_is_unicode = 1;
22412     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
22413         owned_ref = PyUnicode_FromObject(s1);
22414         if (unlikely(!owned_ref))
22415             return -1;
22416         s1 = owned_ref;
22417         s1_is_unicode = 1;
22418     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
22419         return __Pyx_PyBytes_Equals(s1, s2, equals);
22420     }
22421 #endif
22422     if (s1_is_unicode & s2_is_unicode) {
22423         Py_ssize_t length;
22424         int kind;
22425         void *data1, *data2;
22426         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
22427             return -1;
22428         length = __Pyx_PyUnicode_GET_LENGTH(s1);
22429         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
22430             goto return_ne;
22431         }
22432 #if CYTHON_USE_UNICODE_INTERNALS
22433         {
22434             Py_hash_t hash1, hash2;
22435         #if CYTHON_PEP393_ENABLED
22436             hash1 = ((PyASCIIObject*)s1)->hash;
22437             hash2 = ((PyASCIIObject*)s2)->hash;
22438         #else
22439             hash1 = ((PyUnicodeObject*)s1)->hash;
22440             hash2 = ((PyUnicodeObject*)s2)->hash;
22441         #endif
22442             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
22443                 goto return_ne;
22444             }
22445         }
22446 #endif
22447         kind = __Pyx_PyUnicode_KIND(s1);
22448         if (kind != __Pyx_PyUnicode_KIND(s2)) {
22449             goto return_ne;
22450         }
22451         data1 = __Pyx_PyUnicode_DATA(s1);
22452         data2 = __Pyx_PyUnicode_DATA(s2);
22453         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
22454             goto return_ne;
22455         } else if (length == 1) {
22456             goto return_eq;
22457         } else {
22458             int result = memcmp(data1, data2, (size_t)(length * kind));
22459             #if PY_MAJOR_VERSION < 3
22460             Py_XDECREF(owned_ref);
22461             #endif
22462             return (equals == Py_EQ) ? (result == 0) : (result != 0);
22463         }
22464     } else if ((s1 == Py_None) & s2_is_unicode) {
22465         goto return_ne;
22466     } else if ((s2 == Py_None) & s1_is_unicode) {
22467         goto return_ne;
22468     } else {
22469         int result;
22470         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
22471         #if PY_MAJOR_VERSION < 3
22472         Py_XDECREF(owned_ref);
22473         #endif
22474         if (!py_result)
22475             return -1;
22476         result = __Pyx_PyObject_IsTrue(py_result);
22477         Py_DECREF(py_result);
22478         return result;
22479     }
22480 return_eq:
22481     #if PY_MAJOR_VERSION < 3
22482     Py_XDECREF(owned_ref);
22483     #endif
22484     return (equals == Py_EQ);
22485 return_ne:
22486     #if PY_MAJOR_VERSION < 3
22487     Py_XDECREF(owned_ref);
22488     #endif
22489     return (equals == Py_NE);
22490 #endif
22491 }
22492
22493 /* SliceObject */
22494 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
22495         Py_ssize_t cstart, Py_ssize_t cstop,
22496         PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
22497         int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
22498 #if CYTHON_USE_TYPE_SLOTS
22499     PyMappingMethods* mp;
22500 #if PY_MAJOR_VERSION < 3
22501     PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
22502     if (likely(ms && ms->sq_slice)) {
22503         if (!has_cstart) {
22504             if (_py_start && (*_py_start != Py_None)) {
22505                 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
22506                 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
22507             } else
22508                 cstart = 0;
22509         }
22510         if (!has_cstop) {
22511             if (_py_stop && (*_py_stop != Py_None)) {
22512                 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
22513                 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
22514             } else
22515                 cstop = PY_SSIZE_T_MAX;
22516         }
22517         if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
22518             Py_ssize_t l = ms->sq_length(obj);
22519             if (likely(l >= 0)) {
22520                 if (cstop < 0) {
22521                     cstop += l;
22522                     if (cstop < 0) cstop = 0;
22523                 }
22524                 if (cstart < 0) {
22525                     cstart += l;
22526                     if (cstart < 0) cstart = 0;
22527                 }
22528             } else {
22529                 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
22530                     goto bad;
22531                 PyErr_Clear();
22532             }
22533         }
22534         return ms->sq_slice(obj, cstart, cstop);
22535     }
22536 #endif
22537     mp = Py_TYPE(obj)->tp_as_mapping;
22538     if (likely(mp && mp->mp_subscript))
22539 #endif
22540     {
22541         PyObject* result;
22542         PyObject *py_slice, *py_start, *py_stop;
22543         if (_py_slice) {
22544             py_slice = *_py_slice;
22545         } else {
22546             PyObject* owned_start = NULL;
22547             PyObject* owned_stop = NULL;
22548             if (_py_start) {
22549                 py_start = *_py_start;
22550             } else {
22551                 if (has_cstart) {
22552                     owned_start = py_start = PyInt_FromSsize_t(cstart);
22553                     if (unlikely(!py_start)) goto bad;
22554                 } else
22555                     py_start = Py_None;
22556             }
22557             if (_py_stop) {
22558                 py_stop = *_py_stop;
22559             } else {
22560                 if (has_cstop) {
22561                     owned_stop = py_stop = PyInt_FromSsize_t(cstop);
22562                     if (unlikely(!py_stop)) {
22563                         Py_XDECREF(owned_start);
22564                         goto bad;
22565                     }
22566                 } else
22567                     py_stop = Py_None;
22568             }
22569             py_slice = PySlice_New(py_start, py_stop, Py_None);
22570             Py_XDECREF(owned_start);
22571             Py_XDECREF(owned_stop);
22572             if (unlikely(!py_slice)) goto bad;
22573         }
22574 #if CYTHON_USE_TYPE_SLOTS
22575         result = mp->mp_subscript(obj, py_slice);
22576 #else
22577         result = PyObject_GetItem(obj, py_slice);
22578 #endif
22579         if (!_py_slice) {
22580             Py_DECREF(py_slice);
22581         }
22582         return result;
22583     }
22584     PyErr_Format(PyExc_TypeError,
22585         "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
22586 bad:
22587     return NULL;
22588 }
22589
22590 /* PyObjectGetMethod */
22591 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
22592     PyObject *attr;
22593 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
22594     PyTypeObject *tp = Py_TYPE(obj);
22595     PyObject *descr;
22596     descrgetfunc f = NULL;
22597     PyObject **dictptr, *dict;
22598     int meth_found = 0;
22599     assert (*method == NULL);
22600     if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
22601         attr = __Pyx_PyObject_GetAttrStr(obj, name);
22602         goto try_unpack;
22603     }
22604     if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
22605         return 0;
22606     }
22607     descr = _PyType_Lookup(tp, name);
22608     if (likely(descr != NULL)) {
22609         Py_INCREF(descr);
22610 #if PY_MAJOR_VERSION >= 3
22611         #ifdef __Pyx_CyFunction_USED
22612         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
22613         #else
22614         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
22615         #endif
22616 #else
22617         #ifdef __Pyx_CyFunction_USED
22618         if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
22619         #else
22620         if (likely(PyFunction_Check(descr)))
22621         #endif
22622 #endif
22623         {
22624             meth_found = 1;
22625         } else {
22626             f = Py_TYPE(descr)->tp_descr_get;
22627             if (f != NULL && PyDescr_IsData(descr)) {
22628                 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
22629                 Py_DECREF(descr);
22630                 goto try_unpack;
22631             }
22632         }
22633     }
22634     dictptr = _PyObject_GetDictPtr(obj);
22635     if (dictptr != NULL && (dict = *dictptr) != NULL) {
22636         Py_INCREF(dict);
22637         attr = __Pyx_PyDict_GetItemStr(dict, name);
22638         if (attr != NULL) {
22639             Py_INCREF(attr);
22640             Py_DECREF(dict);
22641             Py_XDECREF(descr);
22642             goto try_unpack;
22643         }
22644         Py_DECREF(dict);
22645     }
22646     if (meth_found) {
22647         *method = descr;
22648         return 1;
22649     }
22650     if (f != NULL) {
22651         attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
22652         Py_DECREF(descr);
22653         goto try_unpack;
22654     }
22655     if (descr != NULL) {
22656         *method = descr;
22657         return 0;
22658     }
22659     PyErr_Format(PyExc_AttributeError,
22660 #if PY_MAJOR_VERSION >= 3
22661                  "'%.50s' object has no attribute '%U'",
22662                  tp->tp_name, name);
22663 #else
22664                  "'%.50s' object has no attribute '%.400s'",
22665                  tp->tp_name, PyString_AS_STRING(name));
22666 #endif
22667     return 0;
22668 #else
22669     attr = __Pyx_PyObject_GetAttrStr(obj, name);
22670     goto try_unpack;
22671 #endif
22672 try_unpack:
22673 #if CYTHON_UNPACK_METHODS
22674     if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
22675         PyObject *function = PyMethod_GET_FUNCTION(attr);
22676         Py_INCREF(function);
22677         Py_DECREF(attr);
22678         *method = function;
22679         return 1;
22680     }
22681 #endif
22682     *method = attr;
22683     return 0;
22684 }
22685
22686 /* PyObjectCallMethod1 */
22687 static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
22688     PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
22689     Py_DECREF(method);
22690     return result;
22691 }
22692 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
22693     PyObject *method = NULL, *result;
22694     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
22695     if (likely(is_method)) {
22696         result = __Pyx_PyObject_Call2Args(method, obj, arg);
22697         Py_DECREF(method);
22698         return result;
22699     }
22700     if (unlikely(!method)) return NULL;
22701     return __Pyx__PyObject_CallMethod1(method, arg);
22702 }
22703
22704 /* append */
22705 static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
22706     if (likely(PyList_CheckExact(L))) {
22707         if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
22708     } else {
22709         PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
22710         if (unlikely(!retval))
22711             return -1;
22712         Py_DECREF(retval);
22713     }
22714     return 0;
22715 }
22716
22717 /* SetItemInt */
22718 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
22719     int r;
22720     if (!j) return -1;
22721     r = PyObject_SetItem(o, j, v);
22722     Py_DECREF(j);
22723     return r;
22724 }
22725 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
22726                                                CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
22727 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
22728     if (is_list || PyList_CheckExact(o)) {
22729         Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
22730         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
22731             PyObject* old = PyList_GET_ITEM(o, n);
22732             Py_INCREF(v);
22733             PyList_SET_ITEM(o, n, v);
22734             Py_DECREF(old);
22735             return 1;
22736         }
22737     } else {
22738         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
22739         if (likely(m && m->sq_ass_item)) {
22740             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
22741                 Py_ssize_t l = m->sq_length(o);
22742                 if (likely(l >= 0)) {
22743                     i += l;
22744                 } else {
22745                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
22746                         return -1;
22747                     PyErr_Clear();
22748                 }
22749             }
22750             return m->sq_ass_item(o, i, v);
22751         }
22752     }
22753 #else
22754 #if CYTHON_COMPILING_IN_PYPY
22755     if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
22756 #else
22757     if (is_list || PySequence_Check(o))
22758 #endif
22759     {
22760         return PySequence_SetItem(o, i, v);
22761     }
22762 #endif
22763     return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
22764 }
22765
22766 /* GetTopmostException */
22767 #if CYTHON_USE_EXC_INFO_STACK
22768 static _PyErr_StackItem *
22769 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
22770 {
22771     _PyErr_StackItem *exc_info = tstate->exc_info;
22772     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
22773            exc_info->previous_item != NULL)
22774     {
22775         exc_info = exc_info->previous_item;
22776     }
22777     return exc_info;
22778 }
22779 #endif
22780
22781 /* SaveResetException */
22782 #if CYTHON_FAST_THREAD_STATE
22783 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
22784     #if CYTHON_USE_EXC_INFO_STACK
22785     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
22786     *type = exc_info->exc_type;
22787     *value = exc_info->exc_value;
22788     *tb = exc_info->exc_traceback;
22789     #else
22790     *type = tstate->exc_type;
22791     *value = tstate->exc_value;
22792     *tb = tstate->exc_traceback;
22793     #endif
22794     Py_XINCREF(*type);
22795     Py_XINCREF(*value);
22796     Py_XINCREF(*tb);
22797 }
22798 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
22799     PyObject *tmp_type, *tmp_value, *tmp_tb;
22800     #if CYTHON_USE_EXC_INFO_STACK
22801     _PyErr_StackItem *exc_info = tstate->exc_info;
22802     tmp_type = exc_info->exc_type;
22803     tmp_value = exc_info->exc_value;
22804     tmp_tb = exc_info->exc_traceback;
22805     exc_info->exc_type = type;
22806     exc_info->exc_value = value;
22807     exc_info->exc_traceback = tb;
22808     #else
22809     tmp_type = tstate->exc_type;
22810     tmp_value = tstate->exc_value;
22811     tmp_tb = tstate->exc_traceback;
22812     tstate->exc_type = type;
22813     tstate->exc_value = value;
22814     tstate->exc_traceback = tb;
22815     #endif
22816     Py_XDECREF(tmp_type);
22817     Py_XDECREF(tmp_value);
22818     Py_XDECREF(tmp_tb);
22819 }
22820 #endif
22821
22822 /* PyErrFetchRestore */
22823 #if CYTHON_FAST_THREAD_STATE
22824 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
22825     PyObject *tmp_type, *tmp_value, *tmp_tb;
22826     tmp_type = tstate->curexc_type;
22827     tmp_value = tstate->curexc_value;
22828     tmp_tb = tstate->curexc_traceback;
22829     tstate->curexc_type = type;
22830     tstate->curexc_value = value;
22831     tstate->curexc_traceback = tb;
22832     Py_XDECREF(tmp_type);
22833     Py_XDECREF(tmp_value);
22834     Py_XDECREF(tmp_tb);
22835 }
22836 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
22837     *type = tstate->curexc_type;
22838     *value = tstate->curexc_value;
22839     *tb = tstate->curexc_traceback;
22840     tstate->curexc_type = 0;
22841     tstate->curexc_value = 0;
22842     tstate->curexc_traceback = 0;
22843 }
22844 #endif
22845
22846 /* FastTypeChecks */
22847 #if CYTHON_COMPILING_IN_CPYTHON
22848 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
22849     while (a) {
22850         a = a->tp_base;
22851         if (a == b)
22852             return 1;
22853     }
22854     return b == &PyBaseObject_Type;
22855 }
22856 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
22857     PyObject *mro;
22858     if (a == b) return 1;
22859     mro = a->tp_mro;
22860     if (likely(mro)) {
22861         Py_ssize_t i, n;
22862         n = PyTuple_GET_SIZE(mro);
22863         for (i = 0; i < n; i++) {
22864             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
22865                 return 1;
22866         }
22867         return 0;
22868     }
22869     return __Pyx_InBases(a, b);
22870 }
22871 #if PY_MAJOR_VERSION == 2
22872 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
22873     PyObject *exception, *value, *tb;
22874     int res;
22875     __Pyx_PyThreadState_declare
22876     __Pyx_PyThreadState_assign
22877     __Pyx_ErrFetch(&exception, &value, &tb);
22878     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
22879     if (unlikely(res == -1)) {
22880         PyErr_WriteUnraisable(err);
22881         res = 0;
22882     }
22883     if (!res) {
22884         res = PyObject_IsSubclass(err, exc_type2);
22885         if (unlikely(res == -1)) {
22886             PyErr_WriteUnraisable(err);
22887             res = 0;
22888         }
22889     }
22890     __Pyx_ErrRestore(exception, value, tb);
22891     return res;
22892 }
22893 #else
22894 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
22895     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
22896     if (!res) {
22897         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
22898     }
22899     return res;
22900 }
22901 #endif
22902 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
22903     Py_ssize_t i, n;
22904     assert(PyExceptionClass_Check(exc_type));
22905     n = PyTuple_GET_SIZE(tuple);
22906 #if PY_MAJOR_VERSION >= 3
22907     for (i=0; i<n; i++) {
22908         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
22909     }
22910 #endif
22911     for (i=0; i<n; i++) {
22912         PyObject *t = PyTuple_GET_ITEM(tuple, i);
22913         #if PY_MAJOR_VERSION < 3
22914         if (likely(exc_type == t)) return 1;
22915         #endif
22916         if (likely(PyExceptionClass_Check(t))) {
22917             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
22918         } else {
22919         }
22920     }
22921     return 0;
22922 }
22923 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
22924     if (likely(err == exc_type)) return 1;
22925     if (likely(PyExceptionClass_Check(err))) {
22926         if (likely(PyExceptionClass_Check(exc_type))) {
22927             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
22928         } else if (likely(PyTuple_Check(exc_type))) {
22929             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
22930         } else {
22931         }
22932     }
22933     return PyErr_GivenExceptionMatches(err, exc_type);
22934 }
22935 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
22936     assert(PyExceptionClass_Check(exc_type1));
22937     assert(PyExceptionClass_Check(exc_type2));
22938     if (likely(err == exc_type1 || err == exc_type2)) return 1;
22939     if (likely(PyExceptionClass_Check(err))) {
22940         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
22941     }
22942     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
22943 }
22944 #endif
22945
22946 /* GetException */
22947 #if CYTHON_FAST_THREAD_STATE
22948 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
22949 #else
22950 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
22951 #endif
22952 {
22953     PyObject *local_type, *local_value, *local_tb;
22954 #if CYTHON_FAST_THREAD_STATE
22955     PyObject *tmp_type, *tmp_value, *tmp_tb;
22956     local_type = tstate->curexc_type;
22957     local_value = tstate->curexc_value;
22958     local_tb = tstate->curexc_traceback;
22959     tstate->curexc_type = 0;
22960     tstate->curexc_value = 0;
22961     tstate->curexc_traceback = 0;
22962 #else
22963     PyErr_Fetch(&local_type, &local_value, &local_tb);
22964 #endif
22965     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
22966 #if CYTHON_FAST_THREAD_STATE
22967     if (unlikely(tstate->curexc_type))
22968 #else
22969     if (unlikely(PyErr_Occurred()))
22970 #endif
22971         goto bad;
22972     #if PY_MAJOR_VERSION >= 3
22973     if (local_tb) {
22974         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
22975             goto bad;
22976     }
22977     #endif
22978     Py_XINCREF(local_tb);
22979     Py_XINCREF(local_type);
22980     Py_XINCREF(local_value);
22981     *type = local_type;
22982     *value = local_value;
22983     *tb = local_tb;
22984 #if CYTHON_FAST_THREAD_STATE
22985     #if CYTHON_USE_EXC_INFO_STACK
22986     {
22987         _PyErr_StackItem *exc_info = tstate->exc_info;
22988         tmp_type = exc_info->exc_type;
22989         tmp_value = exc_info->exc_value;
22990         tmp_tb = exc_info->exc_traceback;
22991         exc_info->exc_type = local_type;
22992         exc_info->exc_value = local_value;
22993         exc_info->exc_traceback = local_tb;
22994     }
22995     #else
22996     tmp_type = tstate->exc_type;
22997     tmp_value = tstate->exc_value;
22998     tmp_tb = tstate->exc_traceback;
22999     tstate->exc_type = local_type;
23000     tstate->exc_value = local_value;
23001     tstate->exc_traceback = local_tb;
23002     #endif
23003     Py_XDECREF(tmp_type);
23004     Py_XDECREF(tmp_value);
23005     Py_XDECREF(tmp_tb);
23006 #else
23007     PyErr_SetExcInfo(local_type, local_value, local_tb);
23008 #endif
23009     return 0;
23010 bad:
23011     *type = 0;
23012     *value = 0;
23013     *tb = 0;
23014     Py_XDECREF(local_type);
23015     Py_XDECREF(local_value);
23016     Py_XDECREF(local_tb);
23017     return -1;
23018 }
23019
23020 /* PyObjectCallMethod0 */
23021 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
23022     PyObject *method = NULL, *result = NULL;
23023     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
23024     if (likely(is_method)) {
23025         result = __Pyx_PyObject_CallOneArg(method, obj);
23026         Py_DECREF(method);
23027         return result;
23028     }
23029     if (unlikely(!method)) goto bad;
23030     result = __Pyx_PyObject_CallNoArg(method);
23031     Py_DECREF(method);
23032 bad:
23033     return result;
23034 }
23035
23036 /* UnpackUnboundCMethod */
23037 static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
23038     PyObject *method;
23039     method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
23040     if (unlikely(!method))
23041         return -1;
23042     target->method = method;
23043 #if CYTHON_COMPILING_IN_CPYTHON
23044     #if PY_MAJOR_VERSION >= 3
23045     if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
23046     #endif
23047     {
23048         PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
23049         target->func = descr->d_method->ml_meth;
23050         target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
23051     }
23052 #endif
23053     return 0;
23054 }
23055
23056 /* CallUnboundCMethod0 */
23057 static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
23058     PyObject *args, *result = NULL;
23059     if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
23060 #if CYTHON_ASSUME_SAFE_MACROS
23061     args = PyTuple_New(1);
23062     if (unlikely(!args)) goto bad;
23063     Py_INCREF(self);
23064     PyTuple_SET_ITEM(args, 0, self);
23065 #else
23066     args = PyTuple_Pack(1, self);
23067     if (unlikely(!args)) goto bad;
23068 #endif
23069     result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
23070     Py_DECREF(args);
23071 bad:
23072     return result;
23073 }
23074
23075 /* pop */
23076 static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
23077     if (Py_TYPE(L) == &PySet_Type) {
23078         return PySet_Pop(L);
23079     }
23080     return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
23081 }
23082 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
23083 static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
23084     if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
23085         Py_SIZE(L) -= 1;
23086         return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
23087     }
23088     return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
23089 }
23090 #endif
23091
23092 /* PyErrExceptionMatches */
23093 #if CYTHON_FAST_THREAD_STATE
23094 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
23095     Py_ssize_t i, n;
23096     n = PyTuple_GET_SIZE(tuple);
23097 #if PY_MAJOR_VERSION >= 3
23098     for (i=0; i<n; i++) {
23099         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
23100     }
23101 #endif
23102     for (i=0; i<n; i++) {
23103         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
23104     }
23105     return 0;
23106 }
23107 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
23108     PyObject *exc_type = tstate->curexc_type;
23109     if (exc_type == err) return 1;
23110     if (unlikely(!exc_type)) return 0;
23111     if (unlikely(PyTuple_Check(err)))
23112         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
23113     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
23114 }
23115 #endif
23116
23117 /* RaiseException */
23118 #if PY_MAJOR_VERSION < 3
23119 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
23120                         CYTHON_UNUSED PyObject *cause) {
23121     __Pyx_PyThreadState_declare
23122     Py_XINCREF(type);
23123     if (!value || value == Py_None)
23124         value = NULL;
23125     else
23126         Py_INCREF(value);
23127     if (!tb || tb == Py_None)
23128         tb = NULL;
23129     else {
23130         Py_INCREF(tb);
23131         if (!PyTraceBack_Check(tb)) {
23132             PyErr_SetString(PyExc_TypeError,
23133                 "raise: arg 3 must be a traceback or None");
23134             goto raise_error;
23135         }
23136     }
23137     if (PyType_Check(type)) {
23138 #if CYTHON_COMPILING_IN_PYPY
23139         if (!value) {
23140             Py_INCREF(Py_None);
23141             value = Py_None;
23142         }
23143 #endif
23144         PyErr_NormalizeException(&type, &value, &tb);
23145     } else {
23146         if (value) {
23147             PyErr_SetString(PyExc_TypeError,
23148                 "instance exception may not have a separate value");
23149             goto raise_error;
23150         }
23151         value = type;
23152         type = (PyObject*) Py_TYPE(type);
23153         Py_INCREF(type);
23154         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
23155             PyErr_SetString(PyExc_TypeError,
23156                 "raise: exception class must be a subclass of BaseException");
23157             goto raise_error;
23158         }
23159     }
23160     __Pyx_PyThreadState_assign
23161     __Pyx_ErrRestore(type, value, tb);
23162     return;
23163 raise_error:
23164     Py_XDECREF(value);
23165     Py_XDECREF(type);
23166     Py_XDECREF(tb);
23167     return;
23168 }
23169 #else
23170 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
23171     PyObject* owned_instance = NULL;
23172     if (tb == Py_None) {
23173         tb = 0;
23174     } else if (tb && !PyTraceBack_Check(tb)) {
23175         PyErr_SetString(PyExc_TypeError,
23176             "raise: arg 3 must be a traceback or None");
23177         goto bad;
23178     }
23179     if (value == Py_None)
23180         value = 0;
23181     if (PyExceptionInstance_Check(type)) {
23182         if (value) {
23183             PyErr_SetString(PyExc_TypeError,
23184                 "instance exception may not have a separate value");
23185             goto bad;
23186         }
23187         value = type;
23188         type = (PyObject*) Py_TYPE(value);
23189     } else if (PyExceptionClass_Check(type)) {
23190         PyObject *instance_class = NULL;
23191         if (value && PyExceptionInstance_Check(value)) {
23192             instance_class = (PyObject*) Py_TYPE(value);
23193             if (instance_class != type) {
23194                 int is_subclass = PyObject_IsSubclass(instance_class, type);
23195                 if (!is_subclass) {
23196                     instance_class = NULL;
23197                 } else if (unlikely(is_subclass == -1)) {
23198                     goto bad;
23199                 } else {
23200                     type = instance_class;
23201                 }
23202             }
23203         }
23204         if (!instance_class) {
23205             PyObject *args;
23206             if (!value)
23207                 args = PyTuple_New(0);
23208             else if (PyTuple_Check(value)) {
23209                 Py_INCREF(value);
23210                 args = value;
23211             } else
23212                 args = PyTuple_Pack(1, value);
23213             if (!args)
23214                 goto bad;
23215             owned_instance = PyObject_Call(type, args, NULL);
23216             Py_DECREF(args);
23217             if (!owned_instance)
23218                 goto bad;
23219             value = owned_instance;
23220             if (!PyExceptionInstance_Check(value)) {
23221                 PyErr_Format(PyExc_TypeError,
23222                              "calling %R should have returned an instance of "
23223                              "BaseException, not %R",
23224                              type, Py_TYPE(value));
23225                 goto bad;
23226             }
23227         }
23228     } else {
23229         PyErr_SetString(PyExc_TypeError,
23230             "raise: exception class must be a subclass of BaseException");
23231         goto bad;
23232     }
23233     if (cause) {
23234         PyObject *fixed_cause;
23235         if (cause == Py_None) {
23236             fixed_cause = NULL;
23237         } else if (PyExceptionClass_Check(cause)) {
23238             fixed_cause = PyObject_CallObject(cause, NULL);
23239             if (fixed_cause == NULL)
23240                 goto bad;
23241         } else if (PyExceptionInstance_Check(cause)) {
23242             fixed_cause = cause;
23243             Py_INCREF(fixed_cause);
23244         } else {
23245             PyErr_SetString(PyExc_TypeError,
23246                             "exception causes must derive from "
23247                             "BaseException");
23248             goto bad;
23249         }
23250         PyException_SetCause(value, fixed_cause);
23251     }
23252     PyErr_SetObject(type, value);
23253     if (tb) {
23254 #if CYTHON_COMPILING_IN_PYPY
23255         PyObject *tmp_type, *tmp_value, *tmp_tb;
23256         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
23257         Py_INCREF(tb);
23258         PyErr_Restore(tmp_type, tmp_value, tb);
23259         Py_XDECREF(tmp_tb);
23260 #else
23261         PyThreadState *tstate = __Pyx_PyThreadState_Current;
23262         PyObject* tmp_tb = tstate->curexc_traceback;
23263         if (tb != tmp_tb) {
23264             Py_INCREF(tb);
23265             tstate->curexc_traceback = tb;
23266             Py_XDECREF(tmp_tb);
23267         }
23268 #endif
23269     }
23270 bad:
23271     Py_XDECREF(owned_instance);
23272     return;
23273 }
23274 #endif
23275
23276 /* PyIntBinop */
23277 #if !CYTHON_COMPILING_IN_PYPY
23278 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
23279     (void)inplace;
23280     (void)zerodivision_check;
23281     #if PY_MAJOR_VERSION < 3
23282     if (likely(PyInt_CheckExact(op1))) {
23283         const long b = intval;
23284         long x;
23285         long a = PyInt_AS_LONG(op1);
23286             x = (long)((unsigned long)a + b);
23287             if (likely((x^a) >= 0 || (x^b) >= 0))
23288                 return PyInt_FromLong(x);
23289             return PyLong_Type.tp_as_number->nb_add(op1, op2);
23290     }
23291     #endif
23292     #if CYTHON_USE_PYLONG_INTERNALS
23293     if (likely(PyLong_CheckExact(op1))) {
23294         const long b = intval;
23295         long a, x;
23296 #ifdef HAVE_LONG_LONG
23297         const PY_LONG_LONG llb = intval;
23298         PY_LONG_LONG lla, llx;
23299 #endif
23300         const digit* digits = ((PyLongObject*)op1)->ob_digit;
23301         const Py_ssize_t size = Py_SIZE(op1);
23302         if (likely(__Pyx_sst_abs(size) <= 1)) {
23303             a = likely(size) ? digits[0] : 0;
23304             if (size == -1) a = -a;
23305         } else {
23306             switch (size) {
23307                 case -2:
23308                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
23309                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23310                         break;
23311 #ifdef HAVE_LONG_LONG
23312                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
23313                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23314                         goto long_long;
23315 #endif
23316                     }
23317                     CYTHON_FALLTHROUGH;
23318                 case 2:
23319                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
23320                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23321                         break;
23322 #ifdef HAVE_LONG_LONG
23323                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
23324                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23325                         goto long_long;
23326 #endif
23327                     }
23328                     CYTHON_FALLTHROUGH;
23329                 case -3:
23330                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
23331                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23332                         break;
23333 #ifdef HAVE_LONG_LONG
23334                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
23335                         lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23336                         goto long_long;
23337 #endif
23338                     }
23339                     CYTHON_FALLTHROUGH;
23340                 case 3:
23341                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
23342                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23343                         break;
23344 #ifdef HAVE_LONG_LONG
23345                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
23346                         lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23347                         goto long_long;
23348 #endif
23349                     }
23350                     CYTHON_FALLTHROUGH;
23351                 case -4:
23352                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
23353                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23354                         break;
23355 #ifdef HAVE_LONG_LONG
23356                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
23357                         lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23358                         goto long_long;
23359 #endif
23360                     }
23361                     CYTHON_FALLTHROUGH;
23362                 case 4:
23363                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
23364                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23365                         break;
23366 #ifdef HAVE_LONG_LONG
23367                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
23368                         lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23369                         goto long_long;
23370 #endif
23371                     }
23372                     CYTHON_FALLTHROUGH;
23373                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
23374             }
23375         }
23376                 x = a + b;
23377             return PyLong_FromLong(x);
23378 #ifdef HAVE_LONG_LONG
23379         long_long:
23380                 llx = lla + llb;
23381             return PyLong_FromLongLong(llx);
23382 #endif
23383         
23384         
23385     }
23386     #endif
23387     if (PyFloat_CheckExact(op1)) {
23388         const long b = intval;
23389         double a = PyFloat_AS_DOUBLE(op1);
23390             double result;
23391             PyFPE_START_PROTECT("add", return NULL)
23392             result = ((double)a) + (double)b;
23393             PyFPE_END_PROTECT(result)
23394             return PyFloat_FromDouble(result);
23395     }
23396     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
23397 }
23398 #endif
23399
23400 /* pop_index */
23401 static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) {
23402     PyObject *r;
23403     if (unlikely(!py_ix)) return NULL;
23404     r = __Pyx__PyObject_PopIndex(L, py_ix);
23405     Py_DECREF(py_ix);
23406     return r;
23407 }
23408 static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) {
23409     return __Pyx_PyObject_CallMethod1(L, __pyx_n_s_pop, py_ix);
23410 }
23411 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
23412 static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) {
23413     Py_ssize_t size = PyList_GET_SIZE(L);
23414     if (likely(size > (((PyListObject*)L)->allocated >> 1))) {
23415         Py_ssize_t cix = ix;
23416         if (cix < 0) {
23417             cix += size;
23418         }
23419         if (likely(__Pyx_is_valid_index(cix, size))) {
23420             PyObject* v = PyList_GET_ITEM(L, cix);
23421             Py_SIZE(L) -= 1;
23422             size -= 1;
23423             memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*));
23424             return v;
23425         }
23426     }
23427     if (py_ix == Py_None) {
23428         return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix));
23429     } else {
23430         return __Pyx__PyObject_PopIndex(L, py_ix);
23431     }
23432 }
23433 #endif
23434
23435 /* RaiseNoneIterError */
23436 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
23437     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
23438 }
23439
23440 /* UnpackTupleError */
23441 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
23442     if (t == Py_None) {
23443       __Pyx_RaiseNoneNotIterableError();
23444     } else if (PyTuple_GET_SIZE(t) < index) {
23445       __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
23446     } else {
23447       __Pyx_RaiseTooManyValuesError(index);
23448     }
23449 }
23450
23451 /* UnpackTuple2 */
23452 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
23453         PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
23454     PyObject *value1 = NULL, *value2 = NULL;
23455 #if CYTHON_COMPILING_IN_PYPY
23456     value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
23457     value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
23458 #else
23459     value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
23460     value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
23461 #endif
23462     if (decref_tuple) {
23463         Py_DECREF(tuple);
23464     }
23465     *pvalue1 = value1;
23466     *pvalue2 = value2;
23467     return 0;
23468 #if CYTHON_COMPILING_IN_PYPY
23469 bad:
23470     Py_XDECREF(value1);
23471     Py_XDECREF(value2);
23472     if (decref_tuple) { Py_XDECREF(tuple); }
23473     return -1;
23474 #endif
23475 }
23476 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
23477                                        int has_known_size, int decref_tuple) {
23478     Py_ssize_t index;
23479     PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
23480     iternextfunc iternext;
23481     iter = PyObject_GetIter(tuple);
23482     if (unlikely(!iter)) goto bad;
23483     if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
23484     iternext = Py_TYPE(iter)->tp_iternext;
23485     value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
23486     value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
23487     if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
23488     Py_DECREF(iter);
23489     *pvalue1 = value1;
23490     *pvalue2 = value2;
23491     return 0;
23492 unpacking_failed:
23493     if (!has_known_size && __Pyx_IterFinish() == 0)
23494         __Pyx_RaiseNeedMoreValuesError(index);
23495 bad:
23496     Py_XDECREF(iter);
23497     Py_XDECREF(value1);
23498     Py_XDECREF(value2);
23499     if (decref_tuple) { Py_XDECREF(tuple); }
23500     return -1;
23501 }
23502
23503 /* dict_iter */
23504 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
23505                                                    Py_ssize_t* p_orig_length, int* p_source_is_dict) {
23506     is_dict = is_dict || likely(PyDict_CheckExact(iterable));
23507     *p_source_is_dict = is_dict;
23508     if (is_dict) {
23509 #if !CYTHON_COMPILING_IN_PYPY
23510         *p_orig_length = PyDict_Size(iterable);
23511         Py_INCREF(iterable);
23512         return iterable;
23513 #elif PY_MAJOR_VERSION >= 3
23514         static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
23515         PyObject **pp = NULL;
23516         if (method_name) {
23517             const char *name = PyUnicode_AsUTF8(method_name);
23518             if (strcmp(name, "iteritems") == 0) pp = &py_items;
23519             else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
23520             else if (strcmp(name, "itervalues") == 0) pp = &py_values;
23521             if (pp) {
23522                 if (!*pp) {
23523                     *pp = PyUnicode_FromString(name + 4);
23524                     if (!*pp)
23525                         return NULL;
23526                 }
23527                 method_name = *pp;
23528             }
23529         }
23530 #endif
23531     }
23532     *p_orig_length = 0;
23533     if (method_name) {
23534         PyObject* iter;
23535         iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
23536         if (!iterable)
23537             return NULL;
23538 #if !CYTHON_COMPILING_IN_PYPY
23539         if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
23540             return iterable;
23541 #endif
23542         iter = PyObject_GetIter(iterable);
23543         Py_DECREF(iterable);
23544         return iter;
23545     }
23546     return PyObject_GetIter(iterable);
23547 }
23548 static CYTHON_INLINE int __Pyx_dict_iter_next(
23549         PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
23550         PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
23551     PyObject* next_item;
23552 #if !CYTHON_COMPILING_IN_PYPY
23553     if (source_is_dict) {
23554         PyObject *key, *value;
23555         if (unlikely(orig_length != PyDict_Size(iter_obj))) {
23556             PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
23557             return -1;
23558         }
23559         if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
23560             return 0;
23561         }
23562         if (pitem) {
23563             PyObject* tuple = PyTuple_New(2);
23564             if (unlikely(!tuple)) {
23565                 return -1;
23566             }
23567             Py_INCREF(key);
23568             Py_INCREF(value);
23569             PyTuple_SET_ITEM(tuple, 0, key);
23570             PyTuple_SET_ITEM(tuple, 1, value);
23571             *pitem = tuple;
23572         } else {
23573             if (pkey) {
23574                 Py_INCREF(key);
23575                 *pkey = key;
23576             }
23577             if (pvalue) {
23578                 Py_INCREF(value);
23579                 *pvalue = value;
23580             }
23581         }
23582         return 1;
23583     } else if (PyTuple_CheckExact(iter_obj)) {
23584         Py_ssize_t pos = *ppos;
23585         if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
23586         *ppos = pos + 1;
23587         next_item = PyTuple_GET_ITEM(iter_obj, pos);
23588         Py_INCREF(next_item);
23589     } else if (PyList_CheckExact(iter_obj)) {
23590         Py_ssize_t pos = *ppos;
23591         if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
23592         *ppos = pos + 1;
23593         next_item = PyList_GET_ITEM(iter_obj, pos);
23594         Py_INCREF(next_item);
23595     } else
23596 #endif
23597     {
23598         next_item = PyIter_Next(iter_obj);
23599         if (unlikely(!next_item)) {
23600             return __Pyx_IterFinish();
23601         }
23602     }
23603     if (pitem) {
23604         *pitem = next_item;
23605     } else if (pkey && pvalue) {
23606         if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
23607             return -1;
23608     } else if (pkey) {
23609         *pkey = next_item;
23610     } else {
23611         *pvalue = next_item;
23612     }
23613     return 1;
23614 }
23615
23616 /* SliceObject */
23617 static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
23618         Py_ssize_t cstart, Py_ssize_t cstop,
23619         PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
23620         int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
23621 #if CYTHON_USE_TYPE_SLOTS
23622     PyMappingMethods* mp;
23623 #if PY_MAJOR_VERSION < 3
23624     PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
23625     if (likely(ms && ms->sq_ass_slice)) {
23626         if (!has_cstart) {
23627             if (_py_start && (*_py_start != Py_None)) {
23628                 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
23629                 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
23630             } else
23631                 cstart = 0;
23632         }
23633         if (!has_cstop) {
23634             if (_py_stop && (*_py_stop != Py_None)) {
23635                 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
23636                 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
23637             } else
23638                 cstop = PY_SSIZE_T_MAX;
23639         }
23640         if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
23641             Py_ssize_t l = ms->sq_length(obj);
23642             if (likely(l >= 0)) {
23643                 if (cstop < 0) {
23644                     cstop += l;
23645                     if (cstop < 0) cstop = 0;
23646                 }
23647                 if (cstart < 0) {
23648                     cstart += l;
23649                     if (cstart < 0) cstart = 0;
23650                 }
23651             } else {
23652                 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
23653                     goto bad;
23654                 PyErr_Clear();
23655             }
23656         }
23657         return ms->sq_ass_slice(obj, cstart, cstop, value);
23658     }
23659 #endif
23660     mp = Py_TYPE(obj)->tp_as_mapping;
23661     if (likely(mp && mp->mp_ass_subscript))
23662 #endif
23663     {
23664         int result;
23665         PyObject *py_slice, *py_start, *py_stop;
23666         if (_py_slice) {
23667             py_slice = *_py_slice;
23668         } else {
23669             PyObject* owned_start = NULL;
23670             PyObject* owned_stop = NULL;
23671             if (_py_start) {
23672                 py_start = *_py_start;
23673             } else {
23674                 if (has_cstart) {
23675                     owned_start = py_start = PyInt_FromSsize_t(cstart);
23676                     if (unlikely(!py_start)) goto bad;
23677                 } else
23678                     py_start = Py_None;
23679             }
23680             if (_py_stop) {
23681                 py_stop = *_py_stop;
23682             } else {
23683                 if (has_cstop) {
23684                     owned_stop = py_stop = PyInt_FromSsize_t(cstop);
23685                     if (unlikely(!py_stop)) {
23686                         Py_XDECREF(owned_start);
23687                         goto bad;
23688                     }
23689                 } else
23690                     py_stop = Py_None;
23691             }
23692             py_slice = PySlice_New(py_start, py_stop, Py_None);
23693             Py_XDECREF(owned_start);
23694             Py_XDECREF(owned_stop);
23695             if (unlikely(!py_slice)) goto bad;
23696         }
23697 #if CYTHON_USE_TYPE_SLOTS
23698         result = mp->mp_ass_subscript(obj, py_slice, value);
23699 #else
23700         result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
23701 #endif
23702         if (!_py_slice) {
23703             Py_DECREF(py_slice);
23704         }
23705         return result;
23706     }
23707     PyErr_Format(PyExc_TypeError,
23708         "'%.200s' object does not support slice %.10s",
23709         Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
23710 bad:
23711     return -1;
23712 }
23713
23714 /* PyIntCompare */
23715 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
23716     if (op1 == op2) {
23717         Py_RETURN_TRUE;
23718     }
23719     #if PY_MAJOR_VERSION < 3
23720     if (likely(PyInt_CheckExact(op1))) {
23721         const long b = intval;
23722         long a = PyInt_AS_LONG(op1);
23723         if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23724     }
23725     #endif
23726     #if CYTHON_USE_PYLONG_INTERNALS
23727     if (likely(PyLong_CheckExact(op1))) {
23728         int unequal;
23729         unsigned long uintval;
23730         Py_ssize_t size = Py_SIZE(op1);
23731         const digit* digits = ((PyLongObject*)op1)->ob_digit;
23732         if (intval == 0) {
23733             if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23734         } else if (intval < 0) {
23735             if (size >= 0)
23736                 Py_RETURN_FALSE;
23737             intval = -intval;
23738             size = -size;
23739         } else {
23740             if (size <= 0)
23741                 Py_RETURN_FALSE;
23742         }
23743         uintval = (unsigned long) intval;
23744 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
23745         if (uintval >> (PyLong_SHIFT * 4)) {
23746             unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23747                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23748         } else
23749 #endif
23750 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
23751         if (uintval >> (PyLong_SHIFT * 3)) {
23752             unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23753                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23754         } else
23755 #endif
23756 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
23757         if (uintval >> (PyLong_SHIFT * 2)) {
23758             unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23759                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23760         } else
23761 #endif
23762 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
23763         if (uintval >> (PyLong_SHIFT * 1)) {
23764             unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23765                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23766         } else
23767 #endif
23768             unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
23769         if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23770     }
23771     #endif
23772     if (PyFloat_CheckExact(op1)) {
23773         const long b = intval;
23774         double a = PyFloat_AS_DOUBLE(op1);
23775         if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23776     }
23777     return (
23778         PyObject_RichCompare(op1, op2, Py_EQ));
23779 }
23780
23781 /* PyIntBinop */
23782 #if !CYTHON_COMPILING_IN_PYPY
23783 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
23784     (void)inplace;
23785     (void)zerodivision_check;
23786     #if PY_MAJOR_VERSION < 3
23787     if (likely(PyInt_CheckExact(op1))) {
23788         const long b = intval;
23789         long x;
23790         long a = PyInt_AS_LONG(op1);
23791             x = (long)((unsigned long)a - b);
23792             if (likely((x^a) >= 0 || (x^~b) >= 0))
23793                 return PyInt_FromLong(x);
23794             return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
23795     }
23796     #endif
23797     #if CYTHON_USE_PYLONG_INTERNALS
23798     if (likely(PyLong_CheckExact(op1))) {
23799         const long b = intval;
23800         long a, x;
23801 #ifdef HAVE_LONG_LONG
23802         const PY_LONG_LONG llb = intval;
23803         PY_LONG_LONG lla, llx;
23804 #endif
23805         const digit* digits = ((PyLongObject*)op1)->ob_digit;
23806         const Py_ssize_t size = Py_SIZE(op1);
23807         if (likely(__Pyx_sst_abs(size) <= 1)) {
23808             a = likely(size) ? digits[0] : 0;
23809             if (size == -1) a = -a;
23810         } else {
23811             switch (size) {
23812                 case -2:
23813                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
23814                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23815                         break;
23816 #ifdef HAVE_LONG_LONG
23817                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
23818                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23819                         goto long_long;
23820 #endif
23821                     }
23822                     CYTHON_FALLTHROUGH;
23823                 case 2:
23824                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
23825                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23826                         break;
23827 #ifdef HAVE_LONG_LONG
23828                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
23829                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23830                         goto long_long;
23831 #endif
23832                     }
23833                     CYTHON_FALLTHROUGH;
23834                 case -3:
23835                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
23836                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23837                         break;
23838 #ifdef HAVE_LONG_LONG
23839                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
23840                         lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23841                         goto long_long;
23842 #endif
23843                     }
23844                     CYTHON_FALLTHROUGH;
23845                 case 3:
23846                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
23847                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23848                         break;
23849 #ifdef HAVE_LONG_LONG
23850                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
23851                         lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23852                         goto long_long;
23853 #endif
23854                     }
23855                     CYTHON_FALLTHROUGH;
23856                 case -4:
23857                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
23858                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23859                         break;
23860 #ifdef HAVE_LONG_LONG
23861                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
23862                         lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23863                         goto long_long;
23864 #endif
23865                     }
23866                     CYTHON_FALLTHROUGH;
23867                 case 4:
23868                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
23869                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23870                         break;
23871 #ifdef HAVE_LONG_LONG
23872                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
23873                         lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
23874                         goto long_long;
23875 #endif
23876                     }
23877                     CYTHON_FALLTHROUGH;
23878                 default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
23879             }
23880         }
23881                 x = a - b;
23882             return PyLong_FromLong(x);
23883 #ifdef HAVE_LONG_LONG
23884         long_long:
23885                 llx = lla - llb;
23886             return PyLong_FromLongLong(llx);
23887 #endif
23888         
23889         
23890     }
23891     #endif
23892     if (PyFloat_CheckExact(op1)) {
23893         const long b = intval;
23894         double a = PyFloat_AS_DOUBLE(op1);
23895             double result;
23896             PyFPE_START_PROTECT("subtract", return NULL)
23897             result = ((double)a) - (double)b;
23898             PyFPE_END_PROTECT(result)
23899             return PyFloat_FromDouble(result);
23900     }
23901     return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
23902 }
23903 #endif
23904
23905 /* ObjectGetItem */
23906 #if CYTHON_USE_TYPE_SLOTS
23907 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
23908     PyObject *runerr;
23909     Py_ssize_t key_value;
23910     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
23911     if (unlikely(!(m && m->sq_item))) {
23912         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
23913         return NULL;
23914     }
23915     key_value = __Pyx_PyIndex_AsSsize_t(index);
23916     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
23917         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
23918     }
23919     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
23920         PyErr_Clear();
23921         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
23922     }
23923     return NULL;
23924 }
23925 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
23926     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
23927     if (likely(m && m->mp_subscript)) {
23928         return m->mp_subscript(obj, key);
23929     }
23930     return __Pyx_PyObject_GetIndex(obj, key);
23931 }
23932 #endif
23933
23934 /* PyIntBinop */
23935 #if !CYTHON_COMPILING_IN_PYPY
23936 #if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
23937 #define __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(operand)\
23938     if (unlikely(zerodivision_check && ((operand) == 0))) {\
23939         PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
23940         return NULL;\
23941     }
23942 #endif
23943 static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
23944     (void)inplace;
23945     (void)zerodivision_check;
23946     #if PY_MAJOR_VERSION < 3
23947     if (likely(PyInt_CheckExact(op1))) {
23948         const long b = intval;
23949         long a = PyInt_AS_LONG(op1);
23950             __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
23951             if (8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) {
23952                 return PyFloat_FromDouble((double)a / (double)b);
23953             }
23954             return PyInt_Type.tp_as_number->nb_true_divide(op1, op2);
23955     }
23956     #endif
23957     #if CYTHON_USE_PYLONG_INTERNALS
23958     if (likely(PyLong_CheckExact(op1))) {
23959         const long b = intval;
23960         long a, x;
23961         const digit* digits = ((PyLongObject*)op1)->ob_digit;
23962         const Py_ssize_t size = Py_SIZE(op1);
23963         if (likely(__Pyx_sst_abs(size) <= 1)) {
23964             a = likely(size) ? digits[0] : 0;
23965             if (size == -1) a = -a;
23966         } else {
23967             switch (size) {
23968                 case -2:
23969                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
23970                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23971                         break;
23972                     }
23973                     CYTHON_FALLTHROUGH;
23974                 case 2:
23975                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
23976                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23977                         break;
23978                     }
23979                     CYTHON_FALLTHROUGH;
23980                 case -3:
23981                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
23982                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23983                         break;
23984                     }
23985                     CYTHON_FALLTHROUGH;
23986                 case 3:
23987                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
23988                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23989                         break;
23990                     }
23991                     CYTHON_FALLTHROUGH;
23992                 case -4:
23993                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
23994                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
23995                         break;
23996                     }
23997                     CYTHON_FALLTHROUGH;
23998                 case 4:
23999                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
24000                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
24001                         break;
24002                     }
24003                     CYTHON_FALLTHROUGH;
24004                 default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
24005             }
24006         }
24007                 __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
24008                 if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53)))
24009                         || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
24010                     return PyFloat_FromDouble((double)a / (double)b);
24011                 }
24012                 return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
24013             return PyLong_FromLong(x);
24014         
24015     }
24016     #endif
24017     if (PyFloat_CheckExact(op1)) {
24018         const long b = intval;
24019         double a = PyFloat_AS_DOUBLE(op1);
24020             double result;
24021             if (unlikely(zerodivision_check && b == 0)) {
24022                 PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");
24023                 return NULL;
24024             }
24025             PyFPE_START_PROTECT("divide", return NULL)
24026             result = ((double)a) / (double)b;
24027             PyFPE_END_PROTECT(result)
24028             return PyFloat_FromDouble(result);
24029     }
24030     return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
24031 }
24032 #endif
24033
24034 /* PyObject_GenericGetAttrNoDict */
24035 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
24036 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
24037     PyErr_Format(PyExc_AttributeError,
24038 #if PY_MAJOR_VERSION >= 3
24039                  "'%.50s' object has no attribute '%U'",
24040                  tp->tp_name, attr_name);
24041 #else
24042                  "'%.50s' object has no attribute '%.400s'",
24043                  tp->tp_name, PyString_AS_STRING(attr_name));
24044 #endif
24045     return NULL;
24046 }
24047 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
24048     PyObject *descr;
24049     PyTypeObject *tp = Py_TYPE(obj);
24050     if (unlikely(!PyString_Check(attr_name))) {
24051         return PyObject_GenericGetAttr(obj, attr_name);
24052     }
24053     assert(!tp->tp_dictoffset);
24054     descr = _PyType_Lookup(tp, attr_name);
24055     if (unlikely(!descr)) {
24056         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
24057     }
24058     Py_INCREF(descr);
24059     #if PY_MAJOR_VERSION < 3
24060     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
24061     #endif
24062     {
24063         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
24064         if (unlikely(f)) {
24065             PyObject *res = f(descr, obj, (PyObject *)tp);
24066             Py_DECREF(descr);
24067             return res;
24068         }
24069     }
24070     return descr;
24071 }
24072 #endif
24073
24074 /* Import */
24075 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
24076     PyObject *empty_list = 0;
24077     PyObject *module = 0;
24078     PyObject *global_dict = 0;
24079     PyObject *empty_dict = 0;
24080     PyObject *list;
24081     #if PY_MAJOR_VERSION < 3
24082     PyObject *py_import;
24083     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
24084     if (!py_import)
24085         goto bad;
24086     #endif
24087     if (from_list)
24088         list = from_list;
24089     else {
24090         empty_list = PyList_New(0);
24091         if (!empty_list)
24092             goto bad;
24093         list = empty_list;
24094     }
24095     global_dict = PyModule_GetDict(__pyx_m);
24096     if (!global_dict)
24097         goto bad;
24098     empty_dict = PyDict_New();
24099     if (!empty_dict)
24100         goto bad;
24101     {
24102         #if PY_MAJOR_VERSION >= 3
24103         if (level == -1) {
24104             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
24105                 module = PyImport_ImportModuleLevelObject(
24106                     name, global_dict, empty_dict, list, 1);
24107                 if (!module) {
24108                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
24109                         goto bad;
24110                     PyErr_Clear();
24111                 }
24112             }
24113             level = 0;
24114         }
24115         #endif
24116         if (!module) {
24117             #if PY_MAJOR_VERSION < 3
24118             PyObject *py_level = PyInt_FromLong(level);
24119             if (!py_level)
24120                 goto bad;
24121             module = PyObject_CallFunctionObjArgs(py_import,
24122                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
24123             Py_DECREF(py_level);
24124             #else
24125             module = PyImport_ImportModuleLevelObject(
24126                 name, global_dict, empty_dict, list, level);
24127             #endif
24128         }
24129     }
24130 bad:
24131     #if PY_MAJOR_VERSION < 3
24132     Py_XDECREF(py_import);
24133     #endif
24134     Py_XDECREF(empty_list);
24135     Py_XDECREF(empty_dict);
24136     return module;
24137 }
24138
24139 /* ImportFrom */
24140 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
24141     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
24142     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
24143         PyErr_Format(PyExc_ImportError,
24144         #if PY_MAJOR_VERSION < 3
24145             "cannot import name %.230s", PyString_AS_STRING(name));
24146         #else
24147             "cannot import name %S", name);
24148         #endif
24149     }
24150     return value;
24151 }
24152
24153 /* FetchCommonType */
24154 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
24155     PyObject* fake_module;
24156     PyTypeObject* cached_type = NULL;
24157     fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
24158     if (!fake_module) return NULL;
24159     Py_INCREF(fake_module);
24160     cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
24161     if (cached_type) {
24162         if (!PyType_Check((PyObject*)cached_type)) {
24163             PyErr_Format(PyExc_TypeError,
24164                 "Shared Cython type %.200s is not a type object",
24165                 type->tp_name);
24166             goto bad;
24167         }
24168         if (cached_type->tp_basicsize != type->tp_basicsize) {
24169             PyErr_Format(PyExc_TypeError,
24170                 "Shared Cython type %.200s has the wrong size, try recompiling",
24171                 type->tp_name);
24172             goto bad;
24173         }
24174     } else {
24175         if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
24176         PyErr_Clear();
24177         if (PyType_Ready(type) < 0) goto bad;
24178         if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
24179             goto bad;
24180         Py_INCREF(type);
24181         cached_type = type;
24182     }
24183 done:
24184     Py_DECREF(fake_module);
24185     return cached_type;
24186 bad:
24187     Py_XDECREF(cached_type);
24188     cached_type = NULL;
24189     goto done;
24190 }
24191
24192 /* CythonFunctionShared */
24193 #include <structmember.h>
24194 static PyObject *
24195 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
24196 {
24197     if (unlikely(op->func_doc == NULL)) {
24198         if (op->func.m_ml->ml_doc) {
24199 #if PY_MAJOR_VERSION >= 3
24200             op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
24201 #else
24202             op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
24203 #endif
24204             if (unlikely(op->func_doc == NULL))
24205                 return NULL;
24206         } else {
24207             Py_INCREF(Py_None);
24208             return Py_None;
24209         }
24210     }
24211     Py_INCREF(op->func_doc);
24212     return op->func_doc;
24213 }
24214 static int
24215 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
24216 {
24217     PyObject *tmp = op->func_doc;
24218     if (value == NULL) {
24219         value = Py_None;
24220     }
24221     Py_INCREF(value);
24222     op->func_doc = value;
24223     Py_XDECREF(tmp);
24224     return 0;
24225 }
24226 static PyObject *
24227 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24228 {
24229     if (unlikely(op->func_name == NULL)) {
24230 #if PY_MAJOR_VERSION >= 3
24231         op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
24232 #else
24233         op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
24234 #endif
24235         if (unlikely(op->func_name == NULL))
24236             return NULL;
24237     }
24238     Py_INCREF(op->func_name);
24239     return op->func_name;
24240 }
24241 static int
24242 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
24243 {
24244     PyObject *tmp;
24245 #if PY_MAJOR_VERSION >= 3
24246     if (unlikely(value == NULL || !PyUnicode_Check(value)))
24247 #else
24248     if (unlikely(value == NULL || !PyString_Check(value)))
24249 #endif
24250     {
24251         PyErr_SetString(PyExc_TypeError,
24252                         "__name__ must be set to a string object");
24253         return -1;
24254     }
24255     tmp = op->func_name;
24256     Py_INCREF(value);
24257     op->func_name = value;
24258     Py_XDECREF(tmp);
24259     return 0;
24260 }
24261 static PyObject *
24262 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24263 {
24264     Py_INCREF(op->func_qualname);
24265     return op->func_qualname;
24266 }
24267 static int
24268 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
24269 {
24270     PyObject *tmp;
24271 #if PY_MAJOR_VERSION >= 3
24272     if (unlikely(value == NULL || !PyUnicode_Check(value)))
24273 #else
24274     if (unlikely(value == NULL || !PyString_Check(value)))
24275 #endif
24276     {
24277         PyErr_SetString(PyExc_TypeError,
24278                         "__qualname__ must be set to a string object");
24279         return -1;
24280     }
24281     tmp = op->func_qualname;
24282     Py_INCREF(value);
24283     op->func_qualname = value;
24284     Py_XDECREF(tmp);
24285     return 0;
24286 }
24287 static PyObject *
24288 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
24289 {
24290     PyObject *self;
24291     self = m->func_closure;
24292     if (self == NULL)
24293         self = Py_None;
24294     Py_INCREF(self);
24295     return self;
24296 }
24297 static PyObject *
24298 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24299 {
24300     if (unlikely(op->func_dict == NULL)) {
24301         op->func_dict = PyDict_New();
24302         if (unlikely(op->func_dict == NULL))
24303             return NULL;
24304     }
24305     Py_INCREF(op->func_dict);
24306     return op->func_dict;
24307 }
24308 static int
24309 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
24310 {
24311     PyObject *tmp;
24312     if (unlikely(value == NULL)) {
24313         PyErr_SetString(PyExc_TypeError,
24314                "function's dictionary may not be deleted");
24315         return -1;
24316     }
24317     if (unlikely(!PyDict_Check(value))) {
24318         PyErr_SetString(PyExc_TypeError,
24319                "setting function's dictionary to a non-dict");
24320         return -1;
24321     }
24322     tmp = op->func_dict;
24323     Py_INCREF(value);
24324     op->func_dict = value;
24325     Py_XDECREF(tmp);
24326     return 0;
24327 }
24328 static PyObject *
24329 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24330 {
24331     Py_INCREF(op->func_globals);
24332     return op->func_globals;
24333 }
24334 static PyObject *
24335 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24336 {
24337     Py_INCREF(Py_None);
24338     return Py_None;
24339 }
24340 static PyObject *
24341 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
24342 {
24343     PyObject* result = (op->func_code) ? op->func_code : Py_None;
24344     Py_INCREF(result);
24345     return result;
24346 }
24347 static int
24348 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
24349     int result = 0;
24350     PyObject *res = op->defaults_getter((PyObject *) op);
24351     if (unlikely(!res))
24352         return -1;
24353     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
24354     op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
24355     Py_INCREF(op->defaults_tuple);
24356     op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
24357     Py_INCREF(op->defaults_kwdict);
24358     #else
24359     op->defaults_tuple = PySequence_ITEM(res, 0);
24360     if (unlikely(!op->defaults_tuple)) result = -1;
24361     else {
24362         op->defaults_kwdict = PySequence_ITEM(res, 1);
24363         if (unlikely(!op->defaults_kwdict)) result = -1;
24364     }
24365     #endif
24366     Py_DECREF(res);
24367     return result;
24368 }
24369 static int
24370 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
24371     PyObject* tmp;
24372     if (!value) {
24373         value = Py_None;
24374     } else if (value != Py_None && !PyTuple_Check(value)) {
24375         PyErr_SetString(PyExc_TypeError,
24376                         "__defaults__ must be set to a tuple object");
24377         return -1;
24378     }
24379     Py_INCREF(value);
24380     tmp = op->defaults_tuple;
24381     op->defaults_tuple = value;
24382     Py_XDECREF(tmp);
24383     return 0;
24384 }
24385 static PyObject *
24386 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
24387     PyObject* result = op->defaults_tuple;
24388     if (unlikely(!result)) {
24389         if (op->defaults_getter) {
24390             if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
24391             result = op->defaults_tuple;
24392         } else {
24393             result = Py_None;
24394         }
24395     }
24396     Py_INCREF(result);
24397     return result;
24398 }
24399 static int
24400 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
24401     PyObject* tmp;
24402     if (!value) {
24403         value = Py_None;
24404     } else if (value != Py_None && !PyDict_Check(value)) {
24405         PyErr_SetString(PyExc_TypeError,
24406                         "__kwdefaults__ must be set to a dict object");
24407         return -1;
24408     }
24409     Py_INCREF(value);
24410     tmp = op->defaults_kwdict;
24411     op->defaults_kwdict = value;
24412     Py_XDECREF(tmp);
24413     return 0;
24414 }
24415 static PyObject *
24416 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
24417     PyObject* result = op->defaults_kwdict;
24418     if (unlikely(!result)) {
24419         if (op->defaults_getter) {
24420             if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
24421             result = op->defaults_kwdict;
24422         } else {
24423             result = Py_None;
24424         }
24425     }
24426     Py_INCREF(result);
24427     return result;
24428 }
24429 static int
24430 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
24431     PyObject* tmp;
24432     if (!value || value == Py_None) {
24433         value = NULL;
24434     } else if (!PyDict_Check(value)) {
24435         PyErr_SetString(PyExc_TypeError,
24436                         "__annotations__ must be set to a dict object");
24437         return -1;
24438     }
24439     Py_XINCREF(value);
24440     tmp = op->func_annotations;
24441     op->func_annotations = value;
24442     Py_XDECREF(tmp);
24443     return 0;
24444 }
24445 static PyObject *
24446 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
24447     PyObject* result = op->func_annotations;
24448     if (unlikely(!result)) {
24449         result = PyDict_New();
24450         if (unlikely(!result)) return NULL;
24451         op->func_annotations = result;
24452     }
24453     Py_INCREF(result);
24454     return result;
24455 }
24456 static PyGetSetDef __pyx_CyFunction_getsets[] = {
24457     {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
24458     {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
24459     {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
24460     {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
24461     {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
24462     {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
24463     {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
24464     {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
24465     {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
24466     {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
24467     {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
24468     {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
24469     {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
24470     {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
24471     {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
24472     {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
24473     {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
24474     {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
24475     {0, 0, 0, 0, 0}
24476 };
24477 static PyMemberDef __pyx_CyFunction_members[] = {
24478     {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
24479     {0, 0, 0,  0, 0}
24480 };
24481 static PyObject *
24482 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
24483 {
24484 #if PY_MAJOR_VERSION >= 3
24485     return PyUnicode_FromString(m->func.m_ml->ml_name);
24486 #else
24487     return PyString_FromString(m->func.m_ml->ml_name);
24488 #endif
24489 }
24490 static PyMethodDef __pyx_CyFunction_methods[] = {
24491     {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
24492     {0, 0, 0, 0}
24493 };
24494 #if PY_VERSION_HEX < 0x030500A0
24495 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
24496 #else
24497 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
24498 #endif
24499 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
24500                                        PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
24501     if (unlikely(op == NULL))
24502         return NULL;
24503     op->flags = flags;
24504     __Pyx_CyFunction_weakreflist(op) = NULL;
24505     op->func.m_ml = ml;
24506     op->func.m_self = (PyObject *) op;
24507     Py_XINCREF(closure);
24508     op->func_closure = closure;
24509     Py_XINCREF(module);
24510     op->func.m_module = module;
24511     op->func_dict = NULL;
24512     op->func_name = NULL;
24513     Py_INCREF(qualname);
24514     op->func_qualname = qualname;
24515     op->func_doc = NULL;
24516     op->func_classobj = NULL;
24517     op->func_globals = globals;
24518     Py_INCREF(op->func_globals);
24519     Py_XINCREF(code);
24520     op->func_code = code;
24521     op->defaults_pyobjects = 0;
24522     op->defaults_size = 0;
24523     op->defaults = NULL;
24524     op->defaults_tuple = NULL;
24525     op->defaults_kwdict = NULL;
24526     op->defaults_getter = NULL;
24527     op->func_annotations = NULL;
24528     return (PyObject *) op;
24529 }
24530 static int
24531 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
24532 {
24533     Py_CLEAR(m->func_closure);
24534     Py_CLEAR(m->func.m_module);
24535     Py_CLEAR(m->func_dict);
24536     Py_CLEAR(m->func_name);
24537     Py_CLEAR(m->func_qualname);
24538     Py_CLEAR(m->func_doc);
24539     Py_CLEAR(m->func_globals);
24540     Py_CLEAR(m->func_code);
24541     Py_CLEAR(m->func_classobj);
24542     Py_CLEAR(m->defaults_tuple);
24543     Py_CLEAR(m->defaults_kwdict);
24544     Py_CLEAR(m->func_annotations);
24545     if (m->defaults) {
24546         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
24547         int i;
24548         for (i = 0; i < m->defaults_pyobjects; i++)
24549             Py_XDECREF(pydefaults[i]);
24550         PyObject_Free(m->defaults);
24551         m->defaults = NULL;
24552     }
24553     return 0;
24554 }
24555 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
24556 {
24557     if (__Pyx_CyFunction_weakreflist(m) != NULL)
24558         PyObject_ClearWeakRefs((PyObject *) m);
24559     __Pyx_CyFunction_clear(m);
24560     PyObject_GC_Del(m);
24561 }
24562 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
24563 {
24564     PyObject_GC_UnTrack(m);
24565     __Pyx__CyFunction_dealloc(m);
24566 }
24567 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
24568 {
24569     Py_VISIT(m->func_closure);
24570     Py_VISIT(m->func.m_module);
24571     Py_VISIT(m->func_dict);
24572     Py_VISIT(m->func_name);
24573     Py_VISIT(m->func_qualname);
24574     Py_VISIT(m->func_doc);
24575     Py_VISIT(m->func_globals);
24576     Py_VISIT(m->func_code);
24577     Py_VISIT(m->func_classobj);
24578     Py_VISIT(m->defaults_tuple);
24579     Py_VISIT(m->defaults_kwdict);
24580     if (m->defaults) {
24581         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
24582         int i;
24583         for (i = 0; i < m->defaults_pyobjects; i++)
24584             Py_VISIT(pydefaults[i]);
24585     }
24586     return 0;
24587 }
24588 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
24589 {
24590     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
24591     if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
24592         Py_INCREF(func);
24593         return func;
24594     }
24595     if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
24596         if (type == NULL)
24597             type = (PyObject *)(Py_TYPE(obj));
24598         return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
24599     }
24600     if (obj == Py_None)
24601         obj = NULL;
24602     return __Pyx_PyMethod_New(func, obj, type);
24603 }
24604 static PyObject*
24605 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
24606 {
24607 #if PY_MAJOR_VERSION >= 3
24608     return PyUnicode_FromFormat("<cyfunction %U at %p>",
24609                                 op->func_qualname, (void *)op);
24610 #else
24611     return PyString_FromFormat("<cyfunction %s at %p>",
24612                                PyString_AsString(op->func_qualname), (void *)op);
24613 #endif
24614 }
24615 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
24616     PyCFunctionObject* f = (PyCFunctionObject*)func;
24617     PyCFunction meth = f->m_ml->ml_meth;
24618     Py_ssize_t size;
24619     switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
24620     case METH_VARARGS:
24621         if (likely(kw == NULL || PyDict_Size(kw) == 0))
24622             return (*meth)(self, arg);
24623         break;
24624     case METH_VARARGS | METH_KEYWORDS:
24625         return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
24626     case METH_NOARGS:
24627         if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
24628             size = PyTuple_GET_SIZE(arg);
24629             if (likely(size == 0))
24630                 return (*meth)(self, NULL);
24631             PyErr_Format(PyExc_TypeError,
24632                 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
24633                 f->m_ml->ml_name, size);
24634             return NULL;
24635         }
24636         break;
24637     case METH_O:
24638         if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
24639             size = PyTuple_GET_SIZE(arg);
24640             if (likely(size == 1)) {
24641                 PyObject *result, *arg0;
24642                 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
24643                 arg0 = PyTuple_GET_ITEM(arg, 0);
24644                 #else
24645                 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
24646                 #endif
24647                 result = (*meth)(self, arg0);
24648                 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
24649                 Py_DECREF(arg0);
24650                 #endif
24651                 return result;
24652             }
24653             PyErr_Format(PyExc_TypeError,
24654                 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
24655                 f->m_ml->ml_name, size);
24656             return NULL;
24657         }
24658         break;
24659     default:
24660         PyErr_SetString(PyExc_SystemError, "Bad call flags in "
24661                         "__Pyx_CyFunction_Call. METH_OLDARGS is no "
24662                         "longer supported!");
24663         return NULL;
24664     }
24665     PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
24666                  f->m_ml->ml_name);
24667     return NULL;
24668 }
24669 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
24670     return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
24671 }
24672 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
24673     PyObject *result;
24674     __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
24675     if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
24676         Py_ssize_t argc;
24677         PyObject *new_args;
24678         PyObject *self;
24679         argc = PyTuple_GET_SIZE(args);
24680         new_args = PyTuple_GetSlice(args, 1, argc);
24681         if (unlikely(!new_args))
24682             return NULL;
24683         self = PyTuple_GetItem(args, 0);
24684         if (unlikely(!self)) {
24685             Py_DECREF(new_args);
24686             return NULL;
24687         }
24688         result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
24689         Py_DECREF(new_args);
24690     } else {
24691         result = __Pyx_CyFunction_Call(func, args, kw);
24692     }
24693     return result;
24694 }
24695 static PyTypeObject __pyx_CyFunctionType_type = {
24696     PyVarObject_HEAD_INIT(0, 0)
24697     "cython_function_or_method",
24698     sizeof(__pyx_CyFunctionObject),
24699     0,
24700     (destructor) __Pyx_CyFunction_dealloc,
24701     0,
24702     0,
24703     0,
24704 #if PY_MAJOR_VERSION < 3
24705     0,
24706 #else
24707     0,
24708 #endif
24709     (reprfunc) __Pyx_CyFunction_repr,
24710     0,
24711     0,
24712     0,
24713     0,
24714     __Pyx_CyFunction_CallAsMethod,
24715     0,
24716     0,
24717     0,
24718     0,
24719     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
24720     0,
24721     (traverseproc) __Pyx_CyFunction_traverse,
24722     (inquiry) __Pyx_CyFunction_clear,
24723     0,
24724 #if PY_VERSION_HEX < 0x030500A0
24725     offsetof(__pyx_CyFunctionObject, func_weakreflist),
24726 #else
24727     offsetof(PyCFunctionObject, m_weakreflist),
24728 #endif
24729     0,
24730     0,
24731     __pyx_CyFunction_methods,
24732     __pyx_CyFunction_members,
24733     __pyx_CyFunction_getsets,
24734     0,
24735     0,
24736     __Pyx_CyFunction_descr_get,
24737     0,
24738     offsetof(__pyx_CyFunctionObject, func_dict),
24739     0,
24740     0,
24741     0,
24742     0,
24743     0,
24744     0,
24745     0,
24746     0,
24747     0,
24748     0,
24749     0,
24750     0,
24751 #if PY_VERSION_HEX >= 0x030400a1
24752     0,
24753 #endif
24754 #if PY_VERSION_HEX >= 0x030800b1
24755     0,
24756 #endif
24757 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
24758     0,
24759 #endif
24760 };
24761 static int __pyx_CyFunction_init(void) {
24762     __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
24763     if (unlikely(__pyx_CyFunctionType == NULL)) {
24764         return -1;
24765     }
24766     return 0;
24767 }
24768 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
24769     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
24770     m->defaults = PyObject_Malloc(size);
24771     if (unlikely(!m->defaults))
24772         return PyErr_NoMemory();
24773     memset(m->defaults, 0, size);
24774     m->defaults_pyobjects = pyobjects;
24775     m->defaults_size = size;
24776     return m->defaults;
24777 }
24778 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
24779     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
24780     m->defaults_tuple = tuple;
24781     Py_INCREF(tuple);
24782 }
24783 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
24784     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
24785     m->defaults_kwdict = dict;
24786     Py_INCREF(dict);
24787 }
24788 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
24789     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
24790     m->func_annotations = dict;
24791     Py_INCREF(dict);
24792 }
24793
24794 /* CythonFunction */
24795 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
24796                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
24797     PyObject *op = __Pyx_CyFunction_Init(
24798         PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
24799         ml, flags, qualname, closure, module, globals, code
24800     );
24801     if (likely(op)) {
24802         PyObject_GC_Track(op);
24803     }
24804     return op;
24805 }
24806
24807 /* CalculateMetaclass */
24808 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
24809     Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
24810     for (i=0; i < nbases; i++) {
24811         PyTypeObject *tmptype;
24812         PyObject *tmp = PyTuple_GET_ITEM(bases, i);
24813         tmptype = Py_TYPE(tmp);
24814 #if PY_MAJOR_VERSION < 3
24815         if (tmptype == &PyClass_Type)
24816             continue;
24817 #endif
24818         if (!metaclass) {
24819             metaclass = tmptype;
24820             continue;
24821         }
24822         if (PyType_IsSubtype(metaclass, tmptype))
24823             continue;
24824         if (PyType_IsSubtype(tmptype, metaclass)) {
24825             metaclass = tmptype;
24826             continue;
24827         }
24828         PyErr_SetString(PyExc_TypeError,
24829                         "metaclass conflict: "
24830                         "the metaclass of a derived class "
24831                         "must be a (non-strict) subclass "
24832                         "of the metaclasses of all its bases");
24833         return NULL;
24834     }
24835     if (!metaclass) {
24836 #if PY_MAJOR_VERSION < 3
24837         metaclass = &PyClass_Type;
24838 #else
24839         metaclass = &PyType_Type;
24840 #endif
24841     }
24842     Py_INCREF((PyObject*) metaclass);
24843     return (PyObject*) metaclass;
24844 }
24845
24846 /* Py3ClassCreate */
24847 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
24848                                            PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
24849     PyObject *ns;
24850     if (metaclass) {
24851         PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
24852         if (prep) {
24853             PyObject *pargs = PyTuple_Pack(2, name, bases);
24854             if (unlikely(!pargs)) {
24855                 Py_DECREF(prep);
24856                 return NULL;
24857             }
24858             ns = PyObject_Call(prep, pargs, mkw);
24859             Py_DECREF(prep);
24860             Py_DECREF(pargs);
24861         } else {
24862             if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
24863                 return NULL;
24864             PyErr_Clear();
24865             ns = PyDict_New();
24866         }
24867     } else {
24868         ns = PyDict_New();
24869     }
24870     if (unlikely(!ns))
24871         return NULL;
24872     if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
24873     if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
24874     if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc_2, doc) < 0)) goto bad;
24875     return ns;
24876 bad:
24877     Py_DECREF(ns);
24878     return NULL;
24879 }
24880 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
24881                                       PyObject *dict, PyObject *mkw,
24882                                       int calculate_metaclass, int allow_py2_metaclass) {
24883     PyObject *result, *margs;
24884     PyObject *owned_metaclass = NULL;
24885     if (allow_py2_metaclass) {
24886         owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
24887         if (owned_metaclass) {
24888             metaclass = owned_metaclass;
24889         } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
24890             PyErr_Clear();
24891         } else {
24892             return NULL;
24893         }
24894     }
24895     if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
24896         metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
24897         Py_XDECREF(owned_metaclass);
24898         if (unlikely(!metaclass))
24899             return NULL;
24900         owned_metaclass = metaclass;
24901     }
24902     margs = PyTuple_Pack(3, name, bases, dict);
24903     if (unlikely(!margs)) {
24904         result = NULL;
24905     } else {
24906         result = PyObject_Call(metaclass, margs, mkw);
24907         Py_DECREF(margs);
24908     }
24909     Py_XDECREF(owned_metaclass);
24910     return result;
24911 }
24912
24913 /* RegisterModuleCleanup */
24914 #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
24915 static PyObject* __pyx_module_cleanup_atexit(PyObject *module, CYTHON_UNUSED PyObject *unused) {
24916     __pyx_module_cleanup(module);
24917     Py_INCREF(Py_None); return Py_None;
24918 }
24919 static int __Pyx_RegisterCleanup(void) {
24920     static PyMethodDef cleanup_def = {
24921         "__cleanup", (PyCFunction)__pyx_module_cleanup_atexit, METH_NOARGS, 0};
24922     PyObject *cleanup_func = 0;
24923     PyObject *atexit = 0;
24924     PyObject *reg = 0;
24925     PyObject *args = 0;
24926     PyObject *res = 0;
24927     int ret = -1;
24928     cleanup_func = PyCFunction_New(&cleanup_def, 0);
24929     if (!cleanup_func)
24930         goto bad;
24931     atexit = PyImport_ImportModule("atexit");
24932     if (!atexit)
24933         goto bad;
24934     reg = PyObject_GetAttrString(atexit, "_exithandlers");
24935     if (reg && PyList_Check(reg)) {
24936         PyObject *a, *kw;
24937         a = PyTuple_New(0);
24938         kw = PyDict_New();
24939         if (!a || !kw) {
24940             Py_XDECREF(a);
24941             Py_XDECREF(kw);
24942             goto bad;
24943         }
24944         args = PyTuple_Pack(3, cleanup_func, a, kw);
24945         Py_DECREF(a);
24946         Py_DECREF(kw);
24947         if (!args)
24948             goto bad;
24949         ret = PyList_Insert(reg, 0, args);
24950     } else {
24951         if (!reg)
24952             PyErr_Clear();
24953         Py_XDECREF(reg);
24954         reg = PyObject_GetAttrString(atexit, "register");
24955         if (!reg)
24956             goto bad;
24957         args = PyTuple_Pack(1, cleanup_func);
24958         if (!args)
24959             goto bad;
24960         res = PyObject_CallObject(reg, args);
24961         if (!res)
24962             goto bad;
24963         ret = 0;
24964     }
24965 bad:
24966     Py_XDECREF(cleanup_func);
24967     Py_XDECREF(atexit);
24968     Py_XDECREF(reg);
24969     Py_XDECREF(args);
24970     Py_XDECREF(res);
24971     return ret;
24972 }
24973 #endif
24974
24975 /* CLineInTraceback */
24976 #ifndef CYTHON_CLINE_IN_TRACEBACK
24977 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
24978     PyObject *use_cline;
24979     PyObject *ptype, *pvalue, *ptraceback;
24980 #if CYTHON_COMPILING_IN_CPYTHON
24981     PyObject **cython_runtime_dict;
24982 #endif
24983     if (unlikely(!__pyx_cython_runtime)) {
24984         return c_line;
24985     }
24986     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
24987 #if CYTHON_COMPILING_IN_CPYTHON
24988     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
24989     if (likely(cython_runtime_dict)) {
24990         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
24991             use_cline, *cython_runtime_dict,
24992             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
24993     } else
24994 #endif
24995     {
24996       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
24997       if (use_cline_obj) {
24998         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
24999         Py_DECREF(use_cline_obj);
25000       } else {
25001         PyErr_Clear();
25002         use_cline = NULL;
25003       }
25004     }
25005     if (!use_cline) {
25006         c_line = 0;
25007         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
25008     }
25009     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
25010         c_line = 0;
25011     }
25012     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
25013     return c_line;
25014 }
25015 #endif
25016
25017 /* CodeObjectCache */
25018 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
25019     int start = 0, mid = 0, end = count - 1;
25020     if (end >= 0 && code_line > entries[end].code_line) {
25021         return count;
25022     }
25023     while (start < end) {
25024         mid = start + (end - start) / 2;
25025         if (code_line < entries[mid].code_line) {
25026             end = mid;
25027         } else if (code_line > entries[mid].code_line) {
25028              start = mid + 1;
25029         } else {
25030             return mid;
25031         }
25032     }
25033     if (code_line <= entries[mid].code_line) {
25034         return mid;
25035     } else {
25036         return mid + 1;
25037     }
25038 }
25039 static PyCodeObject *__pyx_find_code_object(int code_line) {
25040     PyCodeObject* code_object;
25041     int pos;
25042     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
25043         return NULL;
25044     }
25045     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
25046     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
25047         return NULL;
25048     }
25049     code_object = __pyx_code_cache.entries[pos].code_object;
25050     Py_INCREF(code_object);
25051     return code_object;
25052 }
25053 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
25054     int pos, i;
25055     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
25056     if (unlikely(!code_line)) {
25057         return;
25058     }
25059     if (unlikely(!entries)) {
25060         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
25061         if (likely(entries)) {
25062             __pyx_code_cache.entries = entries;
25063             __pyx_code_cache.max_count = 64;
25064             __pyx_code_cache.count = 1;
25065             entries[0].code_line = code_line;
25066             entries[0].code_object = code_object;
25067             Py_INCREF(code_object);
25068         }
25069         return;
25070     }
25071     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
25072     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
25073         PyCodeObject* tmp = entries[pos].code_object;
25074         entries[pos].code_object = code_object;
25075         Py_DECREF(tmp);
25076         return;
25077     }
25078     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
25079         int new_max = __pyx_code_cache.max_count + 64;
25080         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
25081             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
25082         if (unlikely(!entries)) {
25083             return;
25084         }
25085         __pyx_code_cache.entries = entries;
25086         __pyx_code_cache.max_count = new_max;
25087     }
25088     for (i=__pyx_code_cache.count; i>pos; i--) {
25089         entries[i] = entries[i-1];
25090     }
25091     entries[pos].code_line = code_line;
25092     entries[pos].code_object = code_object;
25093     __pyx_code_cache.count++;
25094     Py_INCREF(code_object);
25095 }
25096
25097 /* AddTraceback */
25098 #include "compile.h"
25099 #include "frameobject.h"
25100 #include "traceback.h"
25101 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
25102             const char *funcname, int c_line,
25103             int py_line, const char *filename) {
25104     PyCodeObject *py_code = 0;
25105     PyObject *py_srcfile = 0;
25106     PyObject *py_funcname = 0;
25107     #if PY_MAJOR_VERSION < 3
25108     py_srcfile = PyString_FromString(filename);
25109     #else
25110     py_srcfile = PyUnicode_FromString(filename);
25111     #endif
25112     if (!py_srcfile) goto bad;
25113     if (c_line) {
25114         #if PY_MAJOR_VERSION < 3
25115         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
25116         #else
25117         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
25118         #endif
25119     }
25120     else {
25121         #if PY_MAJOR_VERSION < 3
25122         py_funcname = PyString_FromString(funcname);
25123         #else
25124         py_funcname = PyUnicode_FromString(funcname);
25125         #endif
25126     }
25127     if (!py_funcname) goto bad;
25128     py_code = __Pyx_PyCode_New(
25129         0,
25130         0,
25131         0,
25132         0,
25133         0,
25134         __pyx_empty_bytes, /*PyObject *code,*/
25135         __pyx_empty_tuple, /*PyObject *consts,*/
25136         __pyx_empty_tuple, /*PyObject *names,*/
25137         __pyx_empty_tuple, /*PyObject *varnames,*/
25138         __pyx_empty_tuple, /*PyObject *freevars,*/
25139         __pyx_empty_tuple, /*PyObject *cellvars,*/
25140         py_srcfile,   /*PyObject *filename,*/
25141         py_funcname,  /*PyObject *name,*/
25142         py_line,
25143         __pyx_empty_bytes  /*PyObject *lnotab*/
25144     );
25145     Py_DECREF(py_srcfile);
25146     Py_DECREF(py_funcname);
25147     return py_code;
25148 bad:
25149     Py_XDECREF(py_srcfile);
25150     Py_XDECREF(py_funcname);
25151     return NULL;
25152 }
25153 static void __Pyx_AddTraceback(const char *funcname, int c_line,
25154                                int py_line, const char *filename) {
25155     PyCodeObject *py_code = 0;
25156     PyFrameObject *py_frame = 0;
25157     PyThreadState *tstate = __Pyx_PyThreadState_Current;
25158     if (c_line) {
25159         c_line = __Pyx_CLineForTraceback(tstate, c_line);
25160     }
25161     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
25162     if (!py_code) {
25163         py_code = __Pyx_CreateCodeObjectForTraceback(
25164             funcname, c_line, py_line, filename);
25165         if (!py_code) goto bad;
25166         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
25167     }
25168     py_frame = PyFrame_New(
25169         tstate,            /*PyThreadState *tstate,*/
25170         py_code,           /*PyCodeObject *code,*/
25171         __pyx_d,    /*PyObject *globals,*/
25172         0                  /*PyObject *locals*/
25173     );
25174     if (!py_frame) goto bad;
25175     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
25176     PyTraceBack_Here(py_frame);
25177 bad:
25178     Py_XDECREF(py_code);
25179     Py_XDECREF(py_frame);
25180 }
25181
25182 /* CIntToPy */
25183 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
25184     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
25185     const int is_unsigned = neg_one > const_zero;
25186     if (is_unsigned) {
25187         if (sizeof(long) < sizeof(long)) {
25188             return PyInt_FromLong((long) value);
25189         } else if (sizeof(long) <= sizeof(unsigned long)) {
25190             return PyLong_FromUnsignedLong((unsigned long) value);
25191 #ifdef HAVE_LONG_LONG
25192         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
25193             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
25194 #endif
25195         }
25196     } else {
25197         if (sizeof(long) <= sizeof(long)) {
25198             return PyInt_FromLong((long) value);
25199 #ifdef HAVE_LONG_LONG
25200         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
25201             return PyLong_FromLongLong((PY_LONG_LONG) value);
25202 #endif
25203         }
25204     }
25205     {
25206         int one = 1; int little = (int)*(unsigned char *)&one;
25207         unsigned char *bytes = (unsigned char *)&value;
25208         return _PyLong_FromByteArray(bytes, sizeof(long),
25209                                      little, !is_unsigned);
25210     }
25211 }
25212
25213 /* CIntFromPyVerify */
25214 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
25215     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
25216 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
25217     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
25218 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
25219     {\
25220         func_type value = func_value;\
25221         if (sizeof(target_type) < sizeof(func_type)) {\
25222             if (unlikely(value != (func_type) (target_type) value)) {\
25223                 func_type zero = 0;\
25224                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
25225                     return (target_type) -1;\
25226                 if (is_unsigned && unlikely(value < zero))\
25227                     goto raise_neg_overflow;\
25228                 else\
25229                     goto raise_overflow;\
25230             }\
25231         }\
25232         return (target_type) value;\
25233     }
25234
25235 /* CIntFromPy */
25236 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
25237     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
25238     const int is_unsigned = neg_one > const_zero;
25239 #if PY_MAJOR_VERSION < 3
25240     if (likely(PyInt_Check(x))) {
25241         if (sizeof(long) < sizeof(long)) {
25242             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
25243         } else {
25244             long val = PyInt_AS_LONG(x);
25245             if (is_unsigned && unlikely(val < 0)) {
25246                 goto raise_neg_overflow;
25247             }
25248             return (long) val;
25249         }
25250     } else
25251 #endif
25252     if (likely(PyLong_Check(x))) {
25253         if (is_unsigned) {
25254 #if CYTHON_USE_PYLONG_INTERNALS
25255             const digit* digits = ((PyLongObject*)x)->ob_digit;
25256             switch (Py_SIZE(x)) {
25257                 case  0: return (long) 0;
25258                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
25259                 case 2:
25260                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
25261                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25262                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25263                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
25264                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
25265                         }
25266                     }
25267                     break;
25268                 case 3:
25269                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
25270                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25271                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25272                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
25273                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
25274                         }
25275                     }
25276                     break;
25277                 case 4:
25278                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
25279                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25280                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25281                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
25282                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
25283                         }
25284                     }
25285                     break;
25286             }
25287 #endif
25288 #if CYTHON_COMPILING_IN_CPYTHON
25289             if (unlikely(Py_SIZE(x) < 0)) {
25290                 goto raise_neg_overflow;
25291             }
25292 #else
25293             {
25294                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
25295                 if (unlikely(result < 0))
25296                     return (long) -1;
25297                 if (unlikely(result == 1))
25298                     goto raise_neg_overflow;
25299             }
25300 #endif
25301             if (sizeof(long) <= sizeof(unsigned long)) {
25302                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
25303 #ifdef HAVE_LONG_LONG
25304             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
25305                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
25306 #endif
25307             }
25308         } else {
25309 #if CYTHON_USE_PYLONG_INTERNALS
25310             const digit* digits = ((PyLongObject*)x)->ob_digit;
25311             switch (Py_SIZE(x)) {
25312                 case  0: return (long) 0;
25313                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
25314                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
25315                 case -2:
25316                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
25317                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25318                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25319                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25320                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25321                         }
25322                     }
25323                     break;
25324                 case 2:
25325                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
25326                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25327                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25328                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25329                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25330                         }
25331                     }
25332                     break;
25333                 case -3:
25334                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25335                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25336                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25337                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25338                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25339                         }
25340                     }
25341                     break;
25342                 case 3:
25343                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
25344                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25345                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25346                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25347                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25348                         }
25349                     }
25350                     break;
25351                 case -4:
25352                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25353                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25354                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25355                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25356                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25357                         }
25358                     }
25359                     break;
25360                 case 4:
25361                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
25362                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25363                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25364                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25365                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
25366                         }
25367                     }
25368                     break;
25369             }
25370 #endif
25371             if (sizeof(long) <= sizeof(long)) {
25372                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
25373 #ifdef HAVE_LONG_LONG
25374             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
25375                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
25376 #endif
25377             }
25378         }
25379         {
25380 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
25381             PyErr_SetString(PyExc_RuntimeError,
25382                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
25383 #else
25384             long val;
25385             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
25386  #if PY_MAJOR_VERSION < 3
25387             if (likely(v) && !PyLong_Check(v)) {
25388                 PyObject *tmp = v;
25389                 v = PyNumber_Long(tmp);
25390                 Py_DECREF(tmp);
25391             }
25392  #endif
25393             if (likely(v)) {
25394                 int one = 1; int is_little = (int)*(unsigned char *)&one;
25395                 unsigned char *bytes = (unsigned char *)&val;
25396                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
25397                                               bytes, sizeof(val),
25398                                               is_little, !is_unsigned);
25399                 Py_DECREF(v);
25400                 if (likely(!ret))
25401                     return val;
25402             }
25403 #endif
25404             return (long) -1;
25405         }
25406     } else {
25407         long val;
25408         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
25409         if (!tmp) return (long) -1;
25410         val = __Pyx_PyInt_As_long(tmp);
25411         Py_DECREF(tmp);
25412         return val;
25413     }
25414 raise_overflow:
25415     PyErr_SetString(PyExc_OverflowError,
25416         "value too large to convert to long");
25417     return (long) -1;
25418 raise_neg_overflow:
25419     PyErr_SetString(PyExc_OverflowError,
25420         "can't convert negative value to long");
25421     return (long) -1;
25422 }
25423
25424 /* CIntFromPy */
25425 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
25426     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
25427     const int is_unsigned = neg_one > const_zero;
25428 #if PY_MAJOR_VERSION < 3
25429     if (likely(PyInt_Check(x))) {
25430         if (sizeof(int) < sizeof(long)) {
25431             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
25432         } else {
25433             long val = PyInt_AS_LONG(x);
25434             if (is_unsigned && unlikely(val < 0)) {
25435                 goto raise_neg_overflow;
25436             }
25437             return (int) val;
25438         }
25439     } else
25440 #endif
25441     if (likely(PyLong_Check(x))) {
25442         if (is_unsigned) {
25443 #if CYTHON_USE_PYLONG_INTERNALS
25444             const digit* digits = ((PyLongObject*)x)->ob_digit;
25445             switch (Py_SIZE(x)) {
25446                 case  0: return (int) 0;
25447                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
25448                 case 2:
25449                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
25450                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25451                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25452                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
25453                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
25454                         }
25455                     }
25456                     break;
25457                 case 3:
25458                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
25459                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25460                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25461                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
25462                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
25463                         }
25464                     }
25465                     break;
25466                 case 4:
25467                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
25468                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25469                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25470                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
25471                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
25472                         }
25473                     }
25474                     break;
25475             }
25476 #endif
25477 #if CYTHON_COMPILING_IN_CPYTHON
25478             if (unlikely(Py_SIZE(x) < 0)) {
25479                 goto raise_neg_overflow;
25480             }
25481 #else
25482             {
25483                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
25484                 if (unlikely(result < 0))
25485                     return (int) -1;
25486                 if (unlikely(result == 1))
25487                     goto raise_neg_overflow;
25488             }
25489 #endif
25490             if (sizeof(int) <= sizeof(unsigned long)) {
25491                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
25492 #ifdef HAVE_LONG_LONG
25493             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
25494                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
25495 #endif
25496             }
25497         } else {
25498 #if CYTHON_USE_PYLONG_INTERNALS
25499             const digit* digits = ((PyLongObject*)x)->ob_digit;
25500             switch (Py_SIZE(x)) {
25501                 case  0: return (int) 0;
25502                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
25503                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
25504                 case -2:
25505                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
25506                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25507                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25508                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
25509                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25510                         }
25511                     }
25512                     break;
25513                 case 2:
25514                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
25515                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
25516                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25517                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
25518                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25519                         }
25520                     }
25521                     break;
25522                 case -3:
25523                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
25524                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25525                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25526                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
25527                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25528                         }
25529                     }
25530                     break;
25531                 case 3:
25532                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
25533                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
25534                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25535                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
25536                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25537                         }
25538                     }
25539                     break;
25540                 case -4:
25541                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
25542                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25543                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25544                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
25545                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25546                         }
25547                     }
25548                     break;
25549                 case 4:
25550                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
25551                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
25552                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
25553                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
25554                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
25555                         }
25556                     }
25557                     break;
25558             }
25559 #endif
25560             if (sizeof(int) <= sizeof(long)) {
25561                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
25562 #ifdef HAVE_LONG_LONG
25563             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
25564                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
25565 #endif
25566             }
25567         }
25568         {
25569 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
25570             PyErr_SetString(PyExc_RuntimeError,
25571                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
25572 #else
25573             int val;
25574             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
25575  #if PY_MAJOR_VERSION < 3
25576             if (likely(v) && !PyLong_Check(v)) {
25577                 PyObject *tmp = v;
25578                 v = PyNumber_Long(tmp);
25579                 Py_DECREF(tmp);
25580             }
25581  #endif
25582             if (likely(v)) {
25583                 int one = 1; int is_little = (int)*(unsigned char *)&one;
25584                 unsigned char *bytes = (unsigned char *)&val;
25585                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
25586                                               bytes, sizeof(val),
25587                                               is_little, !is_unsigned);
25588                 Py_DECREF(v);
25589                 if (likely(!ret))
25590                     return val;
25591             }
25592 #endif
25593             return (int) -1;
25594         }
25595     } else {
25596         int val;
25597         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
25598         if (!tmp) return (int) -1;
25599         val = __Pyx_PyInt_As_int(tmp);
25600         Py_DECREF(tmp);
25601         return val;
25602     }
25603 raise_overflow:
25604     PyErr_SetString(PyExc_OverflowError,
25605         "value too large to convert to int");
25606     return (int) -1;
25607 raise_neg_overflow:
25608     PyErr_SetString(PyExc_OverflowError,
25609         "can't convert negative value to int");
25610     return (int) -1;
25611 }
25612
25613 /* SwapException */
25614 #if CYTHON_FAST_THREAD_STATE
25615 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
25616     PyObject *tmp_type, *tmp_value, *tmp_tb;
25617     #if CYTHON_USE_EXC_INFO_STACK
25618     _PyErr_StackItem *exc_info = tstate->exc_info;
25619     tmp_type = exc_info->exc_type;
25620     tmp_value = exc_info->exc_value;
25621     tmp_tb = exc_info->exc_traceback;
25622     exc_info->exc_type = *type;
25623     exc_info->exc_value = *value;
25624     exc_info->exc_traceback = *tb;
25625     #else
25626     tmp_type = tstate->exc_type;
25627     tmp_value = tstate->exc_value;
25628     tmp_tb = tstate->exc_traceback;
25629     tstate->exc_type = *type;
25630     tstate->exc_value = *value;
25631     tstate->exc_traceback = *tb;
25632     #endif
25633     *type = tmp_type;
25634     *value = tmp_value;
25635     *tb = tmp_tb;
25636 }
25637 #else
25638 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
25639     PyObject *tmp_type, *tmp_value, *tmp_tb;
25640     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
25641     PyErr_SetExcInfo(*type, *value, *tb);
25642     *type = tmp_type;
25643     *value = tmp_value;
25644     *tb = tmp_tb;
25645 }
25646 #endif
25647
25648 /* CoroutineBase */
25649 #include <structmember.h>
25650 #include <frameobject.h>
25651 #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
25652 static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
25653     PyObject *et, *ev, *tb;
25654     PyObject *value = NULL;
25655     __Pyx_ErrFetch(&et, &ev, &tb);
25656     if (!et) {
25657         Py_XDECREF(tb);
25658         Py_XDECREF(ev);
25659         Py_INCREF(Py_None);
25660         *pvalue = Py_None;
25661         return 0;
25662     }
25663     if (likely(et == PyExc_StopIteration)) {
25664         if (!ev) {
25665             Py_INCREF(Py_None);
25666             value = Py_None;
25667         }
25668 #if PY_VERSION_HEX >= 0x030300A0
25669         else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
25670             value = ((PyStopIterationObject *)ev)->value;
25671             Py_INCREF(value);
25672             Py_DECREF(ev);
25673         }
25674 #endif
25675         else if (unlikely(PyTuple_Check(ev))) {
25676             if (PyTuple_GET_SIZE(ev) >= 1) {
25677 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
25678                 value = PyTuple_GET_ITEM(ev, 0);
25679                 Py_INCREF(value);
25680 #else
25681                 value = PySequence_ITEM(ev, 0);
25682 #endif
25683             } else {
25684                 Py_INCREF(Py_None);
25685                 value = Py_None;
25686             }
25687             Py_DECREF(ev);
25688         }
25689         else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
25690             value = ev;
25691         }
25692         if (likely(value)) {
25693             Py_XDECREF(tb);
25694             Py_DECREF(et);
25695             *pvalue = value;
25696             return 0;
25697         }
25698     } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
25699         __Pyx_ErrRestore(et, ev, tb);
25700         return -1;
25701     }
25702     PyErr_NormalizeException(&et, &ev, &tb);
25703     if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
25704         __Pyx_ErrRestore(et, ev, tb);
25705         return -1;
25706     }
25707     Py_XDECREF(tb);
25708     Py_DECREF(et);
25709 #if PY_VERSION_HEX >= 0x030300A0
25710     value = ((PyStopIterationObject *)ev)->value;
25711     Py_INCREF(value);
25712     Py_DECREF(ev);
25713 #else
25714     {
25715         PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
25716         Py_DECREF(ev);
25717         if (likely(args)) {
25718             value = PySequence_GetItem(args, 0);
25719             Py_DECREF(args);
25720         }
25721         if (unlikely(!value)) {
25722             __Pyx_ErrRestore(NULL, NULL, NULL);
25723             Py_INCREF(Py_None);
25724             value = Py_None;
25725         }
25726     }
25727 #endif
25728     *pvalue = value;
25729     return 0;
25730 }
25731 static CYTHON_INLINE
25732 void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
25733     PyObject *t, *v, *tb;
25734     t = exc_state->exc_type;
25735     v = exc_state->exc_value;
25736     tb = exc_state->exc_traceback;
25737     exc_state->exc_type = NULL;
25738     exc_state->exc_value = NULL;
25739     exc_state->exc_traceback = NULL;
25740     Py_XDECREF(t);
25741     Py_XDECREF(v);
25742     Py_XDECREF(tb);
25743 }
25744 #define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
25745 static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
25746     const char *msg;
25747     if ((0)) {
25748     #ifdef __Pyx_Coroutine_USED
25749     } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
25750         msg = "coroutine already executing";
25751     #endif
25752     #ifdef __Pyx_AsyncGen_USED
25753     } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
25754         msg = "async generator already executing";
25755     #endif
25756     } else {
25757         msg = "generator already executing";
25758     }
25759     PyErr_SetString(PyExc_ValueError, msg);
25760 }
25761 #define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
25762 static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
25763     const char *msg;
25764     if ((0)) {
25765     #ifdef __Pyx_Coroutine_USED
25766     } else if (__Pyx_Coroutine_Check(gen)) {
25767         msg = "can't send non-None value to a just-started coroutine";
25768     #endif
25769     #ifdef __Pyx_AsyncGen_USED
25770     } else if (__Pyx_AsyncGen_CheckExact(gen)) {
25771         msg = "can't send non-None value to a just-started async generator";
25772     #endif
25773     } else {
25774         msg = "can't send non-None value to a just-started generator";
25775     }
25776     PyErr_SetString(PyExc_TypeError, msg);
25777 }
25778 #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
25779 static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
25780     #ifdef __Pyx_Coroutine_USED
25781     if (!closing && __Pyx_Coroutine_Check(gen)) {
25782         PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
25783     } else
25784     #endif
25785     if (value) {
25786         #ifdef __Pyx_AsyncGen_USED
25787         if (__Pyx_AsyncGen_CheckExact(gen))
25788             PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
25789         else
25790         #endif
25791         PyErr_SetNone(PyExc_StopIteration);
25792     }
25793 }
25794 static
25795 PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
25796     __Pyx_PyThreadState_declare
25797     PyThreadState *tstate;
25798     __Pyx_ExcInfoStruct *exc_state;
25799     PyObject *retval;
25800     assert(!self->is_running);
25801     if (unlikely(self->resume_label == 0)) {
25802         if (unlikely(value && value != Py_None)) {
25803             return __Pyx_Coroutine_NotStartedError((PyObject*)self);
25804         }
25805     }
25806     if (unlikely(self->resume_label == -1)) {
25807         return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
25808     }
25809 #if CYTHON_FAST_THREAD_STATE
25810     __Pyx_PyThreadState_assign
25811     tstate = __pyx_tstate;
25812 #else
25813     tstate = __Pyx_PyThreadState_Current;
25814 #endif
25815     exc_state = &self->gi_exc_state;
25816     if (exc_state->exc_type) {
25817         #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
25818         #else
25819         if (exc_state->exc_traceback) {
25820             PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
25821             PyFrameObject *f = tb->tb_frame;
25822             Py_XINCREF(tstate->frame);
25823             assert(f->f_back == NULL);
25824             f->f_back = tstate->frame;
25825         }
25826         #endif
25827     }
25828 #if CYTHON_USE_EXC_INFO_STACK
25829     exc_state->previous_item = tstate->exc_info;
25830     tstate->exc_info = exc_state;
25831 #else
25832     if (exc_state->exc_type) {
25833         __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
25834     } else {
25835         __Pyx_Coroutine_ExceptionClear(exc_state);
25836         __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
25837     }
25838 #endif
25839     self->is_running = 1;
25840     retval = self->body((PyObject *) self, tstate, value);
25841     self->is_running = 0;
25842 #if CYTHON_USE_EXC_INFO_STACK
25843     exc_state = &self->gi_exc_state;
25844     tstate->exc_info = exc_state->previous_item;
25845     exc_state->previous_item = NULL;
25846     __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
25847 #endif
25848     return retval;
25849 }
25850 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
25851     PyObject *exc_tb = exc_state->exc_traceback;
25852     if (likely(exc_tb)) {
25853 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
25854 #else
25855         PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
25856         PyFrameObject *f = tb->tb_frame;
25857         Py_CLEAR(f->f_back);
25858 #endif
25859     }
25860 }
25861 static CYTHON_INLINE
25862 PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
25863     if (unlikely(!retval)) {
25864         __Pyx_PyThreadState_declare
25865         __Pyx_PyThreadState_assign
25866         if (!__Pyx_PyErr_Occurred()) {
25867             PyObject *exc = PyExc_StopIteration;
25868             #ifdef __Pyx_AsyncGen_USED
25869             if (__Pyx_AsyncGen_CheckExact(gen))
25870                 exc = __Pyx_PyExc_StopAsyncIteration;
25871             #endif
25872             __Pyx_PyErr_SetNone(exc);
25873         }
25874     }
25875     return retval;
25876 }
25877 static CYTHON_INLINE
25878 PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
25879     PyObject *ret;
25880     PyObject *val = NULL;
25881     __Pyx_Coroutine_Undelegate(gen);
25882     __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
25883     ret = __Pyx_Coroutine_SendEx(gen, val, 0);
25884     Py_XDECREF(val);
25885     return ret;
25886 }
25887 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
25888     PyObject *retval;
25889     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
25890     PyObject *yf = gen->yieldfrom;
25891     if (unlikely(gen->is_running))
25892         return __Pyx_Coroutine_AlreadyRunningError(gen);
25893     if (yf) {
25894         PyObject *ret;
25895         gen->is_running = 1;
25896         #ifdef __Pyx_Generator_USED
25897         if (__Pyx_Generator_CheckExact(yf)) {
25898             ret = __Pyx_Coroutine_Send(yf, value);
25899         } else
25900         #endif
25901         #ifdef __Pyx_Coroutine_USED
25902         if (__Pyx_Coroutine_Check(yf)) {
25903             ret = __Pyx_Coroutine_Send(yf, value);
25904         } else
25905         #endif
25906         #ifdef __Pyx_AsyncGen_USED
25907         if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
25908             ret = __Pyx_async_gen_asend_send(yf, value);
25909         } else
25910         #endif
25911         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
25912         if (PyGen_CheckExact(yf)) {
25913             ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
25914         } else
25915         #endif
25916         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
25917         if (PyCoro_CheckExact(yf)) {
25918             ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
25919         } else
25920         #endif
25921         {
25922             if (value == Py_None)
25923                 ret = Py_TYPE(yf)->tp_iternext(yf);
25924             else
25925                 ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
25926         }
25927         gen->is_running = 0;
25928         if (likely(ret)) {
25929             return ret;
25930         }
25931         retval = __Pyx_Coroutine_FinishDelegation(gen);
25932     } else {
25933         retval = __Pyx_Coroutine_SendEx(gen, value, 0);
25934     }
25935     return __Pyx_Coroutine_MethodReturn(self, retval);
25936 }
25937 static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
25938     PyObject *retval = NULL;
25939     int err = 0;
25940     #ifdef __Pyx_Generator_USED
25941     if (__Pyx_Generator_CheckExact(yf)) {
25942         retval = __Pyx_Coroutine_Close(yf);
25943         if (!retval)
25944             return -1;
25945     } else
25946     #endif
25947     #ifdef __Pyx_Coroutine_USED
25948     if (__Pyx_Coroutine_Check(yf)) {
25949         retval = __Pyx_Coroutine_Close(yf);
25950         if (!retval)
25951             return -1;
25952     } else
25953     if (__Pyx_CoroutineAwait_CheckExact(yf)) {
25954         retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
25955         if (!retval)
25956             return -1;
25957     } else
25958     #endif
25959     #ifdef __Pyx_AsyncGen_USED
25960     if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
25961         retval = __Pyx_async_gen_asend_close(yf, NULL);
25962     } else
25963     if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
25964         retval = __Pyx_async_gen_athrow_close(yf, NULL);
25965     } else
25966     #endif
25967     {
25968         PyObject *meth;
25969         gen->is_running = 1;
25970         meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
25971         if (unlikely(!meth)) {
25972             if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
25973                 PyErr_WriteUnraisable(yf);
25974             }
25975             PyErr_Clear();
25976         } else {
25977             retval = PyObject_CallFunction(meth, NULL);
25978             Py_DECREF(meth);
25979             if (!retval)
25980                 err = -1;
25981         }
25982         gen->is_running = 0;
25983     }
25984     Py_XDECREF(retval);
25985     return err;
25986 }
25987 static PyObject *__Pyx_Generator_Next(PyObject *self) {
25988     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
25989     PyObject *yf = gen->yieldfrom;
25990     if (unlikely(gen->is_running))
25991         return __Pyx_Coroutine_AlreadyRunningError(gen);
25992     if (yf) {
25993         PyObject *ret;
25994         gen->is_running = 1;
25995         #ifdef __Pyx_Generator_USED
25996         if (__Pyx_Generator_CheckExact(yf)) {
25997             ret = __Pyx_Generator_Next(yf);
25998         } else
25999         #endif
26000         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
26001         if (PyGen_CheckExact(yf)) {
26002             ret = _PyGen_Send((PyGenObject*)yf, NULL);
26003         } else
26004         #endif
26005         #ifdef __Pyx_Coroutine_USED
26006         if (__Pyx_Coroutine_Check(yf)) {
26007             ret = __Pyx_Coroutine_Send(yf, Py_None);
26008         } else
26009         #endif
26010             ret = Py_TYPE(yf)->tp_iternext(yf);
26011         gen->is_running = 0;
26012         if (likely(ret)) {
26013             return ret;
26014         }
26015         return __Pyx_Coroutine_FinishDelegation(gen);
26016     }
26017     return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
26018 }
26019 static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
26020     return __Pyx_Coroutine_Close(self);
26021 }
26022 static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
26023     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
26024     PyObject *retval, *raised_exception;
26025     PyObject *yf = gen->yieldfrom;
26026     int err = 0;
26027     if (unlikely(gen->is_running))
26028         return __Pyx_Coroutine_AlreadyRunningError(gen);
26029     if (yf) {
26030         Py_INCREF(yf);
26031         err = __Pyx_Coroutine_CloseIter(gen, yf);
26032         __Pyx_Coroutine_Undelegate(gen);
26033         Py_DECREF(yf);
26034     }
26035     if (err == 0)
26036         PyErr_SetNone(PyExc_GeneratorExit);
26037     retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
26038     if (unlikely(retval)) {
26039         const char *msg;
26040         Py_DECREF(retval);
26041         if ((0)) {
26042         #ifdef __Pyx_Coroutine_USED
26043         } else if (__Pyx_Coroutine_Check(self)) {
26044             msg = "coroutine ignored GeneratorExit";
26045         #endif
26046         #ifdef __Pyx_AsyncGen_USED
26047         } else if (__Pyx_AsyncGen_CheckExact(self)) {
26048 #if PY_VERSION_HEX < 0x03060000
26049             msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
26050 #else
26051             msg = "async generator ignored GeneratorExit";
26052 #endif
26053         #endif
26054         } else {
26055             msg = "generator ignored GeneratorExit";
26056         }
26057         PyErr_SetString(PyExc_RuntimeError, msg);
26058         return NULL;
26059     }
26060     raised_exception = PyErr_Occurred();
26061     if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
26062         if (raised_exception) PyErr_Clear();
26063         Py_INCREF(Py_None);
26064         return Py_None;
26065     }
26066     return NULL;
26067 }
26068 static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
26069                                         PyObject *args, int close_on_genexit) {
26070     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
26071     PyObject *yf = gen->yieldfrom;
26072     if (unlikely(gen->is_running))
26073         return __Pyx_Coroutine_AlreadyRunningError(gen);
26074     if (yf) {
26075         PyObject *ret;
26076         Py_INCREF(yf);
26077         if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
26078             int err = __Pyx_Coroutine_CloseIter(gen, yf);
26079             Py_DECREF(yf);
26080             __Pyx_Coroutine_Undelegate(gen);
26081             if (err < 0)
26082                 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
26083             goto throw_here;
26084         }
26085         gen->is_running = 1;
26086         if (0
26087         #ifdef __Pyx_Generator_USED
26088             || __Pyx_Generator_CheckExact(yf)
26089         #endif
26090         #ifdef __Pyx_Coroutine_USED
26091             || __Pyx_Coroutine_Check(yf)
26092         #endif
26093             ) {
26094             ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
26095         #ifdef __Pyx_Coroutine_USED
26096         } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
26097             ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
26098         #endif
26099         } else {
26100             PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
26101             if (unlikely(!meth)) {
26102                 Py_DECREF(yf);
26103                 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
26104                     gen->is_running = 0;
26105                     return NULL;
26106                 }
26107                 PyErr_Clear();
26108                 __Pyx_Coroutine_Undelegate(gen);
26109                 gen->is_running = 0;
26110                 goto throw_here;
26111             }
26112             if (likely(args)) {
26113                 ret = PyObject_CallObject(meth, args);
26114             } else {
26115                 ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
26116             }
26117             Py_DECREF(meth);
26118         }
26119         gen->is_running = 0;
26120         Py_DECREF(yf);
26121         if (!ret) {
26122             ret = __Pyx_Coroutine_FinishDelegation(gen);
26123         }
26124         return __Pyx_Coroutine_MethodReturn(self, ret);
26125     }
26126 throw_here:
26127     __Pyx_Raise(typ, val, tb, NULL);
26128     return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
26129 }
26130 static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
26131     PyObject *typ;
26132     PyObject *val = NULL;
26133     PyObject *tb = NULL;
26134     if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
26135         return NULL;
26136     return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
26137 }
26138 static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
26139     Py_VISIT(exc_state->exc_type);
26140     Py_VISIT(exc_state->exc_value);
26141     Py_VISIT(exc_state->exc_traceback);
26142     return 0;
26143 }
26144 static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
26145     Py_VISIT(gen->closure);
26146     Py_VISIT(gen->classobj);
26147     Py_VISIT(gen->yieldfrom);
26148     return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
26149 }
26150 static int __Pyx_Coroutine_clear(PyObject *self) {
26151     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
26152     Py_CLEAR(gen->closure);
26153     Py_CLEAR(gen->classobj);
26154     Py_CLEAR(gen->yieldfrom);
26155     __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
26156 #ifdef __Pyx_AsyncGen_USED
26157     if (__Pyx_AsyncGen_CheckExact(self)) {
26158         Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
26159     }
26160 #endif
26161     Py_CLEAR(gen->gi_code);
26162     Py_CLEAR(gen->gi_name);
26163     Py_CLEAR(gen->gi_qualname);
26164     Py_CLEAR(gen->gi_modulename);
26165     return 0;
26166 }
26167 static void __Pyx_Coroutine_dealloc(PyObject *self) {
26168     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
26169     PyObject_GC_UnTrack(gen);
26170     if (gen->gi_weakreflist != NULL)
26171         PyObject_ClearWeakRefs(self);
26172     if (gen->resume_label >= 0) {
26173         PyObject_GC_Track(self);
26174 #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
26175         if (PyObject_CallFinalizerFromDealloc(self))
26176 #else
26177         Py_TYPE(gen)->tp_del(self);
26178         if (self->ob_refcnt > 0)
26179 #endif
26180         {
26181             return;
26182         }
26183         PyObject_GC_UnTrack(self);
26184     }
26185 #ifdef __Pyx_AsyncGen_USED
26186     if (__Pyx_AsyncGen_CheckExact(self)) {
26187         /* We have to handle this case for asynchronous generators
26188            right here, because this code has to be between UNTRACK
26189            and GC_Del. */
26190         Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
26191     }
26192 #endif
26193     __Pyx_Coroutine_clear(self);
26194     PyObject_GC_Del(gen);
26195 }
26196 static void __Pyx_Coroutine_del(PyObject *self) {
26197     PyObject *error_type, *error_value, *error_traceback;
26198     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
26199     __Pyx_PyThreadState_declare
26200     if (gen->resume_label < 0) {
26201         return;
26202     }
26203 #if !CYTHON_USE_TP_FINALIZE
26204     assert(self->ob_refcnt == 0);
26205     self->ob_refcnt = 1;
26206 #endif
26207     __Pyx_PyThreadState_assign
26208     __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
26209 #ifdef __Pyx_AsyncGen_USED
26210     if (__Pyx_AsyncGen_CheckExact(self)) {
26211         __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
26212         PyObject *finalizer = agen->ag_finalizer;
26213         if (finalizer && !agen->ag_closed) {
26214             PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
26215             if (unlikely(!res)) {
26216                 PyErr_WriteUnraisable(self);
26217             } else {
26218                 Py_DECREF(res);
26219             }
26220             __Pyx_ErrRestore(error_type, error_value, error_traceback);
26221             return;
26222         }
26223     }
26224 #endif
26225     if (unlikely(gen->resume_label == 0 && !error_value)) {
26226 #ifdef __Pyx_Coroutine_USED
26227 #ifdef __Pyx_Generator_USED
26228     if (!__Pyx_Generator_CheckExact(self))
26229 #endif
26230         {
26231         PyObject_GC_UnTrack(self);
26232 #if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
26233         if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
26234             PyErr_WriteUnraisable(self);
26235 #else
26236         {PyObject *msg;
26237         char *cmsg;
26238         #if CYTHON_COMPILING_IN_PYPY
26239         msg = NULL;
26240         cmsg = (char*) "coroutine was never awaited";
26241         #else
26242         char *cname;
26243         PyObject *qualname;
26244         qualname = gen->gi_qualname;
26245         cname = PyString_AS_STRING(qualname);
26246         msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
26247         if (unlikely(!msg)) {
26248             PyErr_Clear();
26249             cmsg = (char*) "coroutine was never awaited";
26250         } else {
26251             cmsg = PyString_AS_STRING(msg);
26252         }
26253         #endif
26254         if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
26255             PyErr_WriteUnraisable(self);
26256         Py_XDECREF(msg);}
26257 #endif
26258         PyObject_GC_Track(self);
26259         }
26260 #endif
26261     } else {
26262         PyObject *res = __Pyx_Coroutine_Close(self);
26263         if (unlikely(!res)) {
26264             if (PyErr_Occurred())
26265                 PyErr_WriteUnraisable(self);
26266         } else {
26267             Py_DECREF(res);
26268         }
26269     }
26270     __Pyx_ErrRestore(error_type, error_value, error_traceback);
26271 #if !CYTHON_USE_TP_FINALIZE
26272     assert(self->ob_refcnt > 0);
26273     if (--self->ob_refcnt == 0) {
26274         return;
26275     }
26276     {
26277         Py_ssize_t refcnt = self->ob_refcnt;
26278         _Py_NewReference(self);
26279         self->ob_refcnt = refcnt;
26280     }
26281 #if CYTHON_COMPILING_IN_CPYTHON
26282     assert(PyType_IS_GC(self->ob_type) &&
26283            _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
26284     _Py_DEC_REFTOTAL;
26285 #endif
26286 #ifdef COUNT_ALLOCS
26287     --Py_TYPE(self)->tp_frees;
26288     --Py_TYPE(self)->tp_allocs;
26289 #endif
26290 #endif
26291 }
26292 static PyObject *
26293 __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
26294 {
26295     PyObject *name = self->gi_name;
26296     if (unlikely(!name)) name = Py_None;
26297     Py_INCREF(name);
26298     return name;
26299 }
26300 static int
26301 __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
26302 {
26303     PyObject *tmp;
26304 #if PY_MAJOR_VERSION >= 3
26305     if (unlikely(value == NULL || !PyUnicode_Check(value)))
26306 #else
26307     if (unlikely(value == NULL || !PyString_Check(value)))
26308 #endif
26309     {
26310         PyErr_SetString(PyExc_TypeError,
26311                         "__name__ must be set to a string object");
26312         return -1;
26313     }
26314     tmp = self->gi_name;
26315     Py_INCREF(value);
26316     self->gi_name = value;
26317     Py_XDECREF(tmp);
26318     return 0;
26319 }
26320 static PyObject *
26321 __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
26322 {
26323     PyObject *name = self->gi_qualname;
26324     if (unlikely(!name)) name = Py_None;
26325     Py_INCREF(name);
26326     return name;
26327 }
26328 static int
26329 __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
26330 {
26331     PyObject *tmp;
26332 #if PY_MAJOR_VERSION >= 3
26333     if (unlikely(value == NULL || !PyUnicode_Check(value)))
26334 #else
26335     if (unlikely(value == NULL || !PyString_Check(value)))
26336 #endif
26337     {
26338         PyErr_SetString(PyExc_TypeError,
26339                         "__qualname__ must be set to a string object");
26340         return -1;
26341     }
26342     tmp = self->gi_qualname;
26343     Py_INCREF(value);
26344     self->gi_qualname = value;
26345     Py_XDECREF(tmp);
26346     return 0;
26347 }
26348 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
26349             PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
26350             PyObject *name, PyObject *qualname, PyObject *module_name) {
26351     __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
26352     if (unlikely(!gen))
26353         return NULL;
26354     return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
26355 }
26356 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
26357             __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
26358             PyObject *name, PyObject *qualname, PyObject *module_name) {
26359     gen->body = body;
26360     gen->closure = closure;
26361     Py_XINCREF(closure);
26362     gen->is_running = 0;
26363     gen->resume_label = 0;
26364     gen->classobj = NULL;
26365     gen->yieldfrom = NULL;
26366     gen->gi_exc_state.exc_type = NULL;
26367     gen->gi_exc_state.exc_value = NULL;
26368     gen->gi_exc_state.exc_traceback = NULL;
26369 #if CYTHON_USE_EXC_INFO_STACK
26370     gen->gi_exc_state.previous_item = NULL;
26371 #endif
26372     gen->gi_weakreflist = NULL;
26373     Py_XINCREF(qualname);
26374     gen->gi_qualname = qualname;
26375     Py_XINCREF(name);
26376     gen->gi_name = name;
26377     Py_XINCREF(module_name);
26378     gen->gi_modulename = module_name;
26379     Py_XINCREF(code);
26380     gen->gi_code = code;
26381     PyObject_GC_Track(gen);
26382     return gen;
26383 }
26384
26385 /* PatchModuleWithCoroutine */
26386 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
26387 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
26388     int result;
26389     PyObject *globals, *result_obj;
26390     globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
26391     result = PyDict_SetItemString(globals, "_cython_coroutine_type",
26392     #ifdef __Pyx_Coroutine_USED
26393         (PyObject*)__pyx_CoroutineType);
26394     #else
26395         Py_None);
26396     #endif
26397     if (unlikely(result < 0)) goto ignore;
26398     result = PyDict_SetItemString(globals, "_cython_generator_type",
26399     #ifdef __Pyx_Generator_USED
26400         (PyObject*)__pyx_GeneratorType);
26401     #else
26402         Py_None);
26403     #endif
26404     if (unlikely(result < 0)) goto ignore;
26405     if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
26406     if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
26407     result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
26408     if (unlikely(!result_obj)) goto ignore;
26409     Py_DECREF(result_obj);
26410     Py_DECREF(globals);
26411     return module;
26412 ignore:
26413     Py_XDECREF(globals);
26414     PyErr_WriteUnraisable(module);
26415     if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
26416         Py_DECREF(module);
26417         module = NULL;
26418     }
26419 #else
26420     py_code++;
26421 #endif
26422     return module;
26423 }
26424
26425 /* PatchGeneratorABC */
26426 #ifndef CYTHON_REGISTER_ABCS
26427 #define CYTHON_REGISTER_ABCS 1
26428 #endif
26429 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
26430 static PyObject* __Pyx_patch_abc_module(PyObject *module);
26431 static PyObject* __Pyx_patch_abc_module(PyObject *module) {
26432     module = __Pyx_Coroutine_patch_module(
26433         module, ""
26434 "if _cython_generator_type is not None:\n"
26435 "    try: Generator = _module.Generator\n"
26436 "    except AttributeError: pass\n"
26437 "    else: Generator.register(_cython_generator_type)\n"
26438 "if _cython_coroutine_type is not None:\n"
26439 "    try: Coroutine = _module.Coroutine\n"
26440 "    except AttributeError: pass\n"
26441 "    else: Coroutine.register(_cython_coroutine_type)\n"
26442     );
26443     return module;
26444 }
26445 #endif
26446 static int __Pyx_patch_abc(void) {
26447 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
26448     static int abc_patched = 0;
26449     if (CYTHON_REGISTER_ABCS && !abc_patched) {
26450         PyObject *module;
26451         module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
26452         if (!module) {
26453             PyErr_WriteUnraisable(NULL);
26454             if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
26455                     ((PY_MAJOR_VERSION >= 3) ?
26456                         "Cython module failed to register with collections.abc module" :
26457                         "Cython module failed to register with collections module"), 1) < 0)) {
26458                 return -1;
26459             }
26460         } else {
26461             module = __Pyx_patch_abc_module(module);
26462             abc_patched = 1;
26463             if (unlikely(!module))
26464                 return -1;
26465             Py_DECREF(module);
26466         }
26467         module = PyImport_ImportModule("backports_abc");
26468         if (module) {
26469             module = __Pyx_patch_abc_module(module);
26470             Py_XDECREF(module);
26471         }
26472         if (!module) {
26473             PyErr_Clear();
26474         }
26475     }
26476 #else
26477     if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
26478 #endif
26479     return 0;
26480 }
26481
26482 /* Generator */
26483 static PyMethodDef __pyx_Generator_methods[] = {
26484     {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
26485      (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
26486     {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
26487      (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
26488     {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
26489      (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
26490     {0, 0, 0, 0}
26491 };
26492 static PyMemberDef __pyx_Generator_memberlist[] = {
26493     {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
26494     {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
26495      (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
26496     {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
26497     {0, 0, 0, 0, 0}
26498 };
26499 static PyGetSetDef __pyx_Generator_getsets[] = {
26500     {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
26501      (char*) PyDoc_STR("name of the generator"), 0},
26502     {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
26503      (char*) PyDoc_STR("qualified name of the generator"), 0},
26504     {0, 0, 0, 0, 0}
26505 };
26506 static PyTypeObject __pyx_GeneratorType_type = {
26507     PyVarObject_HEAD_INIT(0, 0)
26508     "generator",
26509     sizeof(__pyx_CoroutineObject),
26510     0,
26511     (destructor) __Pyx_Coroutine_dealloc,
26512     0,
26513     0,
26514     0,
26515     0,
26516     0,
26517     0,
26518     0,
26519     0,
26520     0,
26521     0,
26522     0,
26523     0,
26524     0,
26525     0,
26526     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
26527     0,
26528     (traverseproc) __Pyx_Coroutine_traverse,
26529     0,
26530     0,
26531     offsetof(__pyx_CoroutineObject, gi_weakreflist),
26532     0,
26533     (iternextfunc) __Pyx_Generator_Next,
26534     __pyx_Generator_methods,
26535     __pyx_Generator_memberlist,
26536     __pyx_Generator_getsets,
26537     0,
26538     0,
26539     0,
26540     0,
26541     0,
26542     0,
26543     0,
26544     0,
26545     0,
26546     0,
26547     0,
26548     0,
26549     0,
26550     0,
26551     0,
26552 #if CYTHON_USE_TP_FINALIZE
26553     0,
26554 #else
26555     __Pyx_Coroutine_del,
26556 #endif
26557     0,
26558 #if CYTHON_USE_TP_FINALIZE
26559     __Pyx_Coroutine_del,
26560 #elif PY_VERSION_HEX >= 0x030400a1
26561     0,
26562 #endif
26563 #if PY_VERSION_HEX >= 0x030800b1
26564     0,
26565 #endif
26566 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
26567     0,
26568 #endif
26569 };
26570 static int __pyx_Generator_init(void) {
26571     __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
26572     __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
26573     __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
26574     if (unlikely(!__pyx_GeneratorType)) {
26575         return -1;
26576     }
26577     return 0;
26578 }
26579
26580 /* CheckBinaryVersion */
26581 static int __Pyx_check_binary_version(void) {
26582     char ctversion[4], rtversion[4];
26583     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
26584     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
26585     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
26586         char message[200];
26587         PyOS_snprintf(message, sizeof(message),
26588                       "compiletime version %s of module '%.100s' "
26589                       "does not match runtime version %s",
26590                       ctversion, __Pyx_MODULE_NAME, rtversion);
26591         return PyErr_WarnEx(NULL, message, 1);
26592     }
26593     return 0;
26594 }
26595
26596 /* InitStrings */
26597 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
26598     while (t->p) {
26599         #if PY_MAJOR_VERSION < 3
26600         if (t->is_unicode) {
26601             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
26602         } else if (t->intern) {
26603             *t->p = PyString_InternFromString(t->s);
26604         } else {
26605             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
26606         }
26607         #else
26608         if (t->is_unicode | t->is_str) {
26609             if (t->intern) {
26610                 *t->p = PyUnicode_InternFromString(t->s);
26611             } else if (t->encoding) {
26612                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
26613             } else {
26614                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
26615             }
26616         } else {
26617             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
26618         }
26619         #endif
26620         if (!*t->p)
26621             return -1;
26622         if (PyObject_Hash(*t->p) == -1)
26623             return -1;
26624         ++t;
26625     }
26626     return 0;
26627 }
26628
26629 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
26630     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
26631 }
26632 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
26633     Py_ssize_t ignore;
26634     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
26635 }
26636 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
26637 #if !CYTHON_PEP393_ENABLED
26638 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
26639     char* defenc_c;
26640     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
26641     if (!defenc) return NULL;
26642     defenc_c = PyBytes_AS_STRING(defenc);
26643 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
26644     {
26645         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
26646         char* c;
26647         for (c = defenc_c; c < end; c++) {
26648             if ((unsigned char) (*c) >= 128) {
26649                 PyUnicode_AsASCIIString(o);
26650                 return NULL;
26651             }
26652         }
26653     }
26654 #endif
26655     *length = PyBytes_GET_SIZE(defenc);
26656     return defenc_c;
26657 }
26658 #else
26659 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
26660     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
26661 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
26662     if (likely(PyUnicode_IS_ASCII(o))) {
26663         *length = PyUnicode_GET_LENGTH(o);
26664         return PyUnicode_AsUTF8(o);
26665     } else {
26666         PyUnicode_AsASCIIString(o);
26667         return NULL;
26668     }
26669 #else
26670     return PyUnicode_AsUTF8AndSize(o, length);
26671 #endif
26672 }
26673 #endif
26674 #endif
26675 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
26676 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
26677     if (
26678 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
26679             __Pyx_sys_getdefaultencoding_not_ascii &&
26680 #endif
26681             PyUnicode_Check(o)) {
26682         return __Pyx_PyUnicode_AsStringAndSize(o, length);
26683     } else
26684 #endif
26685 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
26686     if (PyByteArray_Check(o)) {
26687         *length = PyByteArray_GET_SIZE(o);
26688         return PyByteArray_AS_STRING(o);
26689     } else
26690 #endif
26691     {
26692         char* result;
26693         int r = PyBytes_AsStringAndSize(o, &result, length);
26694         if (unlikely(r < 0)) {
26695             return NULL;
26696         } else {
26697             return result;
26698         }
26699     }
26700 }
26701 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
26702    int is_true = x == Py_True;
26703    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
26704    else return PyObject_IsTrue(x);
26705 }
26706 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
26707     int retval;
26708     if (unlikely(!x)) return -1;
26709     retval = __Pyx_PyObject_IsTrue(x);
26710     Py_DECREF(x);
26711     return retval;
26712 }
26713 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
26714 #if PY_MAJOR_VERSION >= 3
26715     if (PyLong_Check(result)) {
26716         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
26717                 "__int__ returned non-int (type %.200s).  "
26718                 "The ability to return an instance of a strict subclass of int "
26719                 "is deprecated, and may be removed in a future version of Python.",
26720                 Py_TYPE(result)->tp_name)) {
26721             Py_DECREF(result);
26722             return NULL;
26723         }
26724         return result;
26725     }
26726 #endif
26727     PyErr_Format(PyExc_TypeError,
26728                  "__%.4s__ returned non-%.4s (type %.200s)",
26729                  type_name, type_name, Py_TYPE(result)->tp_name);
26730     Py_DECREF(result);
26731     return NULL;
26732 }
26733 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
26734 #if CYTHON_USE_TYPE_SLOTS
26735   PyNumberMethods *m;
26736 #endif
26737   const char *name = NULL;
26738   PyObject *res = NULL;
26739 #if PY_MAJOR_VERSION < 3
26740   if (likely(PyInt_Check(x) || PyLong_Check(x)))
26741 #else
26742   if (likely(PyLong_Check(x)))
26743 #endif
26744     return __Pyx_NewRef(x);
26745 #if CYTHON_USE_TYPE_SLOTS
26746   m = Py_TYPE(x)->tp_as_number;
26747   #if PY_MAJOR_VERSION < 3
26748   if (m && m->nb_int) {
26749     name = "int";
26750     res = m->nb_int(x);
26751   }
26752   else if (m && m->nb_long) {
26753     name = "long";
26754     res = m->nb_long(x);
26755   }
26756   #else
26757   if (likely(m && m->nb_int)) {
26758     name = "int";
26759     res = m->nb_int(x);
26760   }
26761   #endif
26762 #else
26763   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
26764     res = PyNumber_Int(x);
26765   }
26766 #endif
26767   if (likely(res)) {
26768 #if PY_MAJOR_VERSION < 3
26769     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
26770 #else
26771     if (unlikely(!PyLong_CheckExact(res))) {
26772 #endif
26773         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
26774     }
26775   }
26776   else if (!PyErr_Occurred()) {
26777     PyErr_SetString(PyExc_TypeError,
26778                     "an integer is required");
26779   }
26780   return res;
26781 }
26782 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
26783   Py_ssize_t ival;
26784   PyObject *x;
26785 #if PY_MAJOR_VERSION < 3
26786   if (likely(PyInt_CheckExact(b))) {
26787     if (sizeof(Py_ssize_t) >= sizeof(long))
26788         return PyInt_AS_LONG(b);
26789     else
26790         return PyInt_AsSsize_t(b);
26791   }
26792 #endif
26793   if (likely(PyLong_CheckExact(b))) {
26794     #if CYTHON_USE_PYLONG_INTERNALS
26795     const digit* digits = ((PyLongObject*)b)->ob_digit;
26796     const Py_ssize_t size = Py_SIZE(b);
26797     if (likely(__Pyx_sst_abs(size) <= 1)) {
26798         ival = likely(size) ? digits[0] : 0;
26799         if (size == -1) ival = -ival;
26800         return ival;
26801     } else {
26802       switch (size) {
26803          case 2:
26804            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
26805              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26806            }
26807            break;
26808          case -2:
26809            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
26810              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26811            }
26812            break;
26813          case 3:
26814            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
26815              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26816            }
26817            break;
26818          case -3:
26819            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
26820              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26821            }
26822            break;
26823          case 4:
26824            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
26825              return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26826            }
26827            break;
26828          case -4:
26829            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
26830              return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26831            }
26832            break;
26833       }
26834     }
26835     #endif
26836     return PyLong_AsSsize_t(b);
26837   }
26838   x = PyNumber_Index(b);
26839   if (!x) return -1;
26840   ival = PyInt_AsSsize_t(x);
26841   Py_DECREF(x);
26842   return ival;
26843 }
26844 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
26845   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
26846 }
26847 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
26848     return PyInt_FromSize_t(ival);
26849 }
26850
26851
26852 #endif /* Py_PYTHON_H */