>>> from lxml import etree
>>>
>>> article = 'я' * 1000 * 1500
>>>
>>> root = etree.Element('root')
>>> elem = etree.SubElement(root, 'a', attrib={'article': article})
>>>
>>> etree.ElementTree(root).write('file.xml', encoding='cp1251', xml_declaration=True)
>>>
[guest@localhost xmllong]$ head -c100 file.xml
<?xml version='1.0' encoding='CP1251'?>
<root><a article="������������������������������������������[guest@localhost xmllong]$
[guest@localhost xmllong]$
[guest@localhost xmllong]$ head -c100 file.xml | .hex
00000000 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 27 31 |<?xml version='1|
00000010 2e 30 27 20 65 6e 63 6f 64 69 6e 67 3d 27 43 50 |.0' encoding='CP|
00000020 31 32 35 31 27 3f 3e 0a 3c 72 6f 6f 74 3e 3c 61 |1251'?>.<root><a|
00000030 20 61 72 74 69 63 6c 65 3d 22 ff ff ff ff ff ff | article="......|
00000040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000060 ff ff ff ff |....|
00000064
[guest@localhost xmllong]$
[guest@localhost xmllong]$ wc file.xml
1 5 196637 file.xml
[guest@localhost xmllong]$
Действительно, в lxml обрезает.
Если же заменить на станадартный модуль xml, то всё нормально.
>>> import xml.etree.ElementTree as etree
>>>
>>> article = 'я' * 1000 * 1500
>>>
>>> root = etree.Element('root')
>>> elem = etree.SubElement(root, 'a', attrib={'article': article})
>>>
>>> etree.ElementTree(root).write('file.xml', encoding='cp1251', xml_declaration=True)
>>>
[guest@localhost xmllong]$ head -c100 file.xml
<?xml version='1.0' encoding='cp1251'?>
<root><a article="������������������������������������������[guest@localhost xmllong]$
[guest@localhost xmllong]$
[guest@localhost xmllong]$ head -c100 file.xml | .hex
00000000 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 27 31 |<?xml version='1|
00000010 2e 30 27 20 65 6e 63 6f 64 69 6e 67 3d 27 63 70 |.0' encoding='cp|
00000020 31 32 35 31 27 3f 3e 0a 3c 72 6f 6f 74 3e 3c 61 |1251'?>.<root><a|
00000030 20 61 72 74 69 63 6c 65 3d 22 ff ff ff ff ff ff | article="......|
00000040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000060 ff ff ff ff |....|
00000064
[guest@localhost xmllong]$
[guest@localhost xmllong]$ wc file.xml
1 6 1500069 file.xml
[guest@localhost xmllong]$
Наверное, это баг в lxml, даже наверняка.