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
1abcf670
Kaydet (Commit)
1abcf670
authored
May 24, 2017
tarafından
Eric Snow
Kaydeden (comit)
GitHub
May 24, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-22257: Private C-API for core runtime initialization (PEP 432). (#1772)
(patch by Nick Coghlan)
üst
c842efc6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
20 deletions
+44
-20
pylifecycle.h
Include/pylifecycle.h
+9
-1
pystate.h
Include/pystate.h
+11
-0
main.c
Modules/main.c
+19
-16
bootstrap_hash.c
Python/bootstrap_hash.c
+5
-3
pylifecycle.c
Python/pylifecycle.c
+0
-0
No files found.
Include/pylifecycle.h
Dosyayı görüntüle @
1abcf670
...
@@ -19,8 +19,14 @@ PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
...
@@ -19,8 +19,14 @@ PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
*/
*/
PyAPI_FUNC
(
int
)
Py_SetStandardStreamEncoding
(
const
char
*
encoding
,
PyAPI_FUNC
(
int
)
Py_SetStandardStreamEncoding
(
const
char
*
encoding
,
const
char
*
errors
);
const
char
*
errors
);
/* PEP 432 Multi-phase initialization API (Private while provisional!) */
PyAPI_FUNC
(
void
)
_Py_InitializeCore
(
const
_PyCoreConfig
*
);
PyAPI_FUNC
(
int
)
_Py_IsCoreInitialized
(
void
);
PyAPI_FUNC
(
int
)
_Py_InitializeMainInterpreter
(
int
install_sigs
);
#endif
#endif
/* Initialization and finalization */
PyAPI_FUNC
(
void
)
Py_Initialize
(
void
);
PyAPI_FUNC
(
void
)
Py_Initialize
(
void
);
PyAPI_FUNC
(
void
)
Py_InitializeEx
(
int
);
PyAPI_FUNC
(
void
)
Py_InitializeEx
(
int
);
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
...
@@ -29,6 +35,8 @@ PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int);
...
@@ -29,6 +35,8 @@ PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int);
PyAPI_FUNC
(
void
)
Py_Finalize
(
void
);
PyAPI_FUNC
(
void
)
Py_Finalize
(
void
);
PyAPI_FUNC
(
int
)
Py_FinalizeEx
(
void
);
PyAPI_FUNC
(
int
)
Py_FinalizeEx
(
void
);
PyAPI_FUNC
(
int
)
Py_IsInitialized
(
void
);
PyAPI_FUNC
(
int
)
Py_IsInitialized
(
void
);
/* Subinterpreter support */
PyAPI_FUNC
(
PyThreadState
*
)
Py_NewInterpreter
(
void
);
PyAPI_FUNC
(
PyThreadState
*
)
Py_NewInterpreter
(
void
);
PyAPI_FUNC
(
void
)
Py_EndInterpreter
(
PyThreadState
*
);
PyAPI_FUNC
(
void
)
Py_EndInterpreter
(
PyThreadState
*
);
...
@@ -85,7 +93,7 @@ PyAPI_FUNC(void) _PyImportHooks_Init(void);
...
@@ -85,7 +93,7 @@ PyAPI_FUNC(void) _PyImportHooks_Init(void);
PyAPI_FUNC
(
int
)
_PyFrame_Init
(
void
);
PyAPI_FUNC
(
int
)
_PyFrame_Init
(
void
);
PyAPI_FUNC
(
int
)
_PyFloat_Init
(
void
);
PyAPI_FUNC
(
int
)
_PyFloat_Init
(
void
);
PyAPI_FUNC
(
int
)
PyByteArray_Init
(
void
);
PyAPI_FUNC
(
int
)
PyByteArray_Init
(
void
);
PyAPI_FUNC
(
void
)
_Py_HashRandomization_Init
(
void
);
PyAPI_FUNC
(
void
)
_Py_HashRandomization_Init
(
_PyCoreConfig
*
core_config
);
#endif
#endif
/* Various internal finalizers */
/* Various internal finalizers */
...
...
Include/pystate.h
Dosyayı görüntüle @
1abcf670
...
@@ -23,6 +23,16 @@ typedef struct _is PyInterpreterState;
...
@@ -23,6 +23,16 @@ typedef struct _is PyInterpreterState;
#else
#else
typedef
PyObject
*
(
*
_PyFrameEvalFunction
)(
struct
_frame
*
,
int
);
typedef
PyObject
*
(
*
_PyFrameEvalFunction
)(
struct
_frame
*
,
int
);
typedef
struct
{
int
ignore_environment
;
int
use_hash_seed
;
unsigned
long
hash_seed
;
int
_disable_importlib
;
/* Needed by freeze_importlib */
}
_PyCoreConfig
;
#define _PyCoreConfig_INIT {0, -1, 0, 0}
typedef
struct
_is
{
typedef
struct
_is
{
struct
_is
*
next
;
struct
_is
*
next
;
...
@@ -42,6 +52,7 @@ typedef struct _is {
...
@@ -42,6 +52,7 @@ typedef struct _is {
int
codecs_initialized
;
int
codecs_initialized
;
int
fscodec_initialized
;
int
fscodec_initialized
;
_PyCoreConfig
core_config
;
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
int
dlopenflags
;
int
dlopenflags
;
#endif
#endif
...
...
Modules/main.c
Dosyayı görüntüle @
1abcf670
...
@@ -380,19 +380,6 @@ read_command_line(int argc, wchar_t **argv, _Py_CommandLineDetails *cmdline)
...
@@ -380,19 +380,6 @@ read_command_line(int argc, wchar_t **argv, _Py_CommandLineDetails *cmdline)
wchar_t
*
command
=
NULL
;
wchar_t
*
command
=
NULL
;
wchar_t
*
module
=
NULL
;
wchar_t
*
module
=
NULL
;
int
c
;
int
c
;
char
*
opt
;
opt
=
Py_GETENV
(
"PYTHONMALLOC"
);
if
(
_PyMem_SetupAllocators
(
opt
)
<
0
)
{
fprintf
(
stderr
,
"Error in PYTHONMALLOC: unknown allocator
\"
%s
\"
!
\n
"
,
opt
);
exit
(
1
);
}
// TODO: Move these to core runtime init.
Py_HashRandomizationFlag
=
1
;
_Py_HashRandomization_Init
();
PySys_ResetWarnOptions
();
_PyOS_ResetGetOpt
();
_PyOS_ResetGetOpt
();
...
@@ -584,6 +571,7 @@ Py_Main(int argc, wchar_t **argv)
...
@@ -584,6 +571,7 @@ Py_Main(int argc, wchar_t **argv)
#endif
#endif
int
stdin_is_interactive
=
0
;
int
stdin_is_interactive
=
0
;
_Py_CommandLineDetails
cmdline
=
_Py_CommandLineDetails_INIT
;
_Py_CommandLineDetails
cmdline
=
_Py_CommandLineDetails_INIT
;
_PyCoreConfig
core_config
=
_PyCoreConfig_INIT
;
PyCompilerFlags
cf
;
PyCompilerFlags
cf
;
PyObject
*
main_importer_path
=
NULL
;
PyObject
*
main_importer_path
=
NULL
;
...
@@ -602,11 +590,23 @@ Py_Main(int argc, wchar_t **argv)
...
@@ -602,11 +590,23 @@ Py_Main(int argc, wchar_t **argv)
break
;
break
;
}
}
if
(
c
==
'E'
||
c
==
'I'
)
{
if
(
c
==
'E'
||
c
==
'I'
)
{
Py_IgnoreEnvironmentFlag
++
;
core_config
.
ignore_environment
++
;
break
;
break
;
}
}
}
}
char
*
pymalloc
=
Py_GETENV
(
"PYTHONMALLOC"
);
if
(
_PyMem_SetupAllocators
(
pymalloc
)
<
0
)
{
fprintf
(
stderr
,
"Error in PYTHONMALLOC: unknown allocator
\"
%s
\"
!
\n
"
,
pymalloc
);
exit
(
1
);
}
/* Initialize the core language runtime */
Py_IgnoreEnvironmentFlag
=
core_config
.
ignore_environment
;
core_config
.
_disable_importlib
=
0
;
_Py_InitializeCore
(
&
core_config
);
/* Reprocess the command line with the language runtime available */
/* Reprocess the command line with the language runtime available */
if
(
read_command_line
(
argc
,
argv
,
&
cmdline
))
{
if
(
read_command_line
(
argc
,
argv
,
&
cmdline
))
{
return
usage
(
2
,
argv
[
0
]);
return
usage
(
2
,
argv
[
0
]);
...
@@ -680,6 +680,7 @@ Py_Main(int argc, wchar_t **argv)
...
@@ -680,6 +680,7 @@ Py_Main(int argc, wchar_t **argv)
for
(
i
=
0
;
i
<
PyList_GET_SIZE
(
cmdline
.
warning_options
);
i
++
)
{
for
(
i
=
0
;
i
<
PyList_GET_SIZE
(
cmdline
.
warning_options
);
i
++
)
{
PySys_AddWarnOptionUnicode
(
PyList_GET_ITEM
(
cmdline
.
warning_options
,
i
));
PySys_AddWarnOptionUnicode
(
PyList_GET_ITEM
(
cmdline
.
warning_options
,
i
));
}
}
Py_DECREF
(
cmdline
.
warning_options
);
}
}
stdin_is_interactive
=
Py_FdIsInteractive
(
stdin
,
(
char
*
)
0
);
stdin_is_interactive
=
Py_FdIsInteractive
(
stdin
,
(
char
*
)
0
);
...
@@ -767,9 +768,10 @@ Py_Main(int argc, wchar_t **argv)
...
@@ -767,9 +768,10 @@ Py_Main(int argc, wchar_t **argv)
#else
#else
Py_SetProgramName
(
argv
[
0
]);
Py_SetProgramName
(
argv
[
0
]);
#endif
#endif
Py_Initialize
();
if
(
_Py_InitializeMainInterpreter
(
1
))
Py_XDECREF
(
cmdline
.
warning_options
);
Py_FatalError
(
"Py_Main: Py_InitializeMainInterpreter failed"
);
/* TODO: Move this to _PyRun_PrepareMain */
if
(
!
Py_QuietFlag
&&
(
Py_VerboseFlag
||
if
(
!
Py_QuietFlag
&&
(
Py_VerboseFlag
||
(
cmdline
.
command
==
NULL
&&
cmdline
.
filename
==
NULL
&&
(
cmdline
.
command
==
NULL
&&
cmdline
.
filename
==
NULL
&&
cmdline
.
module
==
NULL
&&
stdin_is_interactive
)))
{
cmdline
.
module
==
NULL
&&
stdin_is_interactive
)))
{
...
@@ -779,6 +781,7 @@ Py_Main(int argc, wchar_t **argv)
...
@@ -779,6 +781,7 @@ Py_Main(int argc, wchar_t **argv)
fprintf
(
stderr
,
"%s
\n
"
,
COPYRIGHT
);
fprintf
(
stderr
,
"%s
\n
"
,
COPYRIGHT
);
}
}
/* TODO: Move this to _Py_InitializeMainInterpreter */
if
(
cmdline
.
command
!=
NULL
)
{
if
(
cmdline
.
command
!=
NULL
)
{
/* Backup _PyOS_optind and force sys.argv[0] = '-c' */
/* Backup _PyOS_optind and force sys.argv[0] = '-c' */
_PyOS_optind
--
;
_PyOS_optind
--
;
...
...
Python/bootstrap_hash.c
Dosyayı görüntüle @
1abcf670
...
@@ -599,11 +599,11 @@ init_hash_secret(int use_hash_seed,
...
@@ -599,11 +599,11 @@ init_hash_secret(int use_hash_seed,
}
}
void
void
_Py_HashRandomization_Init
(
void
)
_Py_HashRandomization_Init
(
_PyCoreConfig
*
core_config
)
{
{
char
*
seed_text
;
char
*
seed_text
;
int
use_hash_seed
=
-
1
;
int
use_hash_seed
=
core_config
->
use_hash_seed
;
unsigned
long
hash_seed
;
unsigned
long
hash_seed
=
core_config
->
hash_seed
;
if
(
use_hash_seed
<
0
)
{
if
(
use_hash_seed
<
0
)
{
seed_text
=
Py_GETENV
(
"PYTHONHASHSEED"
);
seed_text
=
Py_GETENV
(
"PYTHONHASHSEED"
);
...
@@ -611,6 +611,8 @@ _Py_HashRandomization_Init(void)
...
@@ -611,6 +611,8 @@ _Py_HashRandomization_Init(void)
Py_FatalError
(
"PYTHONHASHSEED must be
\"
random
\"
or an integer "
Py_FatalError
(
"PYTHONHASHSEED must be
\"
random
\"
or an integer "
"in range [0; 4294967295]"
);
"in range [0; 4294967295]"
);
}
}
core_config
->
use_hash_seed
=
use_hash_seed
;
core_config
->
hash_seed
=
hash_seed
;
}
}
init_hash_secret
(
use_hash_seed
,
hash_seed
);
init_hash_secret
(
use_hash_seed
,
hash_seed
);
}
}
...
...
Python/pylifecycle.c
Dosyayı görüntüle @
1abcf670
This diff is collapsed.
Click to expand it.
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