Issue31428
Created on 2017-09-12 12:04 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3512 | merged | Oren Milman, 2017-09-12 12:25 | |
| Messages (3) | |||
|---|---|---|---|
| msg301953 - (view) | Author: Oren Milman (Oren Milman) * | Date: 2017-09-12 12:04 | |
The following code causes ElementTree.Element.__deepcopy__() to raise a
SystemError:
class BadMemo:
def get(*args):
return None
import xml.etree.ElementTree
xml.etree.ElementTree.Element('foo').__deepcopy__(BadMemo())
this is because _elementtree_Element___deepcopy__() (in Modules/_elementtree.c)
assumes that memo is a dictionary, and passes it to PyDict_SetItem(), which
raises the SystemError.
|
|||
| msg301955 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-09-12 12:24 | |
I suppose the Python implementation supports arbitrary mapping, not just dict. We could use general mapping API in the C implementation, but I think it isn't worth. __deepcopy__ is used internally by copy.deepcopy(), which always passes a dict. I think it isn't worth to backport a fix, and it doesn't need tests. The behavior of calling __deepcopy__ with non-dict is implementation detail. But it shouldn't crash or raise SystemError. |
|||
| msg301963 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-09-12 14:39 | |
New changeset d056818ed2ade6d28190a375d7183f4aef9caa55 by Serhiy Storchaka (Oren Milman) in branch 'master': bpo-31428: Prevent raising a SystemError in case the memo arg of ElementTree.Element.__deepcopy__() isn't a dictionary. (#3512) https://github.com/python/cpython/commit/d056818ed2ade6d28190a375d7183f4aef9caa55 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75609 |
| 2017-09-12 14:40:01 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-09-12 14:39:19 | serhiy.storchaka | set | messages: + msg301963 |
| 2017-09-12 12:25:35 | Oren Milman | set | keywords:
+ patch stage: needs patch -> patch review pull_requests: + pull_request3507 |
| 2017-09-12 12:24:00 | serhiy.storchaka | set | messages:
+ msg301955 versions: - Python 2.7, Python 3.6 |
| 2017-09-12 12:15:10 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka stage: needs patch versions: + Python 2.7, Python 3.6 |
| 2017-09-12 12:04:08 | Oren Milman | create | |
