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
bba8f2d1
Kaydet (Commit)
bba8f2d1
authored
Nis 10, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revert temporary commit in r79937
üst
16e026cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
99 deletions
+21
-99
test_io.py
Lib/test/test_io.py
+0
-41
test_posix.py
Lib/test/test_posix.py
+3
-21
fileio.c
Modules/_io/fileio.c
+18
-37
No files found.
Lib/test/test_io.py
Dosyayı görüntüle @
bba8f2d1
...
@@ -2394,47 +2394,6 @@ class MiscIOTest(unittest.TestCase):
...
@@ -2394,47 +2394,6 @@ class MiscIOTest(unittest.TestCase):
# baseline "io" module.
# baseline "io" module.
self
.
_check_abc_inheritance
(
io
)
self
.
_check_abc_inheritance
(
io
)
# Issue #5380: reading all available bytes from a pipe or a PTY when
# the other end has been closed.
def
check_pipe_func
(
self
,
pipe_func
,
buffered
):
master_fd
,
slave_fd
=
pipe_func
()
# Simulate a subprocess writing some data to the
# slave end of the pipe, and then exiting.
data
=
b
'TEST DATA'
try
:
os
.
write
(
slave_fd
,
data
)
finally
:
os
.
close
(
slave_fd
)
with
self
.
open
(
master_fd
,
"rb"
,
buffering
=-
1
if
buffered
else
0
)
as
f
:
# Request more data than available
gotdata
=
f
.
read
(
len
(
data
)
+
1
)
self
.
assertEqual
(
gotdata
,
data
)
# Trying to read again returns an empty string
self
.
assertEqual
(
b
''
,
f
.
read
())
self
.
assertEqual
(
b
''
,
f
.
read
(
1
))
def
test_pipe_read_buffered
(
self
):
if
not
hasattr
(
os
,
'pipe'
):
self
.
skipTest
(
"os.pipe not available"
)
self
.
check_pipe_func
(
os
.
pipe
,
True
)
def
test_pipe_read_raw
(
self
):
if
not
hasattr
(
os
,
'pipe'
):
self
.
skipTest
(
"os.pipe not available"
)
self
.
check_pipe_func
(
os
.
pipe
,
False
)
def
test_openpty_read_buffered
(
self
):
if
not
hasattr
(
os
,
'openpty'
):
self
.
skipTest
(
"os.openpty not available"
)
self
.
check_pipe_func
(
os
.
openpty
,
True
)
def
test_openpty_read_raw
(
self
):
if
not
hasattr
(
os
,
'openpty'
):
self
.
skipTest
(
"os.openpty not available"
)
self
.
check_pipe_func
(
os
.
openpty
,
False
)
class
CMiscIOTest
(
MiscIOTest
):
class
CMiscIOTest
(
MiscIOTest
):
io
=
io
io
=
io
...
...
Lib/test/test_posix.py
Dosyayı görüntüle @
bba8f2d1
...
@@ -280,29 +280,11 @@ class PosixTester(unittest.TestCase):
...
@@ -280,29 +280,11 @@ class PosixTester(unittest.TestCase):
if
hasattr
(
posix
,
'strerror'
):
if
hasattr
(
posix
,
'strerror'
):
self
.
assertTrue
(
posix
.
strerror
(
0
))
self
.
assertTrue
(
posix
.
strerror
(
0
))
def
check_pipe_func
(
self
,
pipe_func
):
master_fd
,
slave_fd
=
pipe_func
()
try
:
# Simulate a subprocess writing some data to the
# slave end of the pipe, and then exiting.
data
=
b
'TEST DATA'
try
:
os
.
write
(
slave_fd
,
data
)
finally
:
os
.
close
(
slave_fd
)
# Request more data than available
gotdata
=
os
.
read
(
master_fd
,
len
(
data
)
+
1
)
self
.
assertEqual
(
gotdata
,
data
)
finally
:
os
.
close
(
master_fd
)
def
test_pipe
(
self
):
def
test_pipe
(
self
):
if
hasattr
(
posix
,
'pipe'
):
if
hasattr
(
posix
,
'pipe'
):
self
.
check_pipe_func
(
posix
.
pipe
)
reader
,
writer
=
posix
.
pipe
()
os
.
close
(
reader
)
def
test_openpty
(
self
):
os
.
close
(
writer
)
if
hasattr
(
posix
,
'openpty'
):
self
.
check_pipe_func
(
posix
.
openpty
)
def
test_tempnam
(
self
):
def
test_tempnam
(
self
):
if
hasattr
(
posix
,
'tempnam'
):
if
hasattr
(
posix
,
'tempnam'
):
...
...
Modules/_io/fileio.c
Dosyayı görüntüle @
bba8f2d1
...
@@ -464,34 +464,6 @@ fileio_seekable(fileio *self)
...
@@ -464,34 +464,6 @@ fileio_seekable(fileio *self)
return
PyBool_FromLong
((
long
)
self
->
seekable
);
return
PyBool_FromLong
((
long
)
self
->
seekable
);
}
}
static
Py_ssize_t
internal_read
(
int
fd
,
void
*
buf
,
size_t
count
)
{
Py_ssize_t
n
;
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
n
=
read
(
fd
,
buf
,
count
);
#ifdef EIO
/* Issue #5380: when reading past the end of a pipe created by
openpty(), EIO can be set. Make it an EOF instead, so that
the normal technique of testing for an empty string can be used.
*/
if
(
n
==
-
1
&&
errno
==
EIO
)
{
if
(
isatty
(
fd
))
{
n
=
0
;
errno
=
0
;
}
else
{
/* isatty() set errno, restore its value */
errno
=
EIO
;
}
}
#endif
Py_END_ALLOW_THREADS
return
n
;
}
static
PyObject
*
static
PyObject
*
fileio_readinto
(
fileio
*
self
,
PyObject
*
args
)
fileio_readinto
(
fileio
*
self
,
PyObject
*
args
)
{
{
...
@@ -506,9 +478,12 @@ fileio_readinto(fileio *self, PyObject *args)
...
@@ -506,9 +478,12 @@ fileio_readinto(fileio *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"w*"
,
&
pbuf
))
if
(
!
PyArg_ParseTuple
(
args
,
"w*"
,
&
pbuf
))
return
NULL
;
return
NULL
;
if
(
_PyVerify_fd
(
self
->
fd
))
if
(
_PyVerify_fd
(
self
->
fd
))
{
n
=
internal_read
(
self
->
fd
,
pbuf
.
buf
,
pbuf
.
len
);
Py_BEGIN_ALLOW_THREADS
else
errno
=
0
;
n
=
read
(
self
->
fd
,
pbuf
.
buf
,
pbuf
.
len
);
Py_END_ALLOW_THREADS
}
else
n
=
-
1
;
n
=
-
1
;
PyBuffer_Release
(
&
pbuf
);
PyBuffer_Release
(
&
pbuf
);
if
(
n
<
0
)
{
if
(
n
<
0
)
{
...
@@ -585,9 +560,12 @@ fileio_readall(fileio *self)
...
@@ -585,9 +560,12 @@ fileio_readall(fileio *self)
break
;
break
;
}
}
}
}
n
=
internal_read
(
self
->
fd
,
Py_BEGIN_ALLOW_THREADS
PyBytes_AS_STRING
(
result
)
+
total
,
errno
=
0
;
newsize
-
total
);
n
=
read
(
self
->
fd
,
PyBytes_AS_STRING
(
result
)
+
total
,
newsize
-
total
);
Py_END_ALLOW_THREADS
if
(
n
==
0
)
if
(
n
==
0
)
break
;
break
;
if
(
n
<
0
)
{
if
(
n
<
0
)
{
...
@@ -639,9 +617,12 @@ fileio_read(fileio *self, PyObject *args)
...
@@ -639,9 +617,12 @@ fileio_read(fileio *self, PyObject *args)
return
NULL
;
return
NULL
;
ptr
=
PyBytes_AS_STRING
(
bytes
);
ptr
=
PyBytes_AS_STRING
(
bytes
);
if
(
_PyVerify_fd
(
self
->
fd
))
if
(
_PyVerify_fd
(
self
->
fd
))
{
n
=
internal_read
(
self
->
fd
,
ptr
,
size
);
Py_BEGIN_ALLOW_THREADS
else
errno
=
0
;
n
=
read
(
self
->
fd
,
ptr
,
size
);
Py_END_ALLOW_THREADS
}
else
n
=
-
1
;
n
=
-
1
;
if
(
n
<
0
)
{
if
(
n
<
0
)
{
...
...
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