summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-09-27 04:37:37 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-09-27 04:37:37 (GMT)
commitbdb215b18a42360b6a9c82876fa71f19ca1a416d (patch)
tree6959fda40daef25cb1b0792b0b08671506f0450c /Lib
parentf0db2dfda777ad3380e7816cabe4c4240f31687f (diff)
downloadcpython-bdb215b18a42360b6a9c82876fa71f19ca1a416d.zip
cpython-bdb215b18a42360b6a9c82876fa71f19ca1a416d.tar.gz
cpython-bdb215b18a42360b6a9c82876fa71f19ca1a416d.tar.bz2
[3.6] bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (GH-3615) (#3774)
(cherry picked from commit 30b61b51e05d2d43e8e2e783b0a9df738535423b)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_anon.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_anon.py b/Lib/ctypes/test/test_anon.py
index d892b59..d378392 100644
--- a/Lib/ctypes/test/test_anon.py
+++ b/Lib/ctypes/test/test_anon.py
@@ -1,4 +1,5 @@
import unittest
+import test.support
from ctypes import *
class AnonTest(unittest.TestCase):
@@ -35,6 +36,18 @@ class AnonTest(unittest.TestCase):
{"_fields_": [],
"_anonymous_": ["x"]}))
+ @test.support.cpython_only
+ def test_issue31490(self):
+ # There shouldn't be an assertion failure in case the class has an
+ # attribute whose name is specified in _anonymous_ but not in _fields_.
+
+ # AttributeError: 'x' is specified in _anonymous_ but not in _fields_
+ with self.assertRaises(AttributeError):
+ class Name(Structure):
+ _fields_ = []
+ _anonymous_ = ["x"]
+ x = 42
+
def test_nested(self):
class ANON_S(Structure):
_fields_ = [("a", c_int)]