This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年05月15日 22:46 by jwilk, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test-element-setattr.py | jwilk, 2013年05月15日 22:46 | |||
| Messages (12) | |||
|---|---|---|---|
| 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 <module>
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 "<stdin>", line 1, in <module> 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) * (Python triager) | 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) * (Python committer) | 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) * (Python committer) | 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) (Python triager) | 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) * (Python committer) | 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 "<stdin>", line 1, in <module> 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) (Python triager) | 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 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:45 | admin | set | github: 62189 |
| 2013年05月20日 00:01:03 | eli.bendersky | set | status: open -> closed resolution: fixed stage: resolved |
| 2013年05月20日 00:00:40 | python-dev | set | messages: + msg189628 |
| 2013年05月19日 22:07:10 | Arfrever | set | status: closed -> open resolution: fixed -> (no value) stage: resolved -> (no value) |
| 2013年05月19日 21:39:02 | jjstuart | set | messages: + msg189625 |
| 2013年05月18日 14:54:53 | eli.bendersky | set | status: open -> closed resolution: fixed stage: needs patch -> resolved |
| 2013年05月18日 14:54:41 | eli.bendersky | set | messages: + msg189521 |
| 2013年05月18日 14:53:52 | python-dev | set | nosy:
+ python-dev messages: + msg189520 |
| 2013年05月18日 14:42:22 | eli.bendersky | set | type: behavior stage: needs patch |
| 2013年05月18日 14:41:56 | eli.bendersky | set | messages: + msg189518 |
| 2013年05月18日 14:14:19 | eli.bendersky | set | messages: + msg189515 |
| 2013年05月18日 14:06:54 | eli.bendersky | set | assignee: eli.bendersky |
| 2013年05月18日 07:17:42 | Arfrever | set | files: - ElementTree.patch |
| 2013年05月18日 07:15:53 | Arfrever | set | messages: + msg189497 |
| 2013年05月17日 19:11:02 | jjstuart | set | files:
+ ElementTree.patch messages: + msg189478 |
| 2013年05月17日 19:02:32 | jjstuart | set | files: - ElementTree.patch |
| 2013年05月17日 18:19:31 | jjstuart | set | files:
+ ElementTree.patch messages: + msg189477 |
| 2013年05月17日 18:17:16 | jjstuart | set | files: - ElementTree.patch |
| 2013年05月17日 18:04:28 | jjstuart | set | files:
+ ElementTree.patch keywords: + patch messages: + msg189474 |
| 2013年05月17日 15:55:53 | jjstuart | set | nosy:
+ jjstuart messages: + msg189463 |
| 2013年05月16日 13:57:57 | Arfrever | set | nosy:
+ Arfrever versions: + Python 3.4 |
| 2013年05月16日 13:04:44 | pitrou | set | nosy:
+ eli.bendersky |
| 2013年05月15日 22:46:51 | jwilk | create | |