Commit graph

115735 commits

Author SHA1 Message Date
C.A.M. Gerlach f08209874e
gh-99191: Use correct check for MSVC C++ version support in _wmimodule.cpp (GH-100381) 2023-01-09 17:48:24 +00:00
Nikita Sobolev 36f2329367
gh-100873: Fix "‘lo’ may be used uninitialized in this function" warning in mathmodule.c (#100881) 2023-01-09 21:21:24 +05:30
dgelessus 837ba05267
GH-81061: Fix refcount issue when returning None from a ctypes.py_object callback (#13364) 2023-01-09 15:43:04 +05:30
Chris Withers 4e544eafcb
fix up mock tests coverage (#100874) 2023-01-09 10:08:56 +00:00
Carl Meyer 0cd597fef1
gh-100764: add pycore_frame.h to PYTHON_HEADERS and Windows build files(#100765) 2023-01-09 14:35:56 +05:30
dsentinel 7a50d6b5b0
GH-100813: Add socket.IP_PKTINFO constant (#10294) 2023-01-09 14:30:40 +05:30
Ned Deily e47b13934b
Update copyright year in README (GH-100863)
Co-authored-by: HARSHA VARDHAN <75431678+Thunder-007@users.noreply.github.com>
2023-01-08 21:53:56 -05:00
Nikita Sobolev bc0a686f82
gh-87447: Fix walrus comprehension rebind checking (#100581)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-01-08 15:51:29 -07:00
Ned Deily 8d69828092
Update additional copyright years to 2023. (GH-100859) 2023-01-08 17:05:28 -05:00
Raymond Hettinger 9a68ff12c3
GH-100805: Support numpy.array() in random.choice(). (GH-100830) 2023-01-08 13:40:35 -06:00
Mark Dickinson 87d3bd0e02
gh-100833: Remove 'volatile' qualifiers in fsum algorithm (#100845)
This PR removes the `volatile` qualifier on various intermediate quantities
in the `math.fsum` implementation, and updates the notes preceding the
algorithm accordingly (as well as fixing some of the exsting notes). See
the linked issue #100833 for discussion.
2023-01-08 19:40:15 +00:00
Raymond Hettinger b139bcd892
GH-100485: Tweaks to sumprod() (GH-100857) 2023-01-08 13:38:24 -06:00
Benjamin Peterson 11f99323c2
Update copyright years to 2023. (gh-100848) 2023-01-08 09:13:25 -06:00
Nnarol 0741da8d28
GH-90829: Fix empty iterable error message in min/max (#31181) 2023-01-08 19:21:20 +05:30
Nikita Sobolev b034fd3e59
gh-100689: Revert "bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)" (#100745)
* gh-100689: Revert "bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)"

This reverts commit 7c83eaa536.
2023-01-08 18:24:40 +05:30
Shantanu 53455a319f
gh-100783: fix os.path.join documentation (#100811)
- Use "drive", not "drive letter", because of UNC paths
- Previous components are not thrown away from relative drive letters
- Use "segment" instead of "component" for consistency with pathlib
- Other miscellaneous improvements
2023-01-08 00:51:30 -08:00
Sergey B Kirpichev 909982e82a
gh-91851: Micro optimizations for arithmetic between Fractions (#25518)
Adapted from
https://github.com/python/cpython/pull/24779/commits/046c84e8f9

This makes arithmetic between Fractions with small components
just as fast as before python/cpython#24779, at some expense of
mixed arithmetic (e.g. Fraction + int).
2023-01-08 00:34:20 -08:00
busywhitespace 6d3bc4a795
gh-100824: Fix typo in the documentation of unittest.TestLoader.testNamePatterns (#100825) 2023-01-08 13:37:16 +05:30
Shantanu a2141882f2
gh-100776: Fix misleading default value in help(input) (#100788) 2023-01-08 13:27:41 +05:30
Raymond Hettinger df3851fe4a
GH-100485: Convert from Fast2Sum to 2Sum (GH-100836) 2023-01-07 21:37:08 -06:00
Nikita Sobolev 951303fd85
gh-100815: Normalize types module usage in copy module (#100816) 2023-01-07 21:29:53 +00:00
Nikita Sobolev 6746135b07
gh-100792: Make email.message.Message.__contains__ twice as fast (#100793) 2023-01-07 13:26:05 -08:00
Raymond Hettinger 47b9f83a83
GH-100485: Add math.sumprod() (GH-100677) 2023-01-07 12:46:35 -06:00
FrozenBob deaf090699
gh-100673: Removed erroneous note in the get_type_hints docs (#100701)
Removed erroneous note in the get_type_hints docs

typing.get_type_hints still includes base class type hints.
2023-01-07 17:31:47 +00:00
Carl Meyer 7116030a25
gh-88696: clean up dead argument to compiler_make_closure (GH-100806) 2023-01-07 12:20:48 +00:00
Nikita Sobolev 9e7d7266ec
gh-96127: Fix inspect.signature call on mocks (#96335) 2023-01-07 10:49:15 +00:00
Nikita Sobolev a109454e82
gh-100690: [mock] hide ATTRIB_DENY_LIST and make it immutable (#100819) 2023-01-07 10:25:05 +00:00
Barney Gale 26ff43625e
Add barneygale to CODEOWNERS for pathlib (#100808) 2023-01-06 20:38:12 +00:00
Christian Klein 1d4d677d1c
gh-100690: Raise an AttributeError when the assert_ prefix is forgotten when using Mock (#100691)
Mock objects which are not unsafe will now raise an AttributeError when accessing an
attribute that matches the name of an assertion but without the prefix `assert_`, e.g. accessing `called_once` instead of `assert_called_once`.

This is in addition to this already happening for accessing attributes with prefixes assert, assret, asert, aseert, and assrt.
2023-01-06 18:38:50 +00:00
Guido van Rossum 9ffbc58f5c
GH-98831: Add some tests for generate_cases.py (#100763)
- This doesn't cover everything (far from it) but it's a start.
- This uses pytest, which isn't ideal, but was quickest to get started.

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-06 08:04:20 -08:00
Sergey B Kirpichev 0e640260da
gh-91851: Trivial optimizations in Fraction (#100791)
Make some trivial performance optimizations in Fraction

Uses private class attributes `_numerator` and `_denominator` in place of the `numerator` and `denominator` property accesses.

Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
2023-01-06 15:37:34 +00:00
Irit Katriel 15c44789bb
gh-100758: Refactor initialisation of frame headers into a single function (_PyFrame_Initialize) (GH-100759) 2023-01-06 14:55:56 +00:00
Mark Shannon 78068126a1
GH-99005: More intrinsics (GH-100774)
* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
2023-01-06 14:47:57 +00:00
Akshit Tyagi 659c2607f5
gh-99026 update dataclasses docs for when annotations are inspected (gh-100798)
update dataclasses docs for when annotations are inspected
2023-01-06 09:26:44 -05:00
Shantanu 2f2fa03ff3
gh-87691: clarify use of anchor in pathlib docs (#100782)
This is feedback from https://github.com/python/cpython/pull/100737#discussion_r1062968696

This matches the wording from the `os.path.join` docs better:
https://docs.python.org/3/library/os.path.html#os.path.join

In particular, the previous use of "anchor" was incorrect given the
pathlib definition of "anchor".

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-01-05 17:49:33 -08:00
Carl Meyer 0a7936a38f
gh-90104: avoid RecursionError on recursive dataclass field repr (gh-100756)
Avoid RecursionError on recursive dataclass field repr
2023-01-05 19:19:40 -05:00
Dustin Spicuzza cc8748712e
gh-86082: bpo-41916: allow cross-compiled python to have -pthread set for CXX (#22525)
When cross-compiling, the compile/run test for -pthread always fails so -pthread
will never be automatically set without an override from the cache. ac_cv_pthread
can already be overridden, so do the same thing for ac_cv_cxx_thread.
2023-01-05 14:57:31 -08:00
Shantanu 1ae619c911
gh-87691: add an absolute path pathlib example in / operator docs (GH-100737)
The behaviour is fully explained a couple paragraphs above, but it may be useful to have a brief example to cover the behaviour.

Automerge-Triggered-By: GH:hauntsaninja
2023-01-05 14:55:35 -08:00
Shantanu d84b1a97f9
Add hauntsaninja as tomllib CODEOWNER (#100779) 2023-01-05 14:28:02 -08:00
Barney Gale 7fba99eadb
gh-100562: improve performance of pathlib.Path.absolute() (GH-100563)
Increase performance of the `absolute()` method by calling `os.getcwd()` directly, rather than using the `Path.cwd()` class method. This avoids constructing an extra `Path` object (and the parsing/normalization that comes with it).

Decrease performance of the `cwd()` class method by calling the `Path.absolute()` method, rather than using `os.getcwd()` directly. This involves constructing an extra `Path` object. We do this to maintain a longstanding pattern where `os` functions are called from only one place, which allows them to be more readily replaced by users. As `cwd()` is generally called at most once within user programs, it's a good bargain.

```shell
# before
$ ./python -m timeit -s 'from pathlib import Path; p = Path("foo", "bar")' 'p.absolute()'
50000 loops, best of 5: 9.04 usec per loop
# after
$ ./python -m timeit -s 'from pathlib import Path; p = Path("foo", "bar")' 'p.absolute()'
50000 loops, best of 5: 5.02 usec per loop
```

Automerge-Triggered-By: GH:AlexWaygood
2023-01-05 14:11:50 -08:00
Zachary Ware af5149f30b
gh-98831: Regenerate Python/opcode_metadata.h (GH-100778) 2023-01-05 15:47:18 -06:00
Guido van Rossum 14b7f00fdf
GH-98831: Update generate_cases.py: register inst, opcode_metadata.h (#100735)
(These aren't used yet, but may be coming soon,
and it's easier to keep this tool the same between branches.)

Added a sanity check for all this to compile.c.

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2023-01-05 13:01:07 -08:00
Mark Shannon 28187141cc
GH-99005: Add CALL_INTRINSIC_1 instruction (GH-100771)
* Remove PRINT_EXPR instruction

* Remove STOPITERATION_ERROR instruction

* Remove IMPORT_STAR instruction
2023-01-05 16:05:51 +00:00
Mark Shannon f20c553a45
GH-100288: Remove LOAD_ATTR_METHOD_WITH_DICT instruction. (GH-100753) 2023-01-05 12:20:09 +00:00
Tzu-ping Chung 105e37395d
GH-100766: Note that locale.LC_MESSAGES is not universal (GH-100702) 2023-01-05 03:34:30 +00:00
Brett Cannon 31b639a992
Drop myself from pathlib maintenance (#100757) 2023-01-04 14:59:48 -08:00
Christian Klein 7f1eefc6f4
gh-100739: Respect mock spec when checking for unsafe prefixes (#100740)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-01-04 22:31:29 +00:00
Irit Katriel 52017dbe16
gh-100747: some compiler macros use c instead of C to access the compiler (#100748) 2023-01-04 20:19:20 +00:00
Mark Shannon 15aecf8dd7
GH-100719: Remove the co_nplaincellvars field from code objects. (GH-100721) 2023-01-04 15:41:39 +00:00
Irit Katriel c31e356a10
gh-100720: refactor calculation of number of frame slots for a code object into the new function _PyFrame_NumSlotsForCodeObject (#100722) 2023-01-04 13:37:06 +00:00