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
f1c42599
Commit
f1c42599
authored
Mar 04, 2012
by
Meador Inge
Browse files
Options
Browse Files
Download
Plain Diff
Issue #14195: Make WeakSet.__lt__ and WeakSet.__gt__ irreflexive.
parents
5102bf47
653f932e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
17 deletions
+33
-17
Lib/_weakrefset.py
Lib/_weakrefset.py
+6
-6
Lib/test/test_weakset.py
Lib/test/test_weakset.py
+23
-11
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/_weakrefset.py
View file @
f1c42599
...
...
@@ -152,17 +152,17 @@ class WeakSet:
def
issubset
(
self
,
other
):
return
self
.
data
.
issubset
(
ref
(
item
)
for
item
in
other
)
__l
t
__
=
issubset
__l
e
__
=
issubset
def
__l
e
__
(
self
,
other
):
return
self
.
data
<
=
set
(
ref
(
item
)
for
item
in
other
)
def
__l
t
__
(
self
,
other
):
return
self
.
data
<
set
(
ref
(
item
)
for
item
in
other
)
def
issuperset
(
self
,
other
):
return
self
.
data
.
issuperset
(
ref
(
item
)
for
item
in
other
)
__g
t
__
=
issuperset
__g
e
__
=
issuperset
def
__g
e
__
(
self
,
other
):
return
self
.
data
>
=
set
(
ref
(
item
)
for
item
in
other
)
def
__g
t
__
(
self
,
other
):
return
self
.
data
>
set
(
ref
(
item
)
for
item
in
other
)
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
...
...
Lib/test/test_weakset.py
View file @
f1c42599
...
...
@@ -28,6 +28,12 @@ class TestWeakSet(unittest.TestCase):
# need to keep references to them
self
.
items
=
[
ustr
(
c
)
for
c
in
(
'a'
,
'b'
,
'c'
)]
self
.
items2
=
[
ustr
(
c
)
for
c
in
(
'x'
,
'y'
,
'z'
)]
self
.
ab_items
=
[
ustr
(
c
)
for
c
in
'ab'
]
self
.
abcde_items
=
[
ustr
(
c
)
for
c
in
'abcde'
]
self
.
def_items
=
[
ustr
(
c
)
for
c
in
'def'
]
self
.
ab_weakset
=
WeakSet
(
self
.
ab_items
)
self
.
abcde_weakset
=
WeakSet
(
self
.
abcde_items
)
self
.
def_weakset
=
WeakSet
(
self
.
def_items
)
self
.
letters
=
[
ustr
(
c
)
for
c
in
string
.
ascii_letters
]
self
.
s
=
WeakSet
(
self
.
items
)
self
.
d
=
dict
.
fromkeys
(
self
.
items
)
...
...
@@ -137,22 +143,28 @@ class TestWeakSet(unittest.TestCase):
self
.
assertEqual
(
self
.
s
^
frozenset
(
self
.
items2
),
i
)
def
test_sub_and_super
(
self
):
pl
,
ql
,
rl
=
map
(
lambda
s
:
[
ustr
(
c
)
for
c
in
s
],
[
'ab'
,
'abcde'
,
'def'
])
p
,
q
,
r
=
map
(
WeakSet
,
(
pl
,
ql
,
rl
))
self
.
assertTrue
(
p
<
q
)
self
.
assertTrue
(
p
<=
q
)
self
.
assertTrue
(
q
<=
q
)
self
.
assertTrue
(
q
>
p
)
self
.
assertTrue
(
q
>=
p
)
self
.
assertFalse
(
q
<
r
)
self
.
assertFalse
(
q
<=
r
)
self
.
assertFalse
(
q
>
r
)
self
.
assertFalse
(
q
>=
r
)
self
.
assertTrue
(
self
.
ab_weakset
<=
self
.
abcde_weakset
)
self
.
assertTrue
(
self
.
abcde_weakset
<=
self
.
abcde_weakset
)
self
.
assertTrue
(
self
.
abcde_weakset
>=
self
.
ab_weakset
)
self
.
assertFalse
(
self
.
abcde_weakset
<=
self
.
def_weakset
)
self
.
assertFalse
(
self
.
abcde_weakset
>=
self
.
def_weakset
)
self
.
assertTrue
(
set
(
'a'
).
issubset
(
'abc'
))
self
.
assertTrue
(
set
(
'abc'
).
issuperset
(
'a'
))
self
.
assertFalse
(
set
(
'a'
).
issubset
(
'cbs'
))
self
.
assertFalse
(
set
(
'cbs'
).
issuperset
(
'a'
))
def
test_lt
(
self
):
self
.
assertTrue
(
self
.
ab_weakset
<
self
.
abcde_weakset
)
self
.
assertFalse
(
self
.
abcde_weakset
<
self
.
def_weakset
)
self
.
assertFalse
(
self
.
ab_weakset
<
self
.
ab_weakset
)
self
.
assertFalse
(
WeakSet
()
<
WeakSet
())
def
test_gt
(
self
):
self
.
assertTrue
(
self
.
abcde_weakset
>
self
.
ab_weakset
)
self
.
assertFalse
(
self
.
abcde_weakset
>
self
.
def_weakset
)
self
.
assertFalse
(
self
.
ab_weakset
>
self
.
ab_weakset
)
self
.
assertFalse
(
WeakSet
()
>
WeakSet
())
def
test_gc
(
self
):
# Create a nest of cycles to exercise overall ref count check
s
=
WeakSet
(
Foo
()
for
i
in
range
(
1000
))
...
...
Misc/NEWS
View file @
f1c42599
...
...
@@ -511,6 +511,10 @@ Core and Builtins
Library
-------
-
Issue
#
14195
:
An
issue
that
caused
weakref
.
WeakSet
instances
to
incorrectly
return
True
for
a
WeakSet
instance
'a'
in
both
'a < a'
and
'a > a'
has
been
fixed
.
-
Issue
#
14166
:
Pickler
objects
now
have
an
optional
``
dispatch_table
``
attribute
which
allows
to
set
custom
per
-
pickler
reduction
functions
.
Patch
by
sbt
.
...
...
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