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
eba76965
Kaydet (Commit)
eba76965
authored
May 27, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make input9) behave properly with the new I/O library.
üst
f5bec7c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
14 deletions
+66
-14
bltinmodule.c
Python/bltinmodule.c
+66
-14
No files found.
Python/bltinmodule.c
Dosyayı görüntüle @
eba76965
...
@@ -1571,42 +1571,88 @@ end: string appended after the last value, default a newline.");
...
@@ -1571,42 +1571,88 @@ end: string appended after the last value, default a newline.");
static
PyObject
*
static
PyObject
*
builtin_input
(
PyObject
*
self
,
PyObject
*
args
)
builtin_input
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
v
=
NULL
;
PyObject
*
promptarg
=
NULL
;
PyObject
*
fin
=
PySys_GetObject
(
"stdin"
);
PyObject
*
fin
=
PySys_GetObject
(
"stdin"
);
PyObject
*
fout
=
PySys_GetObject
(
"stdout"
);
PyObject
*
fout
=
PySys_GetObject
(
"stdout"
);
PyObject
*
ferr
=
PySys_GetObject
(
"stderr"
);
PyObject
*
tmp
;
long
fd
;
int
tty
;
if
(
!
PyArg_UnpackTuple
(
args
,
"input"
,
0
,
1
,
&
v
))
/* Parse arguments */
if
(
!
PyArg_UnpackTuple
(
args
,
"input"
,
0
,
1
,
&
promptarg
))
return
NULL
;
return
NULL
;
/* Check that stdin/out/err are intact */
if
(
fin
==
NULL
)
{
if
(
fin
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"input: lost sys.stdin"
);
PyErr_SetString
(
PyExc_RuntimeError
,
"input(): lost sys.stdin"
);
return
NULL
;
return
NULL
;
}
}
if
(
fout
==
NULL
)
{
if
(
fout
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"input: lost sys.stdout"
);
PyErr_SetString
(
PyExc_RuntimeError
,
"input(): lost sys.stdout"
);
return
NULL
;
}
if
(
ferr
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"input(): lost sys.stderr"
);
return
NULL
;
}
/* First of all, flush stderr */
tmp
=
PyObject_CallMethod
(
ferr
,
"flush"
,
""
);
if
(
tmp
==
NULL
)
return
NULL
;
Py_DECREF
(
tmp
);
/* We should only use (GNU) readline if Python's sys.stdin and
sys.stdout are the same as C's stdin and stdout, because we
need to pass it those. */
tmp
=
PyObject_CallMethod
(
fin
,
"fileno"
,
""
);
if
(
tmp
==
NULL
)
return
NULL
;
return
NULL
;
fd
=
PyInt_AsLong
(
tmp
);
if
(
fd
<
0
&&
PyErr_Occurred
())
return
NULL
;
Py_DECREF
(
tmp
);
tty
=
fd
==
fileno
(
stdin
)
&&
isatty
(
fd
);
if
(
tty
)
{
tmp
=
PyObject_CallMethod
(
fout
,
"fileno"
,
""
);
if
(
tmp
==
NULL
)
return
NULL
;
fd
=
PyInt_AsLong
(
tmp
);
Py_DECREF
(
tmp
);
if
(
fd
<
0
&&
PyErr_Occurred
())
return
NULL
;
tty
=
fd
==
fileno
(
stdout
)
&&
isatty
(
fd
);
}
}
if
(
PyFile_AsFile
(
fin
)
&&
PyFile_AsFile
(
fout
)
&&
isatty
(
fileno
(
PyFile_AsFile
(
fin
)))
/* If we're interactive, use (GNU) readline */
&&
isatty
(
fileno
(
PyFile_AsFile
(
fout
)))
)
{
if
(
tty
)
{
PyObject
*
po
;
PyObject
*
po
;
char
*
prompt
;
char
*
prompt
;
char
*
s
;
char
*
s
;
PyObject
*
result
;
PyObject
*
result
;
if
(
v
!=
NULL
)
{
tmp
=
PyObject_CallMethod
(
fout
,
"flush"
,
""
);
po
=
PyObject_Str
(
v
);
if
(
tmp
==
NULL
)
return
NULL
;
Py_DECREF
(
tmp
);
if
(
promptarg
!=
NULL
)
{
po
=
PyObject_Str
(
promptarg
);
if
(
po
==
NULL
)
if
(
po
==
NULL
)
return
NULL
;
return
NULL
;
prompt
=
PyString_AsString
(
po
);
prompt
=
PyString_AsString
(
po
);
if
(
prompt
==
NULL
)
if
(
prompt
==
NULL
)
{
Py_DECREF
(
po
);
return
NULL
;
return
NULL
;
}
}
}
else
{
else
{
po
=
NULL
;
po
=
NULL
;
prompt
=
""
;
prompt
=
""
;
}
}
s
=
PyOS_Readline
(
PyFile_AsFile
(
fin
),
PyFile_AsFile
(
fout
),
s
=
PyOS_Readline
(
stdin
,
stdout
,
prompt
);
prompt
);
Py_XDECREF
(
po
);
Py_XDECREF
(
po
);
if
(
s
==
NULL
)
{
if
(
s
==
NULL
)
{
if
(
!
PyErr_Occurred
())
if
(
!
PyErr_Occurred
())
...
@@ -1631,10 +1677,16 @@ builtin_input(PyObject *self, PyObject *args)
...
@@ -1631,10 +1677,16 @@ builtin_input(PyObject *self, PyObject *args)
PyMem_FREE
(
s
);
PyMem_FREE
(
s
);
return
result
;
return
result
;
}
}
if
(
v
!=
NULL
)
{
if
(
PyFile_WriteObject
(
v
,
fout
,
Py_PRINT_RAW
)
!=
0
)
/* Fallback if we're not interactive */
if
(
promptarg
!=
NULL
)
{
if
(
PyFile_WriteObject
(
promptarg
,
fout
,
Py_PRINT_RAW
)
!=
0
)
return
NULL
;
return
NULL
;
}
}
tmp
=
PyObject_CallMethod
(
fout
,
"flush"
,
""
);
if
(
tmp
==
NULL
)
return
NULL
;
Py_DECREF
(
tmp
);
return
PyFile_GetLine
(
fin
,
-
1
);
return
PyFile_GetLine
(
fin
,
-
1
);
}
}
...
...
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