Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2cdfbb35
Commit
2cdfbb35
authored
Aug 05, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge Py_Cleanup() into Py_Finalize(). Call the various small Fini()
functions.
parent
0d9d0fb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
36 deletions
+43
-36
Python/pythonrun.c
Python/pythonrun.c
+43
-36
No files found.
Python/pythonrun.c
View file @
2cdfbb35
...
@@ -69,6 +69,8 @@ static PyObject *run_pyc_file Py_PROTO((FILE *fp, char *filename,
...
@@ -69,6 +69,8 @@ static PyObject *run_pyc_file Py_PROTO((FILE *fp, char *filename,
static
void
err_input
Py_PROTO
((
perrdetail
*
));
static
void
err_input
Py_PROTO
((
perrdetail
*
));
static
void
initsigs
Py_PROTO
((
void
));
static
void
initsigs
Py_PROTO
((
void
));
static
void
finisigs
Py_PROTO
((
void
));
static
void
finisigs
Py_PROTO
((
void
));
static
void
call_sys_exitfunc
Py_PROTO
((
void
));
static
void
call_ll_exitfuncs
Py_PROTO
((
void
));
int
Py_DebugFlag
;
/* Needed by parser.c */
int
Py_DebugFlag
;
/* Needed by parser.c */
int
Py_VerboseFlag
;
/* Needed by import.c */
int
Py_VerboseFlag
;
/* Needed by import.c */
...
@@ -162,6 +164,8 @@ Py_Finalize()
...
@@ -162,6 +164,8 @@ Py_Finalize()
PyInterpreterState
*
interp
;
PyInterpreterState
*
interp
;
PyThreadState
*
tstate
;
PyThreadState
*
tstate
;
call_sys_exitfunc
();
if
(
!
initialized
)
if
(
!
initialized
)
Py_FatalError
(
"Py_Finalize: not initialized"
);
Py_FatalError
(
"Py_Finalize: not initialized"
);
initialized
=
0
;
initialized
=
0
;
...
@@ -177,9 +181,38 @@ Py_Finalize()
...
@@ -177,9 +181,38 @@ Py_Finalize()
finisigs
();
finisigs
();
_PyImport_Fini
();
_PyImport_Fini
();
_PyBuiltin_Fini
();
_PyBuiltin_Fini
();
PyMethod_Fini
();
PyFrame_Fini
();
PyCFunction_Fini
();
PyTuple_Fini
();
PyString_Fini
();
PyString_Fini
();
PyInt_Fini
();
PyFloat_Fini
();
/* XXX Still allocated:
- various static ad-hoc pointers to interned strings
- int and float free list blocks
- whatever various modules and libraries allocate
*/
PyGrammar_RemoveAccelerators
(
&
_PyParser_Grammar
);
PyGrammar_RemoveAccelerators
(
&
_PyParser_Grammar
);
call_ll_exitfuncs
();
#ifdef COUNT_ALLOCS
dump_counts
();
#endif
#ifdef Py_REF_DEBUG
fprintf
(
stderr
,
"[%ld refs]
\n
"
,
_Py_RefTotal
);
#endif
#ifdef Py_TRACE_REFS
if
(
_Py_AskYesNo
(
"Print left references?"
))
{
_Py_PrintReferences
(
stderr
);
}
_Py_ResetReferences
();
#endif
/* Py_TRACE_REFS */
}
}
/* Create and initialize a new interpreter and thread, and return the
/* Create and initialize a new interpreter and thread, and return the
...
@@ -297,22 +330,6 @@ Py_GetProgramName()
...
@@ -297,22 +330,6 @@ Py_GetProgramName()
return
progname
;
return
progname
;
}
}
/*
Py_Initialize()
-- do everything, no-op on second call, call fatal on failure, set path
#2
-- create new interp+tstate & make it current, return NULL on failure,
make it current, do all setup, set path
#3
-- #2 without set path
#4
-- is there any point to #3 for caller-provided current interp+tstate?
*/
/* Create __main__ module */
/* Create __main__ module */
static
void
static
void
...
@@ -831,8 +848,8 @@ int Py_AtExit(func)
...
@@ -831,8 +848,8 @@ int Py_AtExit(func)
return
0
;
return
0
;
}
}
void
static
void
Py_Cleanup
()
call_sys_exitfunc
()
{
{
PyObject
*
exitfunc
=
PySys_GetObject
(
"exitfunc"
);
PyObject
*
exitfunc
=
PySys_GetObject
(
"exitfunc"
);
...
@@ -849,9 +866,11 @@ Py_Cleanup()
...
@@ -849,9 +866,11 @@ Py_Cleanup()
}
}
Py_FlushLine
();
Py_FlushLine
();
}
Py_Finalize
();
static
void
call_ll_exitfuncs
()
{
while
(
nexitfuncs
>
0
)
while
(
nexitfuncs
>
0
)
(
*
exitfuncs
[
--
nexitfuncs
])();
(
*
exitfuncs
[
--
nexitfuncs
])();
...
@@ -867,21 +886,7 @@ void
...
@@ -867,21 +886,7 @@ void
Py_Exit
(
sts
)
Py_Exit
(
sts
)
int
sts
;
int
sts
;
{
{
Py_Cleanup
();
Py_Finalize
();
#ifdef COUNT_ALLOCS
dump_counts
();
#endif
#ifdef Py_REF_DEBUG
fprintf
(
stderr
,
"[%ld refs]
\n
"
,
_Py_RefTotal
);
#endif
#ifdef Py_TRACE_REFS
if
(
_Py_AskYesNo
(
"Print left references?"
))
{
_Py_PrintReferences
(
stderr
);
}
#endif
/* Py_TRACE_REFS */
#ifdef macintosh
#ifdef macintosh
PyMac_Exit
(
sts
);
PyMac_Exit
(
sts
);
...
@@ -896,7 +901,9 @@ sighandler(sig)
...
@@ -896,7 +901,9 @@ sighandler(sig)
int
sig
;
int
sig
;
{
{
signal
(
sig
,
SIG_DFL
);
/* Don't catch recursive signals */
signal
(
sig
,
SIG_DFL
);
/* Don't catch recursive signals */
Py_Cleanup
();
/* Do essential clean-up */
/* Do essential exit processing only */
call_sys_exitfunc
();
call_ll_exitfuncs
();
#ifdef HAVE_KILL
#ifdef HAVE_KILL
kill
(
getpid
(),
sig
);
/* Pretend the signal killed us */
kill
(
getpid
(),
sig
);
/* Pretend the signal killed us */
#else
#else
...
...
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