Commit Graph

121032 Commits

Author SHA1 Message Date
Sam Gross d7ddd90308
gh-115491: Fix Clang compiler warning (#116153)
gh-115491: Fix compiler warning on macOS
2024-02-29 16:02:44 -08:00
AN Long ca56c3a172
gh-103092: Add a mutex to make the PRNG state of rotatingtree concurrent-safe (#115301) 2024-03-01 00:04:16 +01:00
Sebastian Pipping 6a95676bb5
gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 .

### Notes

- Please treat as a security fix related to CVE-2023-52425.

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.
2024-02-29 14:52:50 -08:00
Ken Jin d01886c5c9
gh-115685: Type/values propagate for TO_BOOL in tier 2 (GH-115686) 2024-03-01 06:13:38 +08:00
Shantanu c04a981ff4
Fix rendering of null character in ast.rst (#116080) 2024-02-29 14:09:06 -08:00
Malcolm Smith fa1d675309
gh-71052: Fix several Android build issues (#115955)
This change is part of the work on PEP-738: Adding Android as a 
supported platform.

* Remove the "1.0" suffix from libpython's filename on Android, which 
  would prevent Gradle from packaging it into an app. 
* Simplify the build command in the Makefile so that libpython always 
  gets given an SONAME with the `-Wl-h` argument, even if the SONAME is
  identical to the actual filename.
* Disable a number of functions on Android which can be compiled and 
  linked against, but always fail at runtime. As a result, the native
  _multiprocessing module is no longer built for Android.
* gh-115390 (bee7bb331) added some pre-determined results to the 
  configure script for things that can't be autodetected when
  cross-compiling; this change adds Android to these where appropriate.
* Add a couple more pre-determined results for Android, and making them 
  cover iOS as well. This means the --enable-ipv6 configure option will 
  no longer be required on either platform.
2024-02-29 22:58:20 +01:00
Tian Gao ccfc042bbf
gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141) 2024-02-29 21:39:50 +00:00
Dino Viehland 556749c3e3
gh-112075: Avoid locking shared keys on every assignment (#116087) 2024-02-29 13:38:50 -08:00
Malcolm Smith 41d5391c55
gh-71052: Add test exclusions to support running the test suite on Android (#115918) 2024-02-29 22:32:50 +01:00
Steve Dower 83c5ecdeec
gh-108051: Update versions found by find_python.bat and clarify readme (GH-116118) 2024-02-29 21:24:05 +00:00
Carl Bordum Hansen 91c3c64237
gh-73580: Docs for tunnelling TLS through TLS (GH-22539) 2024-02-29 22:56:04 +02:00
Erlend E. Aasland dbe44f150c
Docs: mark up NotImplemented using the :data: role throughout the docs (#116135) 2024-02-29 20:46:12 +00:00
Guido van Rossum 0656509033
gh-116088: Insert bottom checks after all sym_set_...() calls (#116089)
This changes the `sym_set_...()` functions to return a `bool` which is `false`
when the symbol is `bottom` after the operation.

All calls to such functions now check this result and go to `hit_bottom`,
a special error label that prints a different message and then reports
that it wasn't able to optimize the trace. No executor will be produced
in this case.
2024-02-29 18:55:29 +00:00
Vinay Sajip 3b6f4cadf1
gh-115811: Update documentation to add some Logger attributes. (GH-116109) 2024-02-29 10:53:19 -08:00
Michael Felt 04d1000071
gh-72463: Fix ctypes/test_loading.py so that test_find reports skipped (GH-18312) 2024-02-29 20:37:31 +02:00
Raymond Hettinger a81d9509ee
Make the iter_except() recipe more compact. (gh-116132)
Only one example is needed
2024-02-29 11:30:18 -06:00
Brandt Bucher f0df35eeca
GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
Seth Michael Larson 45d8871dc4
gh-112844: Add SBOM for external dependencies (#115789) 2024-02-29 17:38:04 +02:00
Kirill Podoprigora 6a86030bc2
gh-116100: Add `test` arg to `ast.If` and `op` arg to `ast.BoolOp` calls (#116101) 2024-02-29 06:59:24 -08:00
Shantanu bea2795be2
gh-115881: Document feature_version limitations (#115980) 2024-02-29 11:09:09 +00:00
Petr Viktorin 186fa93876
gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105)
gh-116103: Prevent error in WindowsLoadTracker.__del__ if there was a permission error
2024-02-29 11:40:18 +01:00
Erlend E. Aasland fb2e17b642
gh-115937: Remove implementation details from inspect.signature() docs (#116086)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-02-29 09:42:28 +00:00
Guido van Rossum 86e5e063ab
gh-115816: Generate calls to sym_new_const() etc. without _Py_uop prefix (#116077)
This was left behind by GH-115987. Basically a lot of diffs like this:
```
-            res = _Py_uop_sym_new_unknown(ctx);
+            res = sym_new_unknown(ctx);
```
2024-02-29 00:05:53 +00:00
Guido van Rossum 479ac5ce8a
gh-115859: Fix test_type_inconsistency() when run multiple times (#116079)
This should fix the refleaks bots.

(See https://github.com/python/cpython/pull/116062#issuecomment-1970038174 .)
2024-02-28 23:56:58 +00:00
Ethan Furman 3ea78fd5bc
gh-115821: [Enum] better error message for calling super().__new__() (GH-116063)
docs now state to not call super().__new__
if super().__new__ is called, a better error message is now used
2024-02-28 15:17:49 -08:00
Erlend E. Aasland 4d1d35b906
gh-116075: Skip test_external_inspection on qemu in JIT CI (#116076) 2024-02-28 23:16:01 +00:00
Raymond Hettinger f484a2a748
Update an out-of-date example in the itertools recipe intro (gh-116082) 2024-02-28 17:11:05 -06:00
Eric Snow e80abd57a8
gh-76785: Update test.support.interpreters to Align With PEP 734 (gh-115566)
This brings the code under test.support.interpreters, and the corresponding extension modules, in line with recent updates to PEP 734.

(Note: PEP 734 has not been accepted at this time.  However, we are using an internal copy of the implementation in the test suite to exercise the existing subinterpreters feature.)
2024-02-28 16:08:08 -07:00
Raymond Hettinger 67c19e57b5
Improve all_equal() recipe (gh-116081)
Replace conjuction of next() calls with simpler len()/take() logic. Add key function.
2024-02-28 17:04:56 -06:00
Dino Viehland 81c79961d2
gh-112075: Use relaxed stores for places where we may race with when reading lock-free (#115786) 2024-02-28 14:53:19 -08:00
Guido van Rossum 3409bc29c9
gh-115859: Re-enable T2 optimizer pass by default (#116062)
This undoes the *temporary* default disabling of the T2 optimizer pass in gh-115860.

- Add a new test that reproduces Brandt's example from gh-115859; it indeed crashes before gh-116028 with PYTHONUOPSOPTIMIZE=1
- Re-enable the optimizer pass in T2, stop checking PYTHONUOPSOPTIMIZE
- Rename the env var to disable T2 entirely to PYTHON_UOPS_OPTIMIZE (must be explicitly set to 0 to disable)
- Fix skipIf conditions on tests in test_opt.py accordingly
- Export sym_is_bottom() (for debugging)
- Fix various things in the `_BINARY_OP_` specializations in the abstract interpreter:
  - DECREF(temp)
  - out-of-space check after sym_new_const()
  - add sym_matches_type() checks, so even if we somehow reach a binary op with symbolic constants of the wrong type on the stack we won't trigger the type assert
2024-02-28 22:38:01 +00:00
Sam Gross 75c6c05fea
gh-115891: Fix debug byte filling in free-threaded build (#116018)
The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
2024-02-28 12:50:09 -08:00
Sam Gross df5212df6c
gh-112529: Simplify PyObject_GC_IsTracked and PyObject_GC_IsFinalized (#114732) 2024-02-28 15:37:59 -05:00
Weii Wang c43b26d02e
gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210)
Use of a proxy is intended to defer DNS for the hosts to the proxy itself, rather than a potential for information leak of the host doing DNS resolution itself for any reason.  Proxy bypass lists are strictly name based.  Most implementations of proxy support agree.
2024-02-28 12:15:52 -08:00
Kerim Kabirov 6c1c94dc51
GH-115986 Reorder pprint docs and amend some references (#116019)
Introduce a new subsubsection, 'Functions', for module level functions,                                   
and place it before the PrettyPrinter class reference.                                                    
                                                                                                          
Also:
- Fix pprint.pprint() references so they properly link to the module                                   
  level function.
- Add links to sys.stdout.
2024-02-28 20:43:05 +01:00
Guido van Rossum e2a3e4b748
gh-115816: Improve internal symbols API in optimizer (#116028)
- Any `sym_set_...` call that attempts to set conflicting information
  cause the symbol to become `bottom` (contradiction).
- All `sym_is...` and similar calls return false or NULL for `bottom`.
- Everything's tested.
- The tests still pass with `PYTHONUOPSOPTIMIZE=1`.
2024-02-28 17:55:56 +00:00
Donghee Na f58f8cef74
gh-112075: Remove compiler warning from apple clang (gh-115855) 2024-02-29 02:51:59 +09:00
Tian Gao 0a61e23700
gh-107674: Improve performance of `sys.settrace` (GH-114986) 2024-02-28 15:21:42 +00:00
Steve Dower 9578288a3e
gh-116012: Preserve GetLastError() across calls to TlsGetValue on Windows (GH-116014) 2024-02-28 13:58:25 +00:00
Jan Max Meyer 647053fed1
doc: Use super() in subclassed JSONEncoder examples (GH-115565)
Replace calls to `json.JSONEncoder.default(self, obj)`
by `super().default(obj)` within the examples of the documentation.
2024-02-28 14:54:12 +01:00
Erlend E. Aasland 449c6da2bd
gh-115765: Don't use deprecated AC_EGREP_* macros in configure.ac (#116016)
Rewrite using AX_CHECK_DEFINE and AC_CHECK_TYPES.
2024-02-28 14:35:41 +01:00
Erlend E. Aasland a71e32ce8e
gh-78612: Mark up eval() using param list (#115212)
Also mention that the 'expression' parameter can be a string.
2024-02-28 14:03:50 +01:00
Petr Viktorin 7acf1fb5a7
gh-114911: Add CPUStopwatch test helper (GH-114912)
A few of our tests measure the time of CPU-bound operation, mainly
to avoid quadratic or worse behaviour.
Add a helper to ignore GC and time spent in other processes.
2024-02-28 12:53:48 +01:00
Kirill Podoprigora 3b63d0769f
gh-116030: test_unparse: Add ``ctx`` argument to ``ast.Name`` calls (#116031) 2024-02-28 03:04:23 -08:00
Pablo Galindo Salgado 1752b51012
gh-115773: Add tests to exercise the _Py_DebugOffsets structure (#115774) 2024-02-28 10:17:34 +00:00
Jelle Zijlstra d53560deb2
gh-105858: Expose some union-related objects as internal APIs (GH-116025)
We now use these in the AST parsing code after gh-105880. A few comparable types (e.g.,
NoneType) are already exposed as internal APIs.
2024-02-28 09:56:40 +00:00
Serhiy Storchaka e72576c48b
gh-115961: Improve tests for compressed file-like objects (GH-115963)
* Increase coverage for compressed file-like objects initialized with a
  file name, an open file object, a file object opened by file
  descriptor, and a file-like object without name and mode attributes
  (io.BytesIO)
* Increase coverage for name, fileno(), mode, readable(), writable(),
  seekable() in different modes and states
* No longer skip tests with bytes names
* Test objects implementing the path protocol, not just pathlib.Path.
2024-02-28 07:51:08 +00:00
Jelle Zijlstra 02beb9f020
gh-116026: Try disabling rebuilds of dependents in Homebrew (#116027) 2024-02-27 21:35:25 -08:00
Jelle Zijlstra ed4dfd8825
gh-105858: Improve AST node constructors (#105880)
Demonstration:

>>> ast.FunctionDef.__annotations__
{'name': <class 'str'>, 'args': <class 'ast.arguments'>, 'body': list[ast.stmt], 'decorator_list': list[ast.expr], 'returns': ast.expr | None, 'type_comment': str | None, 'type_params': list[ast.type_param]}
>>> ast.FunctionDef()
<stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'name'. This will become an error in Python 3.15.
<stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'args'. This will become an error in Python 3.15.
<ast.FunctionDef object at 0x101959460>
>>> node = ast.FunctionDef(name="foo", args=ast.arguments())
>>> node.decorator_list
[]
>>> ast.FunctionDef(whatever="you want", name="x", args=ast.arguments())
<stdin>:1: DeprecationWarning: FunctionDef.__init__ got an unexpected keyword argument 'whatever'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<ast.FunctionDef object at 0x1019581f0>
2024-02-27 18:13:03 -08:00
Pierre Ossman (ThinLinc team) 5a1559d949
gh-112997: Don't log arguments in asyncio unless debugging (#115667)
Nothing else in Python generally logs the contents of variables, so this
can be very unexpected for developers and could leak sensitive
information in to terminals and log files.
2024-02-27 17:39:08 -08:00