Bug fix for 1185332

As explained in the issue: https://bugs.launchpad.net/lxml/+bug/1185332, with a test.