Skip to content

Commit

Permalink
do not use xmlMemDisplayLast() when compiling in libxml2 2.6.x as it …
Browse files Browse the repository at this point in the history
…was added in 2.7.0
  • Loading branch information
scoder committed Oct 11, 2012
1 parent 7b8fde4 commit 8afe960
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lxml/debug.pxi
Expand Up @@ -42,7 +42,10 @@ cdef class _MemDebug:
to the file ".memorylist" in the current directory.
The optional parameter 'byte_count' limits the number of bytes in the dump.
Note that this parameter is ignored when lxml is compiled against a libxml2
version before 2.7.0.
"""
cdef Py_ssize_t c_count
if output_file is None:
output_file = b'.memorylist'
elif isinstance(output_file, unicode):
Expand All @@ -52,10 +55,13 @@ cdef class _MemDebug:
if f is NULL:
raise IOError("Failed to create file %s" % output_file.decode(sys.getfilesystemencoding()))
try:
if byte_count is None:
if tree.LIBXML_VERSION < 20700:
tree.xmlMemDisplay(f)
elif byte_count is None:
tree.xmlMemDisplay(f)
else:
tree.xmlMemDisplayLast(f, byte_count)
c_count = byte_count
tree.xmlMemDisplayLast(f, c_count)
finally:
stdio.fclose(f)

Expand Down
1 change: 1 addition & 0 deletions src/lxml/includes/etree_defs.h
Expand Up @@ -97,6 +97,7 @@
# define XML_PARSE_OLD10 1 << 17
# define XML_PARSE_NOBASEFIX 1 << 18
# define XML_PARSE_HUGE 1 << 19
# define xmlMemDisplayLast(f,d)
#endif

#if LIBXML_VERSION < 20704
Expand Down

0 comments on commit 8afe960

Please sign in to comment.