Commit Graph

12902 Commits

Author SHA1 Message Date
MonadChains 9302e331c7
gh-94808: Add test coverage for PyObject_HasAttrString (#96627)
* gh-94808: Add test for HasAttrString

* Harmonize to Python C code style guidelines

* Add check to verify no exception thrown
2022-10-03 13:37:15 -07:00
Serhiy Storchaka 0ee9619a4c
gh-97728: Argument Clinic: Fix uninitialized variable in the Py_UNICODE converter (GH-97729)
It affects function os.system() on Windows and Windows-specific modules
winreg, _winapi, _overlapped, and _msi.
2022-10-03 10:42:54 +03:00
Guido van Rossum 63780f4599
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
2022-09-30 12:57:09 -07:00
Victor Stinner 9f2f1dd131
gh-94526: getpath_dirname() no longer encodes the path (#97645)
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.
2022-09-30 14:58:30 +02:00
Ofey Chan 83a3de4e06
gh-96348: Deprecate the 3-arg signature of coroutine.throw and generator.throw (GH-96428) 2022-09-30 09:43:02 +01:00
Michael Curran d79dd929ac
bpo-38748: Add ctypes test for stack corruption due to misaligned arguments (GH-26204) 2022-09-26 17:27:44 +01:00
chgnrdv 85752decbf
Fix typo in docstring and remove duplicate signal.h include in faulthandler.c (#96720)
This fix corrects a typo in dump_traceback_later function docstring and removes duplicate signal.h include directive
2022-09-26 18:12:19 +02:00
Kumar Aditya c8c0afc713
GH-78724: Initialize struct.Struct in __new__ (GH-94532)
Closes https://github.com/python/cpython/issues/75960
Closes https://github.com/python/cpython/issues/78724
2022-09-25 14:32:48 +01:00
Mark Dickinson f5f047aa62
gh-96735: Fix undefined behaviour in struct unpacking functions (#96739)
This PR fixes undefined behaviour in the struct module unpacking support functions `bu_longlong`, `lu_longlong`, `bu_int` and `lu_int`; thanks to @kumaraditya303 for finding these.

The fix is to accumulate the bytes in an unsigned integer type instead of a signed integer type, then to convert to the appropriate signed type. In cases where the width matches, that conversion will typically be compiled away to a no-op.
(Evidence from Godbolt: https://godbolt.org/z/5zvxodj64 .)

To make the conversions efficient, I've specialised the relevant functions for their output size: for `bu_longlong` and `lu_longlong`, this only entails checking that the output size is indeed `8`. But `bu_int` and `lu_int` were used for format sizes `2` and `4` - I've split those into two separate functions each.

No tests, because all of the affected cases are already exercised by the test suite.
2022-09-25 10:55:33 +01:00
Dong-hee Na 10e3d398c3
gh-97005: Update libexpat from 2.4.7 to 2.4.9 (gh-97006)
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2022-09-22 21:25:05 +09:00
Matthias Görgens cbdeda8ce7
gh-96821: Fix undefined behaviour in `_testcapimodule.c` (GH-96915)
* gh-96821: Assert for demonstrating undefined behaviour

* Fix UB

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-09-19 15:59:13 +08:00
adphrost a41ed975e8
GH-91049: Introduce set vectorcall field API for PyFunctionObject (GH-92257)
Co-authored-by: Andrew Frost <adfrost@fb.com>
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
2022-09-15 16:42:37 +01:00
Benjamin Peterson fd1e477f53
closes gh-96734: Update to Unicode 15.0.0. (GH-96809) 2022-09-13 15:45:12 -07:00
Mark Shannon 12c5f328d2
GH-96754: Check whether the interpreter frame is complete before creating frame object. (GH-96776) 2022-09-13 09:25:16 +01:00
Guido van Rossum df50938f58
GH-46412: More efficient bool() for ndbm/_gdbmmodule (#96692) 2022-09-08 19:32:40 -07:00
Victor Stinner c580a81af9
gh-96652: Fix faulthandler chained signal without sigaction() (#96666)
Fix the faulthandler implementation of faulthandler.register(signal,
chain=True) if the sigaction() function is not available: don't call
the previous signal handler if it's NULL.
2022-09-08 12:20:22 +02:00
Nikita Sobolev 2fd7246e97
gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642) 2022-09-07 20:13:07 +09:00
Dennis Sweeney 56d9cf7fc8
gh-96538: Fix refleak in _bisectmodule.c (gh-96619) 2022-09-06 19:37:18 -04:00
Mark Shannon 95e271b226
GH-96612: Skip incomplete frames in tracemalloc traces. (GH-96613) 2022-09-06 17:37:47 +01:00
Dennis Sweeney 9e35d05422
gh-96538: Move some type-checking out of bisect.bisect() loops (GH-96539) 2022-09-05 01:02:29 -04:00
Pablo Galindo Salgado 6d791a9736
gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)
⚠️  ⚠️ Note for reviewers, hackers and fellow systems/low-level/compiler engineers ⚠️ ⚠️ 

If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**. 

If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
2022-08-30 10:11:18 -07:00
TW 023c51d9d8
gh-69142: add %:z strftime format code (gh-95983)
datetime.isoformat generates the tzoffset with colons, but there
was no format code to make strftime output the same format.

for simplicity and consistency the %:z formatting behaves mostly
as %z, with the exception of adding colons. this includes the
dynamic behaviour of adding seconds and microseconds only when
needed (when not 0).

this fixes the still open "generate" part of this issue:

https://github.com/python/cpython/issues/69142

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-28 14:27:42 -07:00
Ansab Gillani 0ace820bec
fixes gh-96292: Fix Trivial Typo in cpython/Modules/atexitmodule.c (#96327) 2022-08-26 22:33:29 -07:00
Carl Friedrich Bolz-Tereick 9c197bc8bf
GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code points (#96207) 2022-08-26 19:29:39 +03:00
Christian Heimes 8c1dbad36f
gh-96269: Fix build dependency on AIX (GH-96304) 2022-08-26 12:31:58 +02:00
Mark Shannon c09fa7542c
GH-96237: Allow non-functions as reference-holder in frames. (GH-96238) 2022-08-25 10:16:55 +01:00
Irit Katriel 420f39f457
gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests (GH-96007) 2022-08-24 11:02:53 +01:00
Carl Friedrich Bolz-Tereick 2d9f252c0c
gh-96019: Fix caching of decompositions in makeunicodedata (GH-96020) 2022-08-19 12:20:44 +03:00
Petr Viktorin 0f2b469ce1
gh-95991: Add some infrastructure for testing Limited API in _testcapi (GH-95992)
- Limited API needs to be enabled per source file
- Some builds don't support Limited API, so Limited API tests must be skipped on those builds
  (currently this is `Py_TRACE_REFS`, but that may change.)
- `Py_LIMITED_API` must be defined before `<Python.h>` is included.

This puts the hoop-jumping in `testcapi/parts.h`, so individual
test files can be relatively simple. (Currently that's only
`vectorcall_limited.c`, imagine more.)
2022-08-17 13:48:43 +02:00
Christian Heimes 48174fa0b9
gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006)
- On WASI `ENOTCAPABLE` is now mapped to `PermissionError`.
- The `errno` modules exposes the new error number.
- `getpath.py` now ignores `PermissionError` when it cannot open landmark
  files `pybuilddir.txt` and `pyenv.cfg`.
2022-08-16 20:20:15 +02:00
Mark Shannon 5a8c15819c
GH-95245: Move weakreflist into the pre-header. (GH-95996) 2022-08-16 13:57:18 +01:00
Yury Selivanov b2afe482f2
gh-95808: Add missing early returns in _asynciomodule.c (#95809) 2022-08-15 16:32:40 -07:00
Christian Heimes 8621e6d43a
gh-95707: Fix function signature (GH-95995) 2022-08-15 15:06:28 +01:00
Mark Shannon 3ef3c6306d
GH-95707: Fix uses of `Py_TPFLAGS_MANAGED_DICT` (GH-95854)
* Make sure that tp_dictoffset is correct with Py_TPFLAGS_MANAGED_DICT is set.

* Avoid traversing managed dict twice when subclassing class with Py_TPFLAGS_MANAGED_DICT set.
2022-08-15 12:29:27 +01:00
Christian Heimes 4a7f5a55dc
gh-95853: Address wasm build and test issues (GH-95985) 2022-08-15 07:41:10 +02:00
Erlend E. Aasland f07adf82f3
gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
Eric Snow 6f6a4e6cc5
gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860)
We only statically initialize for core code and builtin modules.  Extension modules still create
the tuple at runtime.  We'll solve that part of interpreter isolation separately.

This change includes generated code. The non-generated changes are in:

* Tools/clinic/clinic.py
* Python/getargs.c
* Include/cpython/modsupport.h
* Makefile.pre.in (re-generate global strings after running clinic)
* very minor tweaks to Modules/_codecsmodule.c and Python/Python-tokenize.c

All other changes are generated code (clinic, global strings).
2022-08-11 15:25:49 -06:00
Christian Heimes 8b34e914bb
gh-95878: Fix format char in datetime CAPI tests (GH-95879) 2022-08-11 11:58:10 +02:00
Petr Viktorin 71c3d649b5
gh-95504: Fix negative numbers in PyUnicode_FromFormat (GH-95848)
Co-authored-by: philg314 <110174000+philg314@users.noreply.github.com>
2022-08-10 13:12:40 +02:00
Petr Viktorin 5a97a93be0
gh-93649: Undefine NDEBUG in Modules/_testcapi/* to enable assert() (GH-95793) 2022-08-10 11:53:10 +02:00
Petr Viktorin 325ae93b6b
gh-93649: Split unicode tests from _testcapimodule.c & add some more (GH-95819)
- Move PyUnicode tests to a separate file
- Add some more tests for PyUnicode_FromFormat

Co-authored-by: philg314 <110174000+philg314@users.noreply.github.com>
2022-08-10 09:10:25 +02:00
Petr Viktorin eb81c1aea1
Disable Limited API tests with Py_TRACE_REFS (GH-95796) 2022-08-09 09:03:11 +02:00
Petr Viktorin 656dad702d
gh-93274: Expose receiving vectorcall in the Limited API (GH-95717) 2022-08-08 14:12:05 +02:00
Erlend E. Aasland 0c14f07256
Fix downcast compiler warning in Modules/_testcapi/vectorcall.c (#95729) 2022-08-08 10:58:29 +02:00
Tim Gates 32b49f613a
docs: Fix a few typos (#94899)
- overriden => overridden
- calcualation => calculation

Signed-off-by: Tim Gates <tim.gates@iress.com>
2022-08-08 10:02:45 +02:00
Aivars Kalvāns 15f4a35487
gh-95385 Fastpath for encoding dict to JSON (gh-95374) 2022-08-06 15:55:24 +09:00
Eric Snow bdbadb905a
gh-94673: Recover Weaklist Lookup Performance (gh-95544)
gh-95302 seems to have introduced a small performance regression. Here we make some minor changes to recover that lost performance.
2022-08-04 11:28:15 -06:00
Serhiy Storchaka ab8a5beb5f
Fix links to old SF bugs (#95648) 2022-08-04 18:12:35 +02:00
Petr Viktorin 7b370b7305
gh-93274: Make vectorcall safe on mutable classes & inherit it by default (#95437) 2022-08-04 17:19:29 +02:00
Petr Viktorin a613fedd6e
gh-95388: Deprecate creating immutable types with mutable bases (GH-95533) 2022-08-04 16:13:45 +02:00