Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1079:92bdeb9ef3e2
Date: 2012-11-29 21:34 -0800
http://bitbucket.org/cffi/cffi/changeset/92bdeb9ef3e2/
Log: Test and fix.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -437,7 +437,7 @@
{
if (ct->ct_flags & CT_IS_ENUM) {
PyObject *res = PyTuple_GetItem(ct->ct_stuff, 1);
- Py_XINCREF(res);
+ if (res) res = PyDict_Copy(res);
return res;
}
return nosuchattr("elements");
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1254,6 +1254,9 @@
BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20))
assert BEnum.kind == "enum"
assert BEnum.elements == {-20: 'ab', 0: 'def', 1: 'c'}
+ # 'elements' is not the real dict, but merely a copy
+ BEnum.elements[2] = '??'
+ assert BEnum.elements == {-20: 'ab', 0: 'def', 1: 'c'}
def test_cast_to_enum():
BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit