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
50ab1a36
Kaydet (Commit)
50ab1a36
authored
Nis 11, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #26685: Raise OSError if closing a socket fails
üst
f01e408c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
2 deletions
+26
-2
socket.rst
Doc/library/socket.rst
+4
-0
3.6.rst
Doc/whatsnew/3.6.rst
+4
-0
test_pty.py
Lib/test/test_pty.py
+0
-1
test_socket.py
Lib/test/test_socket.py
+11
-0
NEWS
Misc/NEWS
+2
-0
socketmodule.c
Modules/socketmodule.c
+5
-1
No files found.
Doc/library/socket.rst
Dosyayı görüntüle @
50ab1a36
...
@@ -868,6 +868,10 @@ to sockets.
...
@@ -868,6 +868,10 @@ to sockets.
it is recommended to :meth:`close` them explicitly, or to use a
it is recommended to :meth:`close` them explicitly, or to use a
:keyword:`with` statement around them.
:keyword:`with` statement around them.
.. versionchanged:: 3.6
:exc:`OSError` is now raised if an error occurs when the underlying
:c:func:`close` call is made.
.. note::
.. note::
:meth:`close()` releases the resource associated with a connection but
:meth:`close()` releases the resource associated with a connection but
...
...
Doc/whatsnew/3.6.rst
Dosyayı görüntüle @
50ab1a36
...
@@ -514,6 +514,10 @@ Changes in the Python API
...
@@ -514,6 +514,10 @@ Changes in the Python API
* :func:`spwd.getspnam` now raises a :exc:`PermissionError` instead of
* :func:`spwd.getspnam` now raises a :exc:`PermissionError` instead of
:exc:`KeyError` if the user doesn't have privileges.
:exc:`KeyError` if the user doesn't have privileges.
* The :meth:`socket.socket.close` method now raises an exception if
an error (e.g. EBADF) was reported by the underlying system call.
See :issue:`26685`.
Changes in the C API
Changes in the C API
--------------------
--------------------
...
...
Lib/test/test_pty.py
Dosyayı görüntüle @
50ab1a36
...
@@ -277,7 +277,6 @@ class SmallPtyTests(unittest.TestCase):
...
@@ -277,7 +277,6 @@ class SmallPtyTests(unittest.TestCase):
socketpair
=
self
.
_socketpair
()
socketpair
=
self
.
_socketpair
()
masters
=
[
s
.
fileno
()
for
s
in
socketpair
]
masters
=
[
s
.
fileno
()
for
s
in
socketpair
]
os
.
close
(
masters
[
1
])
socketpair
[
1
]
.
close
()
socketpair
[
1
]
.
close
()
os
.
close
(
write_to_stdin_fd
)
os
.
close
(
write_to_stdin_fd
)
...
...
Lib/test/test_socket.py
Dosyayı görüntüle @
50ab1a36
...
@@ -1161,6 +1161,17 @@ class GeneralModuleTests(unittest.TestCase):
...
@@ -1161,6 +1161,17 @@ class GeneralModuleTests(unittest.TestCase):
sock
.
close
()
sock
.
close
()
self
.
assertRaises
(
OSError
,
sock
.
send
,
b
"spam"
)
self
.
assertRaises
(
OSError
,
sock
.
send
,
b
"spam"
)
def
testCloseException
(
self
):
sock
=
socket
.
socket
()
socket
.
socket
(
fileno
=
sock
.
fileno
())
.
close
()
try
:
sock
.
close
()
except
OSError
as
err
:
# Winsock apparently raises ENOTSOCK
self
.
assertIn
(
err
.
errno
,
(
errno
.
EBADF
,
errno
.
ENOTSOCK
))
else
:
self
.
fail
(
"close() should raise EBADF/ENOTSOCK"
)
def
testNewAttributes
(
self
):
def
testNewAttributes
(
self
):
# testing .family, .type and .protocol
# testing .family, .type and .protocol
...
...
Misc/NEWS
Dosyayı görüntüle @
50ab1a36
...
@@ -240,6 +240,8 @@ Core and Builtins
...
@@ -240,6 +240,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
26685
:
Raise
OSError
if
closing
a
socket
fails
.
-
Issue
#
16329
:
Add
.
webm
to
mimetypes
.
types_map
.
Patch
by
Giampaolo
Rodola
'.
-
Issue
#
16329
:
Add
.
webm
to
mimetypes
.
types_map
.
Patch
by
Giampaolo
Rodola
'.
- Issue #13952: Add .csv to mimetypes.types_map. Patch by Geoff Wilson.
- Issue #13952: Add .csv to mimetypes.types_map. Patch by Geoff Wilson.
...
...
Modules/socketmodule.c
Dosyayı görüntüle @
50ab1a36
...
@@ -2576,6 +2576,7 @@ static PyObject *
...
@@ -2576,6 +2576,7 @@ static PyObject *
sock_close
(
PySocketSockObject
*
s
)
sock_close
(
PySocketSockObject
*
s
)
{
{
SOCKET_T
fd
;
SOCKET_T
fd
;
int
res
;
fd
=
s
->
sock_fd
;
fd
=
s
->
sock_fd
;
if
(
fd
!=
-
1
)
{
if
(
fd
!=
-
1
)
{
...
@@ -2586,8 +2587,11 @@ sock_close(PySocketSockObject *s)
...
@@ -2586,8 +2587,11 @@ sock_close(PySocketSockObject *s)
http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
for more details. */
for more details. */
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
(
void
)
SOCKETCLOSE
(
fd
);
res
=
SOCKETCLOSE
(
fd
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
res
<
0
)
{
return
s
->
errorhandler
();
}
}
}
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_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