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
f1d8e7cf
Commit
f1d8e7cf
authored
Jan 17, 2019
by
David H
Committed by
Victor Stinner
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35701: Added __weakref__ slot to uuid.UUID (GH-11570)
Added test for weakreferencing a uuid.UUID object.
parent
89669ffe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
Lib/test/test_uuid.py
Lib/test/test_uuid.py
+6
-0
Lib/uuid.py
Lib/uuid.py
+1
-1
No files found.
Lib/test/test_uuid.py
View file @
f1d8e7cf
...
@@ -9,6 +9,7 @@ import pickle
...
@@ -9,6 +9,7 @@ import pickle
import
shutil
import
shutil
import
subprocess
import
subprocess
import
sys
import
sys
import
weakref
from
unittest
import
mock
from
unittest
import
mock
py_uuid
=
support
.
import_fresh_module
(
'uuid'
,
blocked
=
[
'_uuid'
])
py_uuid
=
support
.
import_fresh_module
(
'uuid'
,
blocked
=
[
'_uuid'
])
...
@@ -657,6 +658,11 @@ class BaseTestUUID:
...
@@ -657,6 +658,11 @@ class BaseTestUUID:
self
.
assertNotEqual
(
parent_value
,
child_value
)
self
.
assertNotEqual
(
parent_value
,
child_value
)
def
test_uuid_weakref
(
self
):
# bpo-35701: check that weak referencing to a UUID object can be created
strong
=
self
.
uuid
.
uuid4
()
weak
=
weakref
.
ref
(
strong
)
self
.
assertIs
(
strong
,
weak
())
class
TestUUIDWithoutExtModule
(
BaseTestUUID
,
unittest
.
TestCase
):
class
TestUUIDWithoutExtModule
(
BaseTestUUID
,
unittest
.
TestCase
):
uuid
=
py_uuid
uuid
=
py_uuid
...
...
Lib/uuid.py
View file @
f1d8e7cf
...
@@ -118,7 +118,7 @@ class UUID:
...
@@ -118,7 +118,7 @@ class UUID:
uuid_generate_time_safe(3).
uuid_generate_time_safe(3).
"""
"""
__slots__
=
(
'int'
,
'is_safe'
)
__slots__
=
(
'int'
,
'is_safe'
,
'__weakref__'
)
def
__init__
(
self
,
hex
=
None
,
bytes
=
None
,
bytes_le
=
None
,
fields
=
None
,
def
__init__
(
self
,
hex
=
None
,
bytes
=
None
,
bytes_le
=
None
,
fields
=
None
,
int
=
None
,
version
=
None
,
int
=
None
,
version
=
None
,
...
...
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