Skip to content

Commit

Permalink
[svn r321] Fix behavior when None is passed to tostring().
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
faassen committed Jun 16, 2005
1 parent 7eab217 commit e442cea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,15 @@
lxml changelog
==============

under development
=================

Bugs fixed
----------

* Passing 'None' to tostring() does not result in a segfault anymore,
but an AssertionError.

0.7 (2005-06-15)
================

Expand Down
2 changes: 2 additions & 0 deletions CREDITS.txt
Expand Up @@ -19,6 +19,8 @@ Florian Wagner - bug reporting

Emil Kroymann - bug reporting, help with encoding support

dharana - bug reporting

Victor Ng - Discussions on memory management strategies, vlibxml2

Thanks also to:
Expand Down
2 changes: 2 additions & 0 deletions src/lxml/etree.pyx
Expand Up @@ -950,6 +950,8 @@ def tostring(_NodeBase element, encoding='us-ascii'):
cdef tree.xmlOutputBuffer* c_buffer
cdef tree.xmlCharEncodingHandler* enchandler
cdef char* enc

assert element is not None

#if encoding is None:
# encoding = 'UTF-8'
Expand Down
4 changes: 4 additions & 0 deletions src/lxml/tests/test_etree.py
Expand Up @@ -1303,6 +1303,10 @@ def test_tostring_element(self):
self.assertEquals('<c><d></d></c>',
canonicalize(tostring(c)))

def test_tostring_none(self):
tostring = self.etree.tostring
self.assertRaises(AssertionError, self.etree.tostring, None)

def test_tostring_element_tail(self):
tostring = self.etree.tostring
Element = self.etree.Element
Expand Down

0 comments on commit e442cea

Please sign in to comment.