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
3fe64d0c
Kaydet (Commit)
3fe64d0c
authored
Şub 18, 2016
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16915: Clarify that mode parameter of socket.makefile() does not accept
the same values as open().
üst
c12fef9a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
socket.rst
Doc/library/socket.rst
+2
-1
socket.py
Lib/socket.py
+3
-3
test_socket.py
Lib/test/test_socket.py
+14
-0
No files found.
Doc/library/socket.rst
Dosyayı görüntüle @
3fe64d0c
...
@@ -1006,7 +1006,8 @@ to sockets.
...
@@ -1006,7 +1006,8 @@ to sockets.
Return a :term:`file object` associated with the socket. The exact returned
Return a :term:`file object` associated with the socket. The exact returned
type depends on the arguments given to :meth:`makefile`. These arguments are
type depends on the arguments given to :meth:`makefile`. These arguments are
interpreted the same way as by the built-in :func:`open` function.
interpreted the same way as by the built-in :func:`open` function, except
the only supported *mode* values are ``'r'`` (default), ``'w'`` and ``'b'``.
The socket must be in blocking mode; it can have a timeout, but the file
The socket must be in blocking mode; it can have a timeout, but the file
object's internal buffer may end up in an inconsistent state if a timeout
object's internal buffer may end up in an inconsistent state if a timeout
...
...
Lib/socket.py
Dosyayı görüntüle @
3fe64d0c
...
@@ -209,10 +209,10 @@ class socket(_socket.socket):
...
@@ -209,10 +209,10 @@ class socket(_socket.socket):
encoding
=
None
,
errors
=
None
,
newline
=
None
):
encoding
=
None
,
errors
=
None
,
newline
=
None
):
"""makefile(...) -> an I/O stream connected to the socket
"""makefile(...) -> an I/O stream connected to the socket
The arguments are as for io.open() after the filename,
The arguments are as for io.open() after the filename, except the only
except the only mode characters supported are 'r', 'w' and 'b'.
supported mode values are 'r' (default), 'w' and 'b'.
The semantics are similar too. (XXX refactor to share code?)
"""
"""
# XXX refactor to share code?
if
not
set
(
mode
)
<=
{
"r"
,
"w"
,
"b"
}:
if
not
set
(
mode
)
<=
{
"r"
,
"w"
,
"b"
}:
raise
ValueError
(
"invalid mode
%
r (only r, w, b allowed)"
%
(
mode
,))
raise
ValueError
(
"invalid mode
%
r (only r, w, b allowed)"
%
(
mode
,))
writing
=
"w"
in
mode
writing
=
"w"
in
mode
...
...
Lib/test/test_socket.py
Dosyayı görüntüle @
3fe64d0c
...
@@ -1374,6 +1374,20 @@ class GeneralModuleTests(unittest.TestCase):
...
@@ -1374,6 +1374,20 @@ class GeneralModuleTests(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
fp
.
writable
)
self
.
assertRaises
(
ValueError
,
fp
.
writable
)
self
.
assertRaises
(
ValueError
,
fp
.
seekable
)
self
.
assertRaises
(
ValueError
,
fp
.
seekable
)
def
test_makefile_mode
(
self
):
for
mode
in
'r'
,
'rb'
,
'rw'
,
'w'
,
'wb'
:
with
self
.
subTest
(
mode
=
mode
):
with
socket
.
socket
()
as
sock
:
with
sock
.
makefile
(
mode
)
as
fp
:
self
.
assertEqual
(
fp
.
mode
,
mode
)
def
test_makefile_invalid_mode
(
self
):
for
mode
in
'rt'
,
'x'
,
'+'
,
'a'
:
with
self
.
subTest
(
mode
=
mode
):
with
socket
.
socket
()
as
sock
:
with
self
.
assertRaisesRegex
(
ValueError
,
'invalid mode'
):
sock
.
makefile
(
mode
)
def
test_pickle
(
self
):
def
test_pickle
(
self
):
sock
=
socket
.
socket
()
sock
=
socket
.
socket
()
with
sock
:
with
sock
:
...
...
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