| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Modify locale.localeconv(), time.tzname, os.strerror() and other
functions to ignore the UTF-8 Mode: always use the current locale
encoding.
Changes:
* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or
encoding error, they return the position of the error and an error
message which are used to raise Unicode errors in
PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale().
* Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx().
* PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all
cases, especially for the strict error handler.
* Add _Py_DecodeUTF8Ex(): return more information on decoding error
and supports the strict error handler.
* Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex().
* Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx().
* Ignore the UTF-8 mode to encode/decode localeconv(), strerror()
and time zone name.
* Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize()
and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use
the "current" locale.
* Remove _PyUnicode_DecodeCurrentLocale(),
_PyUnicode_DecodeCurrentLocaleAndSize() and
_PyUnicode_EncodeCurrentLocale().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a new _Py_FindEnvConfigValue() function: code shared between
Windows and Unix implementations of _PyPathConfig_Calculate() to read
the pyenv.cfg file.
_Py_FindEnvConfigValue() now uses _Py_DecodeUTF8_surrogateescape()
instead of using a Python Unicode string, the Python API must not be
used early during Python initialization. Same change in Unix
search_for_exec_prefix(): use _Py_DecodeUTF8_surrogateescape().
Cleanup also encode_current_locale(): PyMem_RawFree/PyMem_Free can be
called with NULL.
Fix also "NUL byte" => "NULL byte" typo.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace Py_EncodeLocale() with _Py_EncodeLocaleRaw() in:
* _Py_wfopen()
* _Py_wreadlink()
* _Py_wrealpath()
* _Py_wstat()
* pymain_open_filename()
These functions are called early during Python intialization, only
the RAW memory allocator must be used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
bpo-29240, bpo-32030: If the encoding change (C locale coerced or
UTF-8 Mode changed), Py_Main() now reads again the configuration with
the new encoding.
Changes:
* Add _Py_UnixMain() called by main().
* Rename pymain_free_pymain() to pymain_clear_pymain(), it can now be
called multipled times.
* Rename pymain_parse_cmdline_envvars() to pymain_read_conf().
* Py_Main() now clears orig_argc and orig_argv at exit.
* Remove argv_copy2, Py_Main() doesn't modify argv anymore. There is
no need anymore to get two copies of the wchar_t** argv.
* _PyCoreConfig: add coerce_c_locale and coerce_c_locale_warn.
* Py_UTF8Mode is now initialized to -1.
* Locale coercion (PEP 538) now respects -I and -E options.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
_PyMainInterpreterConfig now contains Python objects, whereas
_PyCoreConfig contains wchar_t* strings.
Core config:
* Rename _PyMainInterpreterConfig_ReadEnv() to _PyCoreConfig_ReadEnv()
* Move 3 strings from _PyMainInterpreterConfig to _PyCoreConfig:
module_search_path_env, home, program_name.
* Add _PyCoreConfig_Clear()
* _PyPathConfig_Calculate() now takes core config rather than main
config
* _PyMainInterpreterConfig_Read() now requires also a core config
Main config:
* Add _PyMainInterpreterConfig.module_search_path: sys.path list
* Add _PyMainInterpreterConfig.argv: sys.argv list
* _PyMainInterpreterConfig_Read() now computes module_search_path
|
|
|
|
| |
(#4748)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
bpo-32030. (#4681)" (#4694)
* Revert "bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)"
This reverts commit 13badcbc60cdbfae1dba1683fd2fae9d70717143.
Re-apply commits:
* "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)"
commit af5a895073c24637c094772b27526b94a12ec897.
* "bpo-32030: Fix config_get_program_name() on macOS (#4669)"
commit e23c06e2b03452c9aaf0dae52296c85e572f9bcd.
* "bpo-32030: Add Python/pathconfig.c (#4668)"
commit 0ea395ae964c9cd0f499e2ef0d0030c971201220.
* "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)"
commit ebac19dad6263141d5db0a2c923efe049dba99d2.
* "bpo-32030: Fix Py_GetPath(): init program_name (#4665)"
commit 9ac3d8882712c9675c3d2f9f84af6b5729575cde.
* Fix compilation error on macOS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Revert "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)"
This reverts commit af5a895073c24637c094772b27526b94a12ec897.
* Revert "bpo-32030: Fix config_get_program_name() on macOS (#4669)"
This reverts commit e23c06e2b03452c9aaf0dae52296c85e572f9bcd.
* Revert "bpo-32030: Add Python/pathconfig.c (#4668)"
This reverts commit 0ea395ae964c9cd0f499e2ef0d0030c971201220.
* Revert "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)"
This reverts commit ebac19dad6263141d5db0a2c923efe049dba99d2.
* Revert "bpo-32030: Fix Py_GetPath(): init program_name (#4665)"
This reverts commit 9ac3d8882712c9675c3d2f9f84af6b5729575cde.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
_PyPathConfig_Init() now also initialize home and program_name:
* Rename existing _PyPathConfig_Init() to _PyPathConfig_Calculate().
Add a new _PyPathConfig_Init() function in pathconfig.c which
handles the _Py_path_config variable and call
_PyPathConfig_Calculate().
* Add home and program_name fields to _PyPathConfig.home
* _PyPathConfig_Init() now initialize home and program_name
from main_config
* Py_SetProgramName(), Py_SetPythonHome() and Py_GetPythonHome() now
calls Py_FatalError() on failure, instead of silently ignoring
failures.
* config_init_home() now gets directly _Py_path_config.home to only
get the value set by Py_SetPythonHome(), or NULL if
Py_SetPythonHome() was not called.
* config_get_program_name() now gets directly
_Py_path_config.program_name to only get the value set by
Py_SetProgramName(), or NULL if Py_SetProgramName() was not called.
* pymain_init_python() doesn't call Py_SetProgramName() anymore,
_PyPathConfig_Init() now always sets the program name
* Call _PyMainInterpreterConfig_Read() in
pymain_parse_cmdline_envvars_impl() to control the memory allocator
* C API documentation: it's no more safe to call Py_GetProgramName()
before Py_Initialize().
|
|
|
|
|
|
|
| |
* Factorize code from PC/getpathp.c and Modules/getpath.c to remove
duplicated code
* rename pathconfig_clear() to _PyPathConfig_Clear()
* Inline _PyPathConfig_Fini() in pymain_impl() and then remove it,
since it's a oneliner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Changes:
* _PyPathConfig_Fini() cannot be called in Py_FinalizeEx().
Py_Initialize() and Py_Finalize() can be called multiple times, but
it must not "forget" parameters set by Py_SetProgramName(),
Py_SetPath() or Py_SetPythonHome(), whereas _PyPathConfig_Fini()
clear all these parameters.
* config_get_program_name() and calculate_program_full_path() now
also decode paths using Py_DecodeLocale() to use the
surrogateescape error handler, rather than decoding using
mbstowcs() which is strict.
* Change _Py_CheckPython3() prototype: () => (void)
* Truncate a few lines which were too long
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* _PyMainInterpreterConfig_ReadEnv() now sets program_name from
environment variables and pymain_parse_envvars() implements the
falls back on argv[0].
* Remove _PyMain.program_name: use the program_name from
_PyMainInterpreterConfig
* Move the Py_SetProgramName() call back to pymain_init_python(),
just before _Py_InitializeCore().
* pathconfig_global_init() now also calls
_PyMainInterpreterConfig_Read() to set program_name if it isn't set
yet
* Cleanup PyCalculatePath: pass main_config to subfunctions to get
directly fields from main_config (home, module_search_path_env and
program_name)
|
|
|
|
|
|
|
|
|
|
| |
* Rename PyPathConfig structure to _PyPathConfig and move it to
Include/internal/pystate.h
* Rename path_config to _Py_path_config
* _PyPathConfig: Rename program_name field to program_full_path
* Add assert(str != NULL); to _PyMem_RawWcsdup(), _PyMem_RawStrdup()
and _PyMem_Strdup().
* Rename calculate_path() to pathconfig_global_init(). The function
now does nothing if it's already initiallized.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add _PyPathConfig_Init() and _PyPathConfig_Fini()
* Remove _Py_GetPathWithConfig()
* _PyPathConfig_Init() returns _PyInitError to allow to handle errors
properly
* Add pathconfig_clear()
* Windows calculate_path_impl(): replace Py_FatalError() with
_PyInitError
* Py_FinalizeEx() now calls _PyPathConfig_Fini() to release memory
* Fix _Py_InitializeMainInterpreter() regression: don't initialize
path config if _disable_importlib is false
* PyPathConfig now uses dynamically allocated memory
|
|
|
|
|
|
| |
* Py_Main() now calls Py_SetProgramName() earlier to be able to get
the program name in _PyMainInterpreterConfig_ReadEnv().
* Rename prog to program_name
* Rename progpath to program_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Py_GetPath() and Py_Main() now call
_PyMainInterpreterConfig_ReadEnv() to share the same code to get
environment variables.
Changes:
* Add _PyMainInterpreterConfig_ReadEnv()
* Add _PyMainInterpreterConfig_Clear()
* Add _PyMem_RawWcsdup()
* _PyMainInterpreterConfig: rename pythonhome to home
* Rename _Py_ReadMainInterpreterConfig() to
_PyMainInterpreterConfig_Read()
* Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding
errors: the user is able to fix the issue, it's not a bug in
Python. Same change was made in _Py_INIT_NO_MEMORY().
* Remove _Py_GetPythonHomeWithConfig()
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* calculate_path() rewritten in Modules/getpath.c and PC/getpathp.c
* Move global variables into a new PyPathConfig structure.
* calculate_path():
* Split the huge calculate_path() function into subfunctions.
* Add PyCalculatePath structure to pass data between subfunctions.
* Document PyCalculatePath fields.
* Move cleanup code into a new calculate_free() subfunction
* calculate_init() now handles Py_DecodeLocale() failures properly
* calculate_path() is now atomic: only replace PyPathConfig
(path_config) at once on success.
* _Py_GetPythonHomeWithConfig() now returns an error on failure
* Add _Py_INIT_NO_MEMORY() helper: report a memory allocation failure
* Coding style fixes (PEP 7)
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Py_Main() now reads the PYTHONHOME environment variable
* Add _Py_GetPythonHomeWithConfig() private function
* Add _PyWarnings_InitWithConfig()
* init_filters() doesn't get the current core configuration from the
current interpreter or Python thread anymore. Pass explicitly the
configuration to _PyWarnings_InitWithConfig().
* _Py_InitializeCore() now fails on _PyWarnings_InitWithConfig()
failure.
* Pass configuration as constant
|
|
|
|
| |
Move _PyCoreConfig.module_search_path_env to _PyMainInterpreterConfig
structure.
|
|
|
|
|
|
|
|
|
|
|
| |
Changes:
* Py_Main() initializes _PyCoreConfig.module_search_path_env from
the PYTHONPATH environment variable.
* PyInterpreterState_New() now initializes core_config and config
fields
* Compute sys.path a little bit ealier in
_Py_InitializeMainInterpreter() and new_interpreter()
* Add _Py_GetPathWithConfig() private function.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix a memory corruption in getpath.c due to mixed memory allocators
between Py_GetPath() and Py_SetPath().
The fix use the Raw allocator to mimic the windows version.
This patch should be used from python3.6 to the current version
for more details, see the bug report and
https://github.com/pyinstaller/pyinstaller/issues/2812
|
|\
| |
| |
| |
| | |
empty compile-time PYTHONPATH components. This fixes some tests in -S or -I
modes.
|
| |
| |
| |
| |
| | |
empty compile-time PYTHONPATH components. This fixes some tests in -S or -I
modes.
|
|\ \
| |/ |
|
| | |
|
|/ |
|
|
|
|
|
|
| |
The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
|
|
|
|
|
|
|
| |
I expected more users of _Py_wstat(), but in practice it's only used by
Modules/getpath.c. Move the function because it's not needed on Windows.
Windows uses PC/getpathp.c which uses the Win32 API (ex: GetFileAttributesW())
not the POSIX API.
|
|\
| |
| |
| | |
overflows. Added few missed PyErr_NoMemory().
|
| |
| |
| |
| | |
overflows. Added few missed PyErr_NoMemory().
|
|\ \
| |/ |
|
| |
| |
| |
| |
| |
| | |
directory to sys.path when running from a build directory. That has
proven to be problematic for several standard library modules with
C extension modules whose builds can fail on some platforms.
|
|/
|
|
|
| |
``_Py_wchar2char()`` to :c:func:`Py_EncodeLocale`, and document these
functions.
|
|
|
|
| |
Original patch by Thomas Wouters.
|
| |
|
|
|
|
| |
for module_search_path. It was already the case on _Py_char2wchar() failure.
|
|
|
|
|
|
|
| |
_Py_char2wchar() to decode lib_python instead.
Some compilers don't support concatenating literals: L"wide" "bytes". Example:
IRIX compiler.
|
|\
| |
| |
| | |
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
|
| |
| |
| |
| | |
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
|
| |
| |
| |
| |
| |
| |
| | |
* Replace malloc() with PyMem_RawMalloc()
* Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held.
* _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead
of PyMem_Malloc()
|
|/
|
|
|
|
| |
all.
Thanks to Armin Rigo and Alexey Kachayev.
|
|
|
|
| |
Patch by Ronald Oussoren.
|
| |
|
|
|
|
|
|
| |
encoding using _Py_char2wchar() instead of mbstowcs() to store undecodable
bytes as surrogates characters (PEP 383) instead of ignoring silently
the PYTHONPATH variable.
|
|
|
|
| |
possible crash when calling Py_SetPath()
|
| |
|
|
|
|
|
|
| |
PyUnicode_AsWideChar() result is signed, whereas it was stored in a unsigned
variable, and then the test was "n >= 0" which is always true to an unsigned
number. Patch written by Hallvard B Furuseth.
|
|
|
|
|
| |
_Py_char2wchar(), instead of L"" VAR hack, to escape undecodable bytes using
the surrogateescape error handler.
|
|
|
|
|
|
| |
Instead of casting it to wchar_t* without conversion. It fixes a bug if Python
is compiled a non-ascii directory, different than the source code directory,
with C locale.
|