Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c4c98660
Commit
c4c98660
authored
Aug 04, 2017
by
Shane Harvey
Committed by
Serhiy Storchaka
Aug 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31107: Fix copyreg mangled slot names calculation. (#2989)
parent
778928b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
1 deletion
+18
-1
Lib/copyreg.py
Lib/copyreg.py
+5
-1
Lib/test/test_copyreg.py
Lib/test/test_copyreg.py
+10
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS.d/next/Library/2017-08-02-12-48-15.bpo-31107.1t2hn5.rst
...S.d/next/Library/2017-08-02-12-48-15.bpo-31107.1t2hn5.rst
+2
-0
No files found.
Lib/copyreg.py
View file @
c4c98660
...
...
@@ -128,7 +128,11 @@ def _slotnames(cls):
continue
# mangled names
elif
name
.
startswith
(
'__'
)
and
not
name
.
endswith
(
'__'
):
names
.
append
(
'_%s%s'
%
(
c
.
__name__
,
name
))
stripped
=
c
.
__name__
.
lstrip
(
'_'
)
if
stripped
:
names
.
append
(
'_%s%s'
%
(
stripped
,
name
))
else
:
names
.
append
(
name
)
else
:
names
.
append
(
name
)
...
...
Lib/test/test_copyreg.py
View file @
c4c98660
...
...
@@ -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 @@ class CopyRegTestCase(unittest.TestCase):
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
()
...
...
Misc/ACKS
View file @
c4c98660
...
...
@@ -598,6 +598,7 @@ David Harrigan
Brian Harring
Jonathan Hartley
Travis B. Hartwell
Shane Harvey
Larry Hastings
Tim Hatch
Shane Hathaway
...
...
Misc/NEWS.d/next/Library/2017-08-02-12-48-15.bpo-31107.1t2hn5.rst
0 → 100644
View file @
c4c98660
Fix `copyreg._slotnames()` mangled attribute calculation for classes whose
name begins with an underscore. Patch by Shane Harvey.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment