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
44309e6b
Kaydet (Commit)
44309e6b
authored
Kas 22, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make FileIO.mode always include 'b'
#4386 Reviewed by Amaury
üst
656aa28c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
16 deletions
+24
-16
stdtypes.rst
Doc/library/stdtypes.rst
+2
-0
socket.py
Lib/socket.py
+3
-1
test_fileio.py
Lib/test/test_fileio.py
+2
-2
test_gzip.py
Lib/test/test_gzip.py
+1
-1
test_io.py
Lib/test/test_io.py
+7
-7
test_socket.py
Lib/test/test_socket.py
+2
-2
NEWS
Misc/NEWS
+2
-0
_fileio.c
Modules/_fileio.c
+5
-3
No files found.
Doc/library/stdtypes.rst
Dosyayı görüntüle @
44309e6b
...
@@ -1875,6 +1875,8 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
...
@@ -1875,6 +1875,8 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
view objects.
view objects.
.. _dict-views:
Dictionary view objects
Dictionary view objects
-----------------------
-----------------------
...
...
Lib/socket.py
Dosyayı görüntüle @
44309e6b
...
@@ -198,10 +198,12 @@ class SocketIO(io.RawIOBase):
...
@@ -198,10 +198,12 @@ class SocketIO(io.RawIOBase):
# XXX More docs
# XXX More docs
def
__init__
(
self
,
sock
,
mode
):
def
__init__
(
self
,
sock
,
mode
):
if
mode
not
in
(
"r"
,
"w"
,
"rw"
):
if
mode
not
in
(
"r"
,
"w"
,
"rw"
,
"rb"
,
"wb"
,
"rwb"
):
raise
ValueError
(
"invalid mode:
%
r"
%
mode
)
raise
ValueError
(
"invalid mode:
%
r"
%
mode
)
io
.
RawIOBase
.
__init__
(
self
)
io
.
RawIOBase
.
__init__
(
self
)
self
.
_sock
=
sock
self
.
_sock
=
sock
if
"b"
not
in
mode
:
mode
+=
"b"
self
.
_mode
=
mode
self
.
_mode
=
mode
self
.
_reading
=
"r"
in
mode
self
.
_reading
=
"r"
in
mode
self
.
_writing
=
"w"
in
mode
self
.
_writing
=
"w"
in
mode
...
...
Lib/test/test_fileio.py
Dosyayı görüntüle @
44309e6b
...
@@ -49,7 +49,7 @@ class AutoFileTests(unittest.TestCase):
...
@@ -49,7 +49,7 @@ class AutoFileTests(unittest.TestCase):
# verify expected attributes exist
# verify expected attributes exist
f
=
self
.
f
f
=
self
.
f
self
.
assertEquals
(
f
.
mode
,
"w"
)
self
.
assertEquals
(
f
.
mode
,
"w
b
"
)
self
.
assertEquals
(
f
.
closed
,
False
)
self
.
assertEquals
(
f
.
closed
,
False
)
# verify the attributes are readonly
# verify the attributes are readonly
...
@@ -159,7 +159,7 @@ class OtherFileTests(unittest.TestCase):
...
@@ -159,7 +159,7 @@ class OtherFileTests(unittest.TestCase):
def
testModeStrings
(
self
):
def
testModeStrings
(
self
):
# check invalid mode strings
# check invalid mode strings
for
mode
in
(
""
,
"aU"
,
"wU+"
,
"r
b
"
,
"rt"
):
for
mode
in
(
""
,
"aU"
,
"wU+"
,
"r
w
"
,
"rt"
):
try
:
try
:
f
=
_fileio
.
_FileIO
(
TESTFN
,
mode
)
f
=
_fileio
.
_FileIO
(
TESTFN
,
mode
)
except
ValueError
:
except
ValueError
:
...
...
Lib/test/test_gzip.py
Dosyayı görüntüle @
44309e6b
...
@@ -150,7 +150,7 @@ class TestGzip(unittest.TestCase):
...
@@ -150,7 +150,7 @@ class TestGzip(unittest.TestCase):
def
test_mode
(
self
):
def
test_mode
(
self
):
self
.
test_write
()
self
.
test_write
()
f
=
gzip
.
GzipFile
(
self
.
filename
,
'r'
)
f
=
gzip
.
GzipFile
(
self
.
filename
,
'r'
)
self
.
assert
True
(
f
.
myfileobj
.
mode
.
startswith
(
'r'
)
)
self
.
assert
Equal
(
f
.
myfileobj
.
mode
,
'rb'
)
f
.
close
()
f
.
close
()
def
test_1647484
(
self
):
def
test_1647484
(
self
):
...
...
Lib/test/test_io.py
Dosyayı görüntüle @
44309e6b
...
@@ -1266,7 +1266,7 @@ class MiscIOTest(unittest.TestCase):
...
@@ -1266,7 +1266,7 @@ class MiscIOTest(unittest.TestCase):
def
test_attributes
(
self
):
def
test_attributes
(
self
):
f
=
io
.
open
(
support
.
TESTFN
,
"wb"
,
buffering
=
0
)
f
=
io
.
open
(
support
.
TESTFN
,
"wb"
,
buffering
=
0
)
self
.
assertEquals
(
f
.
mode
,
"w"
)
self
.
assertEquals
(
f
.
mode
,
"w
b
"
)
f
.
close
()
f
.
close
()
f
=
io
.
open
(
support
.
TESTFN
,
"U"
)
f
=
io
.
open
(
support
.
TESTFN
,
"U"
)
...
@@ -1274,18 +1274,18 @@ class MiscIOTest(unittest.TestCase):
...
@@ -1274,18 +1274,18 @@ class MiscIOTest(unittest.TestCase):
self
.
assertEquals
(
f
.
buffer
.
name
,
support
.
TESTFN
)
self
.
assertEquals
(
f
.
buffer
.
name
,
support
.
TESTFN
)
self
.
assertEquals
(
f
.
buffer
.
raw
.
name
,
support
.
TESTFN
)
self
.
assertEquals
(
f
.
buffer
.
raw
.
name
,
support
.
TESTFN
)
self
.
assertEquals
(
f
.
mode
,
"U"
)
self
.
assertEquals
(
f
.
mode
,
"U"
)
self
.
assertEquals
(
f
.
buffer
.
mode
,
"r"
)
self
.
assertEquals
(
f
.
buffer
.
mode
,
"r
b
"
)
self
.
assertEquals
(
f
.
buffer
.
raw
.
mode
,
"r"
)
self
.
assertEquals
(
f
.
buffer
.
raw
.
mode
,
"r
b
"
)
f
.
close
()
f
.
close
()
f
=
io
.
open
(
support
.
TESTFN
,
"w+"
)
f
=
io
.
open
(
support
.
TESTFN
,
"w+"
)
self
.
assertEquals
(
f
.
mode
,
"w+"
)
self
.
assertEquals
(
f
.
mode
,
"w+"
)
self
.
assertEquals
(
f
.
buffer
.
mode
,
"r+"
)
# Does it really matter?
self
.
assertEquals
(
f
.
buffer
.
mode
,
"r
b
+"
)
# Does it really matter?
self
.
assertEquals
(
f
.
buffer
.
raw
.
mode
,
"r+"
)
self
.
assertEquals
(
f
.
buffer
.
raw
.
mode
,
"r
b
+"
)
g
=
io
.
open
(
f
.
fileno
(),
"wb"
,
closefd
=
False
)
g
=
io
.
open
(
f
.
fileno
(),
"wb"
,
closefd
=
False
)
self
.
assertEquals
(
g
.
mode
,
"w"
)
self
.
assertEquals
(
g
.
mode
,
"w
b
"
)
self
.
assertEquals
(
g
.
raw
.
mode
,
"w"
)
self
.
assertEquals
(
g
.
raw
.
mode
,
"w
b
"
)
self
.
assertEquals
(
g
.
name
,
f
.
fileno
())
self
.
assertEquals
(
g
.
name
,
f
.
fileno
())
self
.
assertEquals
(
g
.
raw
.
name
,
f
.
fileno
())
self
.
assertEquals
(
g
.
raw
.
name
,
f
.
fileno
())
f
.
close
()
f
.
close
()
...
...
Lib/test/test_socket.py
Dosyayı görüntüle @
44309e6b
...
@@ -849,11 +849,11 @@ class FileObjectClassTestCase(SocketConnectedTest):
...
@@ -849,11 +849,11 @@ class FileObjectClassTestCase(SocketConnectedTest):
self
.
assert_
(
not
self
.
cli_file
.
closed
)
self
.
assert_
(
not
self
.
cli_file
.
closed
)
def
testAttributes
(
self
):
def
testAttributes
(
self
):
self
.
assertEqual
(
self
.
serv_file
.
mode
,
'r'
)
self
.
assertEqual
(
self
.
serv_file
.
mode
,
'r
b
'
)
self
.
assertEqual
(
self
.
serv_file
.
name
,
self
.
cli_conn
.
fileno
())
self
.
assertEqual
(
self
.
serv_file
.
name
,
self
.
cli_conn
.
fileno
())
def
_testAttributes
(
self
):
def
_testAttributes
(
self
):
self
.
assertEqual
(
self
.
cli_file
.
mode
,
'w'
)
self
.
assertEqual
(
self
.
cli_file
.
mode
,
'w
b
'
)
self
.
assertEqual
(
self
.
cli_file
.
name
,
self
.
serv_conn
.
fileno
())
self
.
assertEqual
(
self
.
cli_file
.
name
,
self
.
serv_conn
.
fileno
())
class
UnbufferedFileObjectClassTestCase
(
FileObjectClassTestCase
):
class
UnbufferedFileObjectClassTestCase
(
FileObjectClassTestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
44309e6b
...
@@ -48,6 +48,8 @@ Core and Builtins
...
@@ -48,6 +48,8 @@ Core and Builtins
Library
Library
-------
-------
- FileIO's mode attribute now always includes ``"b"``.
- Issue #3799: Fix dbm.dumb to accept strings as well as bytes for keys. String
- Issue #3799: Fix dbm.dumb to accept strings as well as bytes for keys. String
keys are now written out in UTF-8.
keys are now written out in UTF-8.
...
...
Modules/_fileio.c
Dosyayı görüntüle @
44309e6b
...
@@ -208,6 +208,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
...
@@ -208,6 +208,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
flags
|=
O_CREAT
;
flags
|=
O_CREAT
;
append
=
1
;
append
=
1
;
break
;
break
;
case
'b'
:
break
;
case
'+'
:
case
'+'
:
if
(
plus
)
if
(
plus
)
goto
bad_mode
;
goto
bad_mode
;
...
@@ -682,12 +684,12 @@ mode_string(PyFileIOObject *self)
...
@@ -682,12 +684,12 @@ mode_string(PyFileIOObject *self)
{
{
if
(
self
->
readable
)
{
if
(
self
->
readable
)
{
if
(
self
->
writable
)
if
(
self
->
writable
)
return
"r+"
;
return
"r
b
+"
;
else
else
return
"r"
;
return
"r
b
"
;
}
}
else
else
return
"w"
;
return
"w
b
"
;
}
}
static
PyObject
*
static
PyObject
*
...
...
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