summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863)Victor Stinner2023-09-041-0/+1
| | | | | | Move the private _PyErr_WriteUnraisableMsg() functions to the internal C API (pycore_pyerrors.h). Move write_unraisable_exc() from _testcapi to _testinternalcapi.
* gh-107913: Fix possible losses of OSError error codes (GH-107930)Serhiy Storchaka2023-08-261-1/+2
| | | | | | Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code.
* gh-89745: Remove commented code in getpath.c (#108307)Victor Stinner2023-08-221-18/+0
|
* gh-106320: Remove private _PyMem API (#107187)Victor Stinner2023-07-241-3/+5
| | | | | | | | | | | | | Move private _PyMem functions to the internal C API (pycore_pymem.h): * _PyMem_GetCurrentAllocatorName() * _PyMem_RawStrdup() * _PyMem_RawWcsdup() * _PyMem_Strdup() No longer export these functions. Move pymem_getallocatorsname() function from _testcapi to _testinternalcapi, since the API moved to the internal C API.
* remove unused #includes of pycore_pymem.h (#105166)Irit Katriel2023-06-011-1/+0
|
* gh-102281: Fix potential nullptr dereference + use of uninitialized memory ↵Max Bachmann2023-03-151-1/+4
| | | | (gh-102282)
* gh-102255: Improve build support for Windows API partitions (GH-102256)Max Bachmann2023-03-091-0/+2
| | | | | Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs). CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes. `MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
* gh-102336: Remove code specifically for handling Windows 7 (GH-102337)Max Bachmann2023-03-011-3/+2
|
* gh-99300: Use Py_NewRef() in Modules/ directory (#99469)Victor Stinner2022-11-141-19/+10
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-97758: Fix a crash in getpath_joinpath() called without arguments (GH-97759)Serhiy Storchaka2022-10-051-1/+1
|
* gh-94526: getpath_dirname() no longer encodes the path (#97645)Victor Stinner2022-09-301-9/+14
| | | | | | | | | | | Fix the Python path configuration used to initialized sys.path at Python startup. Paths are no longer encoded to UTF-8/strict to avoid encoding errors if it contains surrogate characters (bytes paths are decoded with the surrogateescape error handler). getpath_basename() and getpath_dirname() functions no longer encode the path to UTF-8/strict, but work directly on Unicode strings. These functions now use PyUnicode_FindChar() and PyUnicode_Substring() on the Unicode path, rather than strrchr() on the encoded bytes string.
* bpo-46890: Fix setting of sys._base_executable with framework builds on ↵Ronald Oussoren2022-04-051-0/+6
| | | | | | | | | macOS (GH-31958) The side effect of this bug was that venv environments directly used the main interpreter instead of the intermediate stub executable, which can cause problems when a script uses system APIs that require the use of an application bundle.
* bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)neonene2022-01-131-3/+3
| | | This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
* bpo-46049: Fixes ._pth support on non-Windows (GH-30051)Steve Dower2021-12-111-1/+1
|
* bpo-46048: Fix parsing of single character lines in getpath readlines() ↵Steve Dower2021-12-111-3/+3
| | | | (GH-30048)
* bpo-46015: Fixes calculation of sys.path in a venv on Windows (GH-29992)Steve Dower2021-12-081-1/+1
| | | Also ensures that pybuilddir.txt is written early enough in the build to be picked up by later steps.
* bpo-45582: Fix framework path and bootstrap build (GH-29954)Christian Heimes2021-12-071-9/+12
| | | | | | | * Check NS API return values for NULL to prevent segfault in ``_bootstrap_python``. * Set modPathInitialized to 1 so the ``decode_to_dict`` path is used. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-45582: framework build: modPath must not be const (GH-29944)Christian Heimes2021-12-061-1/+1
| | | Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
* bpo-45582: Fix getpath_isxfile() and test_embed on Windows (GH-29930)neonene2021-12-061-1/+1
|
* bpo-45950: Fix macOS framework builds of _bootstrap_python (GH-29936)Christian Heimes2021-12-061-1/+2
|
* bpo-45582: Fix signature of _Py_Get_Getpath_CodeObject (GH-29921)Christian Heimes2021-12-051-1/+1
|
* bpo-45582: Add a NOT operator to the condition in getpath_isxfile (GH-29906)neonene2021-12-031-3/+9
|
* bpo-45582: Fix out-of-tree build issues with new getpath (GH-29902)Christian Heimes2021-12-031-1/+1
|
* bpo-45582: Port getpath[p].c to Python (GH-29041)Steve Dower2021-12-031-1397/+715
| | | | | The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code. This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
* bpo-45506: Normalize _PyPathConfig.stdlib_dir when calculated. (#29040)Eric Snow2021-10-221-6/+40
| | | | | The recently added PyConfig.stdlib_dir was being set with ".." entries. When __file__ was added for from modules this caused a problem on out-of-tree builds. This PR fixes that by normalizing "stdlib_dir" when it is calculated in getpath.c. https://bugs.python.org/issue45506
* bpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)Victor Stinner2021-10-131-1/+2
| | | | | Include <stdlib.h> explicitly in C files. Python.h includes <wchar.h>.
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* bpo-45211: Remember the stdlib dir during startup. (gh-28586)Eric Snow2021-09-281-0/+10
| | | | | During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211
* bpo-45211: Move helpers from getpath.c to internal API. (gh-28550)Eric Snow2021-09-271-56/+8
| | | | | | | | | | | | This accomplishes 2 things: * consolidates some common code between getpath.c and getpathp.c * makes the helpers available to code in other files FWIW, the signature of the join_relfile() function (in fileutils.c) intentionally mirrors that of Windows' PathCchCombineEx(). Note that this change is mostly moving code around. No behavior is meant to change. https://bugs.python.org/issue45211
* bpo-44285: getpath.c: Assert that env_file is NULL during an error check ↵stratakis2021-06-021-0/+1
| | | | | (GH-26486) This was flagged by a static analyzer, but the logic of why this is NULL on error is hard to follow for humans as well.
* bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)Ronald Oussoren2020-11-081-4/+0
| | | | | | | | | | | Co-authored-by: Lawrence D’Anna <lawrence_danna@apple.com> * Add support for macOS 11 and Apple Silicon (aka arm64) As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy * Support building on recent versions of macOS while deploying to older versions This allows building installers on macOS 11 while still supporting macOS 10.9.
* bpo-40947: getpath.c uses PyConfig.platlibdir (GH-20807)Victor Stinner2020-06-111-11/+20
| | | | | | | | | | | Followup of bpo-40854, there is one remaining usage of PLATLIBDIR which should be replaced by config->platlibdir. test_sys checks that sys.platlibdir attribute exists and is a string. Update Makefile: getpath.c and sysmodule.c no longer need PLATLIBDIR macro, PyConfig.platlibdir member is used instead. Co-authored-by: Sandro Mani <manisandro@gmail.com>
* bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var ↵Sandro Mani2020-06-081-10/+6
| | | | (GH-20605)
* bpo-37616: Handle version information more gracefully in getpath.c (GH-20214)Pablo Galindo2020-05-191-9/+3
|
* Python 3.10.0a0 (GH-20198)Pablo Galindo2020-05-191-5/+6
|
* bpo-40268: Remove unused osdefs.h includes (GH-19532)Victor Stinner2020-04-151-1/+1
| | | When the include is needed, add required symbol in a comment.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-3/+2
|
* bpo-1294959: Add sys.platlibdir attribute (GH-18381)Victor Stinner2020-03-101-12/+40
| | | | | | | | | | | | | Add --with-platlibdir option to the configure script: name of the platform-specific library directory, stored in the new sys.platlitdir attribute. It is used to build the path of platform-specific dynamic libraries and the path of the standard library. It is equal to "lib" on most platforms. On Fedora and SuSE, it is equal to "lib64" on 64-bit systems. Co-Authored-By: Jan Matějek <jmatejek@suse.com> Co-Authored-By: Matěj Cepl <mcepl@cepl.eu> Co-Authored-By: Charalampos Stratakis <cstratak@redhat.com>
* bpo-38353: Fix typos in calculate_argv0_path_framework() (GH-16695)Victor Stinner2019-10-101-4/+4
| | | | | bpo-38353, bpo-38429: Fix typos introduced by commit c02b41b1fb115c87693530ea6a480b2e15460424 in calculate_argv0_path_framework() of getpath.c.
* bpo-38353: Simplify calculate_pybuilddir() (GH-16614)Victor Stinner2019-10-071-5/+0
| | | | Calling _Py_wfopen() is enough to check if filename is an existing file or not. There is no need to check first isfile().
* bpo-38353: getpath.c: allocates strings on the heap (GH-16585)Victor Stinner2019-10-041-295/+383
| | | | | | | | | | | * _Py_FindEnvConfigValue() now returns a string allocated by PyMem_RawMalloc(). * calculate_init() now decodes VPATH macro. * Add calculate_open_pyenv() function. * Add substring() and joinpath2() functions. * Fix add_exe_suffix() And a few cleanup changes.
* bpo-38353: getpath.c uses dynamically allocated strings (GH-16582)Victor Stinner2019-10-041-91/+115
| | | | * PyCalculatePath: add "_macro" to the 3 fields storing macro values * Add dynamically allocated strings to PyCalculatePath
* bpo-38353: Rework ismodule() in getpath.c (GH-16574)Victor Stinner2019-10-041-64/+80
| | | | * ismodule() no longer modify the input string. * copy_absolute(), joinpath(): rename parameters and local variables.
* bpo-38353: Add subfunctions to getpath.c (GH-16572)Victor Stinner2019-10-041-153/+259
| | | | | | | | | | | | | | Following symbolic links is now limited to 40 attempts, just to prevent loops. Add subfunctions: * Add resolve_symlinks() * Add calculate_argv0_path_framework() * Add calculate_which() * Add calculate_program_macos() Fix also _Py_wreadlink(): readlink() result type is Py_ssize_t, not int.
* bpo-38353: Fix calculate_argv0_path() for symlinks (GH-16549)Victor Stinner2019-10-031-1/+1
| | | | calculate_argv0_path() must read argv0_path link, not read program_full_path link.
* bpo-38234: Cleanup getpath.c (GH-16367)Victor Stinner2019-09-251-73/+116
| | | | | | | | | * search_for_prefix() directly calls reduce() if found is greater than 0. * Add calculate_pybuilddir() subfunction. * search_for_prefix(): add path string buffer for readability. * Fix some error handling code paths: release resources on error. * calculate_read_pyenv(): rename tmpbuffer to filename. * test.pythoninfo now also logs windows.dll_path
* bpo-38234: Add tests for Python init path config (GH-16358)Victor Stinner2019-09-241-3/+3
|
* bpo-38234: read_pth_file() now returns PyStatus (GH-16338)Victor Stinner2019-09-231-79/+112
| | | | | | | | | Refactor path configuration code: * read_pth_file() now returns PyStatus to report errors, rather than calling Py_FatalError(). * Move argv0_path and zip_path buffers out of PyCalculatePath structures. * On Windows, _PyPathConfig.home is now preferred over PyConfig.home.
* bpo-38234: Fix _PyConfig_InitPathConfig() (GH-16335)Victor Stinner2019-09-231-62/+78
| | | | | | | | | | | | | | | | * _PyConfig_InitPathConfig() now starts by copying the global path configuration, and then override values set in PyConfig. * _PyPathConfig_Calculate() implementations no longer override _PyPathConfig fields which are already computed. For example, if _PyPathConfig.prefix is not NULL, leave it unchanged. * If Py_SetPath() has been called, _PyConfig_InitPathConfig() doesn't call _PyPathConfig_Calculate() anymore. * _PyPathConfig_Calculate() no longer uses PyConfig, except to initialize PyCalculatePath structure. * pathconfig_calculate(): remove useless temporary "_PyPathConfig new_config" variable. * calculate_module_search_path(): remove hack to workaround memory allocation failure, call Py_FatalError() instead. * Fix get_program_full_path(): handle memory allocation failure.
* bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298)Victor Stinner2019-09-201-4/+6
| | | | | | * If Py_SetPath() has been called, _PyConfig_InitPathConfig() now uses its value. * Py_Initialize() now longer copies path configuration from PyConfig to the global path configuration (_Py_path_config).