msg189321 - (view) |
Author: Jakub Wilk (jwilk) |
Date: 2013-05-15 22:46 |
Setting attributes on ElementTree.Element objects is broken: it succeeds without exception, but then the following statement fails with AttributeError (unless that statement sets an Element's attribute too): $ python3.3 test-element-setattr.py Hello world!Traceback (most recent call last): File "test-element-setattr.py", line 6, in print('Hello world!') AttributeError: ham2 |
|
|
msg189463 - (view) |
Author: Joe Stuart (jjstuart) |
Date: 2013-05-17 15:55 |
It looks like it's being called from the c extension. I would think it should still throw an exception though? >>> e = etree.Element >>> e.ham = 1 Traceback (most recent call last): File "", line 1, in TypeError: can't set attributes of built-in/extension type 'xml.etree.ElementTree.Element' |
|
|
msg189474 - (view) |
Author: Joe Stuart (jjstuart) |
Date: 2013-05-17 18:04 |
At the end of ElementTree all of the c accelerators are being imported and it looks like only XMLParser is being used. Here is a patch that only imports XMLParser. |
|
|
msg189477 - (view) |
Author: Joe Stuart (jjstuart) |
Date: 2013-05-17 18:19 |
This patch should fix the issue of the classes being overwritten by the c accelerated ones. |
|
|
msg189478 - (view) |
Author: Joe Stuart (jjstuart) |
Date: 2013-05-17 19:11 |
Forgot to update the XMLParser() assignment. |
|
|
msg189497 - (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) *  |
Date: 2013-05-18 07:15 |
Replacement of pure-Python classes by C-accelerated classes is intentional. http://docs.python.org/3.3/library/xml.etree.elementtree.html "Changed in version 3.3: This module will use a fast implementation whenever available. The xml.etree.cElementTree module is deprecated." |
|
|
msg189515 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2013-05-18 14:14 |
Yes, overwriting the Python classes with C classes is not an error, but the original issue is legit. The error should be more immediately reported. |
|
|
msg189518 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2013-05-18 14:41 |
The problem is that element_setattro is returning a wrong value for error - NULL instead of -1. So the exception is set and is triggered on the next line instead. Will fix for 3.3 and default branches |
|
|
msg189520 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-05-18 14:53 |
New changeset 9682241dc8fc by Eli Bendersky in branch '3.3': Issue #17989: element_setattro returned incorrect error value. http://hg.python.org/cpython/rev/9682241dc8fc New changeset b111ae4f83ef by Eli Bendersky in branch 'default': Issue #17989: element_setattro returned incorrect error value. http://hg.python.org/cpython/rev/b111ae4f83ef |
|
|
msg189521 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2013-05-18 14:54 |
Fixed. Thanks for the report! Python 3.4.0a0 (default:1b760f926846+9682241dc8fc+, May 18 2013, 07:52:49) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import xml.etree.ElementTree as ET; j = ET.Element('j') >>> j.ham = 2 Traceback (most recent call last): File "", line 1, in AttributeError: Can't set arbitraty attributes on Element >>> |
|
|
msg189625 - (view) |
Author: Joe Stuart (jjstuart) |
Date: 2013-05-19 21:39 |
Looks like a typo in arbitrary. AttributeError: Can't set arbitraty attributes on Element |
|
|
msg189628 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-05-20 00:00 |
New changeset 65680e3a7f07 by Eli Bendersky in branch '3.3': Issue #17989: fix typo in error message http://hg.python.org/cpython/rev/65680e3a7f07 New changeset 19767536ce84 by Eli Bendersky in branch 'default': Issue #17989: fix typo in error message http://hg.python.org/cpython/rev/19767536ce84 |
|
|