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
f68f2fec
Kaydet (Commit)
f68f2fec
authored
Ock 11, 2001
tarafından
Moshe Zadka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implementation of PEP-0217.
This closes the PEP, and patch 103170
üst
5ac97957
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
27 deletions
+72
-27
libsys.tex
Doc/lib/libsys.tex
+9
-0
ceval.c
Python/ceval.c
+17
-27
sysmodule.c
Python/sysmodule.c
+46
-0
No files found.
Doc/lib/libsys.tex
Dosyayı görüntüle @
f68f2fec
...
@@ -44,6 +44,15 @@ Integer specifying the handle of the Python DLL.
...
@@ -44,6 +44,15 @@ Integer specifying the handle of the Python DLL.
Availability: Windows.
Availability: Windows.
\end{datadesc}
\end{datadesc}
\begin{funcdesc}
{
displayhook
}{
\var
{
value
}}
If
\var
{
value
}
is not
\code
{
None
}
, this function prints it to
\code
{
sys.stdout
}
, and saves it in
\code
{__
builtin
__
.
_}
.
This function is called when an expression is entered at the prompt
of an interactive Python session. It exists mainly so it can be
overridden.
\end{funcdesc}
\begin{funcdesc}
{
exc
_
info
}{}
\begin{funcdesc}
{
exc
_
info
}{}
This function returns a tuple of three values that give information
This function returns a tuple of three values that give information
about the exception that is currently being handled. The information
about the exception that is currently being handled. The information
...
...
Python/ceval.c
Dosyayı görüntüle @
f68f2fec
...
@@ -1245,36 +1245,26 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
...
@@ -1245,36 +1245,26 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
case
PRINT_EXPR
:
case
PRINT_EXPR
:
v
=
POP
();
v
=
POP
();
/* Print value except if None */
w
=
PySys_GetObject
(
"displayhook"
);
/* After printing, also assign to '_' */
if
(
w
==
NULL
)
{
/* Before, set '_' to None to avoid recursion */
PyErr_SetString
(
PyExc_RuntimeError
,
if
(
v
!=
Py_None
&&
"lost sys.displayhook"
);
(
err
=
PyDict_SetItemString
(
err
=
-
1
;
f
->
f_builtins
,
"_"
,
Py_None
))
==
0
)
{
}
err
=
Py_FlushLine
();
if
(
err
==
0
)
{
if
(
err
==
0
)
{
x
=
Py_BuildValue
(
"(O)"
,
v
);
x
=
PySys_GetObject
(
"stdout"
);
if
(
x
==
NULL
)
if
(
x
==
NULL
)
{
err
=
-
1
;
PyErr_SetString
(
}
PyExc_RuntimeError
,
if
(
err
==
0
)
{
"lost sys.stdout"
);
w
=
PyEval_CallObject
(
w
,
x
);
err
=
-
1
;
if
(
w
==
NULL
)
}
err
=
-
1
;
}
if
(
err
==
0
)
err
=
PyFile_WriteObject
(
v
,
x
,
0
);
if
(
err
==
0
)
{
PyFile_SoftSpace
(
x
,
1
);
err
=
Py_FlushLine
();
}
if
(
err
==
0
)
{
err
=
PyDict_SetItemString
(
f
->
f_builtins
,
"_"
,
v
);
}
}
}
Py_DECREF
(
v
);
Py_DECREF
(
v
);
Py_XDECREF
(
x
);
break
;
break
;
case
PRINT_ITEM_TO
:
case
PRINT_ITEM_TO
:
w
=
stream
=
POP
();
w
=
stream
=
POP
();
/* fall through to PRINT_ITEM */
/* fall through to PRINT_ITEM */
...
...
Python/sysmodule.c
Dosyayı görüntüle @
f68f2fec
...
@@ -67,6 +67,50 @@ PySys_SetObject(char *name, PyObject *v)
...
@@ -67,6 +67,50 @@ PySys_SetObject(char *name, PyObject *v)
return
PyDict_SetItemString
(
sd
,
name
,
v
);
return
PyDict_SetItemString
(
sd
,
name
,
v
);
}
}
static
PyObject
*
sys_displayhook
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
o
,
*
stdout
;
PyInterpreterState
*
interp
=
PyThreadState_Get
()
->
interp
;
PyObject
*
modules
=
interp
->
modules
;
PyObject
*
builtins
=
PyDict_GetItemString
(
modules
,
"__builtin__"
);
/* parse arguments */
if
(
!
PyArg_ParseTuple
(
args
,
"O:displayhook"
,
&
o
))
return
NULL
;
/* Print value except if None */
/* After printing, also assign to '_' */
/* Before, set '_' to None to avoid recursion */
if
(
o
==
Py_None
)
{
Py_INCREF
(
Py_None
);
return
Py_None
;
}
if
(
PyObject_SetAttrString
(
builtins
,
"_"
,
Py_None
)
!=
0
)
return
NULL
;
if
(
Py_FlushLine
()
!=
0
)
return
NULL
;
stdout
=
PySys_GetObject
(
"stdout"
);
if
(
stdout
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"lost sys.stdout"
);
return
NULL
;
}
if
(
PyFile_WriteObject
(
o
,
stdout
,
0
)
!=
0
)
return
NULL
;
PyFile_SoftSpace
(
stdout
,
1
);
if
(
Py_FlushLine
()
!=
0
)
return
NULL
;
if
(
PyObject_SetAttrString
(
builtins
,
"_"
,
o
)
!=
0
)
return
NULL
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
char
displayhook_doc
[]
=
"displayhook(o) -> None
\n
"
"
\n
"
"Print o to the stdout, and save it in __builtin__._
\n
"
;
static
PyObject
*
static
PyObject
*
sys_exc_info
(
PyObject
*
self
,
PyObject
*
args
)
sys_exc_info
(
PyObject
*
self
,
PyObject
*
args
)
{
{
...
@@ -332,6 +376,7 @@ extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
...
@@ -332,6 +376,7 @@ extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
static
PyMethodDef
sys_methods
[]
=
{
static
PyMethodDef
sys_methods
[]
=
{
/* Might as well keep this in alphabetic order */
/* Might as well keep this in alphabetic order */
{
"displayhook"
,
sys_displayhook
,
1
,
displayhook_doc
},
{
"exc_info"
,
sys_exc_info
,
1
,
exc_info_doc
},
{
"exc_info"
,
sys_exc_info
,
1
,
exc_info_doc
},
{
"exit"
,
sys_exit
,
0
,
exit_doc
},
{
"exit"
,
sys_exit
,
0
,
exit_doc
},
{
"getdefaultencoding"
,
sys_getdefaultencoding
,
1
,
{
"getdefaultencoding"
,
sys_getdefaultencoding
,
1
,
...
@@ -475,6 +520,7 @@ __stderr__ -- the original stderr; don't use!\n\
...
@@ -475,6 +520,7 @@ __stderr__ -- the original stderr; don't use!\n\
\n
\
\n
\
Functions:
\n
\
Functions:
\n
\
\n
\
\n
\
displayhook() -- print an object to the screen, and save it in __builtin__._
\n
\
exc_info() -- return thread-safe information about the current exception
\n
\
exc_info() -- return thread-safe information about the current exception
\n
\
exit() -- exit the interpreter by raising SystemExit
\n
\
exit() -- exit the interpreter by raising SystemExit
\n
\
getrefcount() -- return the reference count for an object (plus one :-)
\n
\
getrefcount() -- return the reference count for an object (plus one :-)
\n
\
...
...
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