Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
88659b0a
Kaydet (Commit)
88659b0a
authored
May 20, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#2592: delegate nb_index and the floor/truediv slots in weakref.proxy.
üst
112aa503
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
test_weakref.py
Lib/test/test_weakref.py
+22
-1
NEWS
Misc/NEWS
+3
-0
weakrefobject.c
Objects/weakrefobject.c
+10
-0
No files found.
Lib/test/test_weakref.py
Dosyayı görüntüle @
88659b0a
...
...
@@ -3,6 +3,7 @@ import sys
import
unittest
import
UserList
import
weakref
import
operator
from
test
import
test_support
...
...
@@ -187,6 +188,26 @@ class ReferencesTestCase(TestBase):
self
.
assertEqual
(
L3
[:
5
],
p3
[:
5
])
self
.
assertEqual
(
L3
[
2
:
5
],
p3
[
2
:
5
])
def
test_proxy_index
(
self
):
class
C
:
def
__index__
(
self
):
return
10
o
=
C
()
p
=
weakref
.
proxy
(
o
)
self
.
assertEqual
(
operator
.
index
(
p
),
10
)
def
test_proxy_div
(
self
):
class
C
:
def
__floordiv__
(
self
,
other
):
return
42
def
__ifloordiv__
(
self
,
other
):
return
21
o
=
C
()
p
=
weakref
.
proxy
(
o
)
self
.
assertEqual
(
p
//
5
,
42
)
p
//=
5
self
.
assertEqual
(
p
,
21
)
# The PyWeakref_* C API is documented as allowing either NULL or
# None as the value for the callback, where either means "no
# callback". The "no callback" ref and proxy objects are supposed
...
...
@@ -1059,7 +1080,7 @@ class WeakKeyDictionaryTestCase(mapping_tests.BasicTestMappingProtocol):
def
_reference
(
self
):
return
self
.
__ref
.
copy
()
libreftest
=
""" Doctest for examples in the library reference:
libweakref.tex
libreftest
=
""" Doctest for examples in the library reference:
weakref.rst
>>> import weakref
>>> class Dict(dict):
...
...
Misc/NEWS
Dosyayı görüntüle @
88659b0a
...
...
@@ -36,6 +36,9 @@ Core and Builtins
Extension Modules
-----------------
- Issue #2592: delegate nb_index and the floor/truediv slots in
weakref.proxy.
- Support os.O_ASYNC and fcntl.FASYNC if the constants exist on the
platform.
...
...
Objects/weakrefobject.c
Dosyayı görüntüle @
88659b0a
...
...
@@ -473,6 +473,8 @@ WRAP_BINARY(proxy_add, PyNumber_Add)
WRAP_BINARY
(
proxy_sub
,
PyNumber_Subtract
)
WRAP_BINARY
(
proxy_mul
,
PyNumber_Multiply
)
WRAP_BINARY
(
proxy_div
,
PyNumber_Divide
)
WRAP_BINARY
(
proxy_floor_div
,
PyNumber_FloorDivide
)
WRAP_BINARY
(
proxy_true_div
,
PyNumber_TrueDivide
)
WRAP_BINARY
(
proxy_mod
,
PyNumber_Remainder
)
WRAP_BINARY
(
proxy_divmod
,
PyNumber_Divmod
)
WRAP_TERNARY
(
proxy_pow
,
PyNumber_Power
)
...
...
@@ -492,6 +494,8 @@ WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd)
WRAP_BINARY
(
proxy_isub
,
PyNumber_InPlaceSubtract
)
WRAP_BINARY
(
proxy_imul
,
PyNumber_InPlaceMultiply
)
WRAP_BINARY
(
proxy_idiv
,
PyNumber_InPlaceDivide
)
WRAP_BINARY
(
proxy_ifloor_div
,
PyNumber_InPlaceFloorDivide
)
WRAP_BINARY
(
proxy_itrue_div
,
PyNumber_InPlaceTrueDivide
)
WRAP_BINARY
(
proxy_imod
,
PyNumber_InPlaceRemainder
)
WRAP_TERNARY
(
proxy_ipow
,
PyNumber_InPlacePower
)
WRAP_BINARY
(
proxy_ilshift
,
PyNumber_InPlaceLshift
)
...
...
@@ -499,6 +503,7 @@ WRAP_BINARY(proxy_irshift, PyNumber_InPlaceRshift)
WRAP_BINARY
(
proxy_iand
,
PyNumber_InPlaceAnd
)
WRAP_BINARY
(
proxy_ixor
,
PyNumber_InPlaceXor
)
WRAP_BINARY
(
proxy_ior
,
PyNumber_InPlaceOr
)
WRAP_UNARY
(
proxy_index
,
PyNumber_Index
)
static
int
proxy_nonzero
(
PyWeakReference
*
proxy
)
...
...
@@ -623,6 +628,11 @@ static PyNumberMethods proxy_as_number = {
proxy_iand
,
/*nb_inplace_and*/
proxy_ixor
,
/*nb_inplace_xor*/
proxy_ior
,
/*nb_inplace_or*/
proxy_floor_div
,
/*nb_floor_divide*/
proxy_true_div
,
/*nb_true_divide*/
proxy_ifloor_div
,
/*nb_inplace_floor_divide*/
proxy_itrue_div
,
/*nb_inplace_true_divide*/
proxy_index
,
/*nb_index*/
};
static
PySequenceMethods
proxy_as_sequence
=
{
...
...
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