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
177a41a0
Unverified
Kaydet (Commit)
177a41a0
authored
Kas 18, 2018
tarafından
Steve Dower
Kaydeden (comit)
GitHub
Kas 18, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34725: Adds _Py_SetProgramFullPath so embedders may override sys.executable (GH-9860)
üst
689d555e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
33 deletions
+74
-33
pycore_pathconfig.h
Include/internal/pycore_pathconfig.h
+1
-2
pylifecycle.h
Include/pylifecycle.h
+11
-7
2018-10-13-16-30-54.bpo-34725.j52rIS.rst
...EWS.d/next/C API/2018-10-13-16-30-54.bpo-34725.j52rIS.rst
+1
-0
getpathp.c
PC/getpathp.c
+4
-0
coreconfig.c
Python/coreconfig.c
+24
-0
pathconfig.c
Python/pathconfig.c
+33
-24
No files found.
Include/internal/pycore_pathconfig.h
Dosyayı görüntüle @
177a41a0
...
...
@@ -26,10 +26,9 @@ typedef struct _PyPathConfig {
/* Full path to the Python program */
wchar_t
*
program_full_path
;
wchar_t
*
prefix
;
wchar_t
*
exec_prefix
;
#ifdef MS_WINDOWS
wchar_t
*
dll_path
;
#else
wchar_t
*
exec_prefix
;
#endif
/* Set by Py_SetPath(), or computed by _PyPathConfig_Init() */
wchar_t
*
module_search_path
;
...
...
Include/pylifecycle.h
Dosyayı görüntüle @
177a41a0
...
...
@@ -7,12 +7,6 @@
extern
"C"
{
#endif
PyAPI_FUNC
(
void
)
Py_SetProgramName
(
const
wchar_t
*
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetProgramName
(
void
);
PyAPI_FUNC
(
void
)
Py_SetPythonHome
(
const
wchar_t
*
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetPythonHome
(
void
);
#ifndef Py_LIMITED_API
/* Only used by applications that embed the interpreter and need to
* override the standard encoding determination mechanism
...
...
@@ -83,8 +77,18 @@ PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
/* Bootstrap __main__ (defined in Modules/main.c) */
PyAPI_FUNC
(
int
)
Py_Main
(
int
argc
,
wchar_t
**
argv
);
/* In getpath.c */
/* In pathconfig.c */
PyAPI_FUNC
(
void
)
Py_SetProgramName
(
const
wchar_t
*
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetProgramName
(
void
);
PyAPI_FUNC
(
void
)
Py_SetPythonHome
(
const
wchar_t
*
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetPythonHome
(
void
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
void
)
_Py_SetProgramFullPath
(
const
wchar_t
*
);
#endif
PyAPI_FUNC
(
wchar_t
*
)
Py_GetProgramFullPath
(
void
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetPrefix
(
void
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetExecPrefix
(
void
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetPath
(
void
);
...
...
Misc/NEWS.d/next/C API/2018-10-13-16-30-54.bpo-34725.j52rIS.rst
0 → 100644
Dosyayı görüntüle @
177a41a0
Adds _Py_SetProgramFullPath so embedders may override sys.executable
PC/getpathp.c
Dosyayı görüntüle @
177a41a0
...
...
@@ -982,6 +982,10 @@ done:
if
(
config
->
prefix
==
NULL
)
{
return
_Py_INIT_NO_MEMORY
();
}
config
->
exec_prefix
=
_PyMem_RawWcsdup
(
prefix
);
if
(
config
->
exec_prefix
==
NULL
)
{
return
_Py_INIT_NO_MEMORY
();
}
return
_Py_INIT_OK
();
}
...
...
Python/coreconfig.c
Dosyayı görüntüle @
177a41a0
...
...
@@ -662,6 +662,23 @@ config_init_program_name(_PyCoreConfig *config)
return
_Py_INIT_OK
();
}
static
_PyInitError
config_init_executable
(
_PyCoreConfig
*
config
)
{
assert
(
config
->
executable
==
NULL
);
/* If Py_SetProgramFullPath() was called, use its value */
const
wchar_t
*
program_full_path
=
_Py_path_config
.
program_full_path
;
if
(
program_full_path
!=
NULL
)
{
config
->
executable
=
_PyMem_RawWcsdup
(
program_full_path
);
if
(
config
->
executable
==
NULL
)
{
return
_Py_INIT_NO_MEMORY
();
}
return
_Py_INIT_OK
();
}
return
_Py_INIT_OK
();
}
static
const
wchar_t
*
config_get_xoption
(
const
_PyCoreConfig
*
config
,
wchar_t
*
name
)
...
...
@@ -1370,6 +1387,13 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
}
}
if
(
config
->
executable
==
NULL
)
{
err
=
config_init_executable
(
config
);
if
(
_Py_INIT_FAILED
(
err
))
{
return
err
;
}
}
if
(
config
->
utf8_mode
<
0
||
config
->
coerce_c_locale
<
0
)
{
config_init_locale
(
config
);
}
...
...
Python/pathconfig.c
Dosyayı görüntüle @
177a41a0
...
...
@@ -49,10 +49,9 @@ _PyPathConfig_Clear(_PyPathConfig *config)
CLEAR
(
config
->
prefix
);
CLEAR
(
config
->
program_full_path
);
CLEAR
(
config
->
exec_prefix
);
#ifdef MS_WINDOWS
CLEAR
(
config
->
dll_path
);
#else
CLEAR
(
config
->
exec_prefix
);
#endif
CLEAR
(
config
->
module_search_path
);
CLEAR
(
config
->
home
);
...
...
@@ -74,8 +73,8 @@ _PyPathConfig_Calculate(_PyPathConfig *path_config,
PyMemAllocatorEx
old_alloc
;
_PyMem_SetDefaultAllocator
(
PYMEM_DOMAIN_RAW
,
&
old_alloc
);
/* Calculate program_full_path, prefix, exec_prefix
(Unix)
or
dll_path (Windows), and module_search_path */
/* Calculate program_full_path, prefix, exec_prefix
,
dll_path (Windows), and module_search_path */
err
=
_PyPathConfig_Calculate_impl
(
&
new_config
,
core_config
);
if
(
_Py_INIT_FAILED
(
err
))
{
goto
err
;
...
...
@@ -126,10 +125,9 @@ _PyPathConfig_SetGlobal(const _PyPathConfig *config)
COPY_ATTR
(
program_full_path
);
COPY_ATTR
(
prefix
);
COPY_ATTR
(
exec_prefix
);
#ifdef MS_WINDOWS
COPY_ATTR
(
dll_path
);
#else
COPY_ATTR
(
exec_prefix
);
#endif
COPY_ATTR
(
module_search_path
);
COPY_ATTR
(
program_name
);
...
...
@@ -208,12 +206,11 @@ _PyCoreConfig_SetPathConfig(const _PyCoreConfig *core_config)
if
(
copy_wstr
(
&
path_config
.
prefix
,
core_config
->
prefix
)
<
0
)
{
goto
no_memory
;
}
#ifdef MS_WINDOWS
if
(
copy_wstr
(
&
path_config
.
dll_path
,
core_config
->
dll_path
)
<
0
)
{
if
(
copy_wstr
(
&
path_config
.
exec_prefix
,
core_config
->
exec_prefix
)
<
0
)
{
goto
no_memory
;
}
#
else
if
(
copy_wstr
(
&
path_config
.
exec_prefix
,
core_config
->
exec_prefix
)
<
0
)
{
#
ifdef MS_WINDOWS
if
(
copy_wstr
(
&
path_config
.
dll_path
,
core_config
->
dll_path
)
<
0
)
{
goto
no_memory
;
}
#endif
...
...
@@ -317,12 +314,8 @@ _PyCoreConfig_CalculatePathConfig(_PyCoreConfig *config)
}
if
(
config
->
exec_prefix
==
NULL
)
{
#ifdef MS_WINDOWS
wchar_t
*
exec_prefix
=
path_config
.
prefix
;
#else
wchar_t
*
exec_prefix
=
path_config
.
exec_prefix
;
#endif
if
(
copy_wstr
(
&
config
->
exec_prefix
,
exec_prefix
)
<
0
)
{
if
(
copy_wstr
(
&
config
->
exec_prefix
,
path_config
.
exec_prefix
)
<
0
)
{
goto
no_memory
;
}
}
...
...
@@ -379,7 +372,8 @@ _PyCoreConfig_InitPathConfig(_PyCoreConfig *config)
}
if
(
config
->
base_exec_prefix
==
NULL
)
{
if
(
copy_wstr
(
&
config
->
base_exec_prefix
,
config
->
exec_prefix
)
<
0
)
{
if
(
copy_wstr
(
&
config
->
base_exec_prefix
,
config
->
exec_prefix
)
<
0
)
{
return
_Py_INIT_NO_MEMORY
();
}
}
...
...
@@ -435,12 +429,11 @@ Py_SetPath(const wchar_t *path)
int
alloc_error
=
(
new_config
.
program_full_path
==
NULL
);
new_config
.
prefix
=
_PyMem_RawWcsdup
(
L""
);
alloc_error
|=
(
new_config
.
prefix
==
NULL
);
new_config
.
exec_prefix
=
_PyMem_RawWcsdup
(
L""
);
alloc_error
|=
(
new_config
.
exec_prefix
==
NULL
);
#ifdef MS_WINDOWS
new_config
.
dll_path
=
_PyMem_RawWcsdup
(
L""
);
alloc_error
|=
(
new_config
.
dll_path
==
NULL
);
#else
new_config
.
exec_prefix
=
_PyMem_RawWcsdup
(
L""
);
alloc_error
|=
(
new_config
.
exec_prefix
==
NULL
);
#endif
new_config
.
module_search_path
=
_PyMem_RawWcsdup
(
path
);
alloc_error
|=
(
new_config
.
module_search_path
==
NULL
);
...
...
@@ -503,6 +496,26 @@ Py_SetProgramName(const wchar_t *program_name)
}
}
void
_Py_SetProgramFullPath
(
const
wchar_t
*
program_full_path
)
{
if
(
program_full_path
==
NULL
||
program_full_path
[
0
]
==
L'\0'
)
{
return
;
}
PyMemAllocatorEx
old_alloc
;
_PyMem_SetDefaultAllocator
(
PYMEM_DOMAIN_RAW
,
&
old_alloc
);
PyMem_RawFree
(
_Py_path_config
.
program_full_path
);
_Py_path_config
.
program_full_path
=
_PyMem_RawWcsdup
(
program_full_path
);
PyMem_SetAllocator
(
PYMEM_DOMAIN_RAW
,
&
old_alloc
);
if
(
_Py_path_config
.
program_full_path
==
NULL
)
{
Py_FatalError
(
"_Py_SetProgramFullPath() failed: out of memory"
);
}
}
wchar_t
*
Py_GetPath
(
void
)
...
...
@@ -523,12 +536,8 @@ Py_GetPrefix(void)
wchar_t
*
Py_GetExecPrefix
(
void
)
{
#ifdef MS_WINDOWS
return
Py_GetPrefix
();
#else
pathconfig_global_init
();
return
_Py_path_config
.
exec_prefix
;
#endif
}
...
...
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