mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
bpo-31107: Fix copyreg mangled slot names calculation. (#2989)
This commit is contained in:
parent
778928b0c7
commit
c4c9866064
4 changed files with 18 additions and 1 deletions
|
|
@ -16,6 +16,12 @@ class WithWeakref(object):
|
|||
class WithPrivate(object):
|
||||
__slots__ = ('__spam',)
|
||||
|
||||
class _WithLeadingUnderscoreAndPrivate(object):
|
||||
__slots__ = ('__spam',)
|
||||
|
||||
class ___(object):
|
||||
__slots__ = ('__spam',)
|
||||
|
||||
class WithSingleString(object):
|
||||
__slots__ = 'spam'
|
||||
|
||||
|
|
@ -104,6 +110,10 @@ def test_slotnames(self):
|
|||
self.assertEqual(copyreg._slotnames(WithWeakref), [])
|
||||
expected = ['_WithPrivate__spam']
|
||||
self.assertEqual(copyreg._slotnames(WithPrivate), expected)
|
||||
expected = ['_WithLeadingUnderscoreAndPrivate__spam']
|
||||
self.assertEqual(copyreg._slotnames(_WithLeadingUnderscoreAndPrivate),
|
||||
expected)
|
||||
self.assertEqual(copyreg._slotnames(___), ['__spam'])
|
||||
self.assertEqual(copyreg._slotnames(WithSingleString), ['spam'])
|
||||
expected = ['eggs', 'spam']
|
||||
expected.sort()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue