summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137)Artem Chernyshev2024-02-081-0/+4
| | | | Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
* gh-113039: Avoid using leading dots in the include path for frozen ↵Itamar Oren2023-12-181-1/+1
| | | | getpath.py (GH-113022)
* gh-86179: Avoid making case-only changes when calculating realpath() during ↵Steve Dower2023-12-141-2/+11
| | | | initialization (GH-113077)
* gh-86179: Implement realpath() on Windows for getpath.py calculations ↵Steve Dower2023-12-131-0/+39
| | | | (GH-113033)
* gh-59703: restore include of mach-o/dyld.h (gh-112309)Ned Deily2023-11-221-0/+1
| | | | On older versions of macOS, _NSGetExecutablePath appears to only be available via macho-o/dyld so macho-o/dyld.h is still needed.
* gh-59703: use the system dladdr function in getpath.c for macOS framework ↵AN Long2023-11-211-11/+6
| | | | | builds (GH-111546) Co-authored-by: Ned Deily <nad@python.org>
* gh-108082: Use PyErr_FormatUnraisable() (GH-111580)Serhiy Storchaka2023-11-021-4/+3
| | | | | | Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-031-1/+2
| | | | | | Add PyThreadState_GetUnchecked() function: similar to PyThreadState_Get(), but don't issue a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, this function was private and known as _PyThreadState_UncheckedGet().
* 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