diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-04-23 17:44:32 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-04-23 17:44:32 (GMT) |
commit | db780d0d13976b099b22bc5145a53ec3ff6c63ba (patch) | |
tree | 0857fe4b93ec2419c47ae92fc0e75d0babaa8e4a /Lib | |
parent | 53b977127fe8192f8bdf6a400de81086e128e936 (diff) | |
download | cpython-db780d0d13976b099b22bc5145a53ec3ff6c63ba.zip cpython-db780d0d13976b099b22bc5145a53ec3ff6c63ba.tar.gz cpython-db780d0d13976b099b22bc5145a53ec3ff6c63ba.tar.bz2 |
fix instance dicts with str subclasses (#13903)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_dict.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index cd396c8..cdd8b6c 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -879,6 +879,16 @@ class DictTest(unittest.TestCase): values = list(it) + [drop] self.assertEqual(sorted(values), sorted(list(data.values()))) + def test_instance_dict_getattr_str_subclass(self): + class Foo: + def __init__(self, msg): + self.msg = msg + f = Foo('123') + class _str(str): + pass + self.assertEqual(f.msg, getattr(f, _str('msg'))) + self.assertEqual(f.msg, f.__dict__[_str('msg')]) + from test import mapping_tests class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol): |