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
3d1f2d3b
Kaydet (Commit)
3d1f2d3b
authored
Eki 06, 2014
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make _socket.socket weakrefable (closes #22569)
Patch from Alex Gaynor.
üst
7788dba2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
test_socket.py
Lib/test/test_socket.py
+10
-2
socketmodule.c
Modules/socketmodule.c
+4
-1
socketmodule.h
Modules/socketmodule.h
+1
-0
No files found.
Lib/test/test_socket.py
Dosyayı görüntüle @
3d1f2d3b
...
...
@@ -12,9 +12,9 @@ import sys
import
os
import
array
import
contextlib
from
weakref
import
proxy
import
signal
import
math
import
weakref
try
:
import
_socket
except
ImportError
:
...
...
@@ -264,7 +264,7 @@ class GeneralModuleTests(unittest.TestCase):
def
test_weakref
(
self
):
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
p
=
proxy
(
s
)
p
=
weakref
.
proxy
(
s
)
self
.
assertEqual
(
p
.
fileno
(),
s
.
fileno
())
s
.
close
()
s
=
None
...
...
@@ -275,6 +275,14 @@ class GeneralModuleTests(unittest.TestCase):
else
:
self
.
fail
(
'Socket proxy still exists'
)
def
test_weakref__sock
(
self
):
s
=
socket
.
socket
()
.
_sock
w
=
weakref
.
ref
(
s
)
self
.
assertIs
(
w
(),
s
)
del
s
test_support
.
gc_collect
()
self
.
assertIsNone
(
w
())
def
testSocketError
(
self
):
# Testing socket module exceptions
def
raise_error
(
*
args
,
**
kwargs
):
...
...
Modules/socketmodule.c
Dosyayı görüntüle @
3d1f2d3b
...
...
@@ -3115,6 +3115,8 @@ sock_dealloc(PySocketSockObject *s)
{
if
(
s
->
sock_fd
!=
-
1
)
(
void
)
SOCKETCLOSE
(
s
->
sock_fd
);
if
(
s
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
s
);
Py_TYPE
(
s
)
->
tp_free
((
PyObject
*
)
s
);
}
...
...
@@ -3163,6 +3165,7 @@ sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
((
PySocketSockObject
*
)
new
)
->
sock_fd
=
-
1
;
((
PySocketSockObject
*
)
new
)
->
sock_timeout
=
-
1
.
0
;
((
PySocketSockObject
*
)
new
)
->
errorhandler
=
&
set_error
;
((
PySocketSockObject
*
)
new
)
->
weakreflist
=
NULL
;
}
return
new
;
}
...
...
@@ -3226,7 +3229,7 @@ static PyTypeObject sock_type = {
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
offsetof
(
PySocketSockObject
,
weakreflist
),
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
sock_methods
,
/* tp_methods */
...
...
Modules/socketmodule.h
Dosyayı görüntüle @
3d1f2d3b
...
...
@@ -132,6 +132,7 @@ typedef struct {
sets a Python exception */
double
sock_timeout
;
/* Operation timeout in seconds;
0.0 means non-blocking */
PyObject
*
weakreflist
;
}
PySocketSockObject
;
/* --- C API ----------------------------------------------------*/
...
...
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