Commit Graph

7470 Commits

Author SHA1 Message Date
Miss Islington (bot) ec6ed6681d
gh-94930: skipitem() in getargs.c should return non-NULL on error (GH-94931)
(cherry picked from commit 067f0da335)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-07-18 08:41:22 -07:00
Miss Islington (bot) 1c63734217
gh-91348: Restore frame argument to sys._getframe audit event (GH-94928)
(cherry picked from commit 044a593cbb)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-07-17 08:49:57 -07:00
Serhiy Storchaka 107c21c5d5
gh-94864: Fix PyArg_Parse* with deprecated format units "u" and "Z" (GH-94902)
It returned 1 (success) when warnings are turned into exceptions.
2022-07-17 08:23:37 +03:00
John Belmonte 45896f2a02
[3.11] gh-93883: elide traceback indicators when possible (GH-93994) (GH-94740)
Elide traceback column indicators when the entire line of the
frame is implicated.  This reduces traceback length and draws
more attention to the remaining (very relevant) indicators.

Example:
```
Traceback (most recent call last):
  File "query.py", line 99, in <module>
    bar()
  File "query.py", line 66, in bar
    foo()
  File "query.py", line 37, in foo
    magic_arithmetic('foo')
  File "query.py", line 18, in magic_arithmetic
    return add_counts(x) / 25
           ^^^^^^^^^^^^^
  File "query.py", line 24, in add_counts
    return 25 + query_user(user1) + query_user(user2)
                ^^^^^^^^^^^^^^^^^
  File "query.py", line 32, in query_user
    return 1 + query_count(db, response['a']['b']['c']['user'], retry=True)
                               ~~~~~~~~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object is not subscriptable
```

Automerge-Triggered-By: GH:pablogsal
2022-07-11 04:27:29 -07:00
Brandt Bucher e5c8ad3e15
[3.11] GH-94694: Fix column offsets for multi-line method lookups (GH-94721)
(cherry picked from commit 264b3ddfd5)
2022-07-09 22:12:45 -07:00
Kumar Aditya 7a341724e4
[3.11] GH-93252: Fix error handling for failed Python calls (GH-94693) (GH-94708)
Automerge-Triggered-By: GH:tiran
2022-07-09 05:09:15 -07:00
Christian Heimes 36a3372d51
[3.11] gh-94215: Fix error handling for line-tracing events (GH-94681) (GH-94688)
* Re-enable crasher
* Fix error handling for line-tracing events
* blurb add
(cherry picked from commit 23ee4a8067)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-07-08 15:25:53 +02:00
Christian Heimes 74c953d396
[3.11] gh-92228: disable the compiler's 'small exit block inlining' optimization for blocks that have a line number (GH-94592) (GH-94643)
Inlining of code that corresponds to source code lines, can make it hard to distinguish later between code which is only reachable from except handlers, and that which is reachable in normal control flow. This caused problems with the debugger's jump feature.

This PR turns off the inlining optimisation for code which has line numbers. We still inline things like the implicit "return None"..
(cherry picked from commit bde06e1b83)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-07-07 03:10:32 -07:00
Łukasz Langa 5f4a16b291
[3.11] gh-94510: Raise on re-entrant calls to sys.setprofile and sys.settrace (GH-94511) (GH-94578)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 40d81fd63b)
2022-07-05 21:02:43 +02:00
Łukasz Langa 1bfe83a114
[3.11] gh-94485: Set line number of module's RESUME instruction to 0 as specified by PEP 626 (GH-94552) (GH-94562)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Mark Shannon <mark@hotpy.org>

(cherry picked from commit 324d01944d)
2022-07-05 16:01:24 +02:00
Miss Islington (bot) 68f5fa6683
[3.11] GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371) (#94482)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-07-04 19:43:12 +01:00
Mark Shannon 113b309f18
[3.11] GH-93354: Use exponential backoff to avoid excessive specialization attempts (GH-93355) (GH-93379)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-30 23:03:37 +02:00
Miss Islington (bot) fdc008138e
gh-91719: Reload opcode on unknown error so that C can optimize the dispatching in ceval.c (GH-94364) (#94453)
(cherry picked from commit ea39b77de9)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2022-06-30 09:11:05 -07:00
Miss Islington (bot) f58c366a73
GH-94329: Don't raise on excessive stack consumption (GH-94421) (GH-94446)
(cherry picked from commit b152bf448b)
2022-06-30 15:53:20 +01:00
Irit Katriel 48a739ec10
gh-94332: make it safe to call assemble_free when assemble_init has not been called (GH-94389) (GH-94442)
(cherry picked from commit be82d26570)
2022-06-30 15:30:12 +01:00
Christian Heimes 9140c413d0
[3.11] GH-93516: Drop broken assert, fixes GH-93769 (GH-94411) 2022-06-29 13:53:56 +01:00
Mark Shannon 3b4f5ed168
[3.11] GH-93516: Backport GH-93769 (GH-94231)
* Store offset of first traceable instruction to avoid having to recompute it all the time when tracing.
2022-06-28 16:30:22 +01:00
Mark Shannon 3ece6e6feb
[3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing (GH-94127)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2022-06-22 16:32:02 +01:00
Miss Islington (bot) 2733c64e28
gh-94021: Address unreachable code warning in specialize code (GH-94022)
(cherry picked from commit 77c839c98f)

Co-authored-by: Christian Heimes <christian@python.org>
2022-06-21 00:01:52 -07:00
Miss Islington (bot) b8fe3bd1d4
gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation (GH-93641)
(cherry picked from commit 38af903506)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2022-06-20 11:37:27 -07:00
Victor Stinner 96254a9acd
gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) (#94000)
Move the follow functions and type from frameobject.h to pyframe.h,
so the standard <Python.h> provide frame getter functions:

* PyFrame_Check()
* PyFrame_GetBack()
* PyFrame_GetBuiltins()
* PyFrame_GetGenerator()
* PyFrame_GetGlobals()
* PyFrame_GetLasti()
* PyFrame_GetLocals()
* PyFrame_Type

Remove #include "frameobject.h" from many C files. It's no longer
needed.

(cherry picked from commit 27b9894033)
2022-06-20 15:47:41 +02:00
Miss Islington (bot) 1353b8a4bc
gh-74953: Fix PyThread_acquire_lock_timed() code recomputing the timeout (GH-93941)
Set timeout, don't create a local variable with the same name.
(cherry picked from commit f64557f480)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-06-17 07:39:27 -07:00
Irit Katriel df091e14d8
[3.11] GH-93662: Make sure that column offsets are correct in multi-line method calls. (GH-93673) (#93895)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-06-16 11:56:35 +01:00
Miss Islington (bot) cbfbe248e3
gh-90300: split --help output into separate options (GH-30331)
Make --help output shorter and add new help options.

--help-env, --help-xoptions and --help-all command-line options are
added to complement --help.
(cherry picked from commit 8aa9d40b00)

Co-authored-by: Éric <earaujo@caravan.coop>
2022-06-14 12:15:42 -07:00
Serhiy Storchaka d42b3689f4
[3.11] gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742) (GH-93792)
It combines PyImport_ImportModule() and PyObject_GetAttrString()
and saves 4-6 lines of code on every use.

Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
(cherry picked from commit 6fd4c8ec77)
2022-06-14 08:51:39 +03:00
Miss Islington (bot) 90f9b8b9e8
gh-92597: Improve error message for AST nodes with invalid ranges (GH-93398) (GH-93414)
(cherry picked from commit 8a221a8537)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-06-01 14:05:40 +01:00
Miss Islington (bot) b425d887aa
gh-92597: Ensure that AST nodes without explicit end positions can be compiled (GH-93359)
(cherry picked from commit 705eaec28f)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-05-31 16:26:16 -07:00
Miss Islington (bot) 7f6e6abdc4
gh-93351: Ensure the position information in AST nodes created by the parser is always consistent (GH-93352)
(cherry picked from commit 5893b5db98)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-05-30 11:52:36 -07:00
Eric Snow 36374251aa
[3.11] bpo-40514: Drop EXPERIMENTAL_ISOLATED_SUBINTERPRETERS (gh-93185) (GH-93306)
(cherry picked from commit caa279d6fd)

This was added for bpo-40514 (gh-84694) to test out a per-interpreter GIL.  However, it has since proven unnecessary to keep the experiment in the repo.  (It can be done as a branch in a fork like normal.)  So here we are removing:

* the configure option
* the macro
* the code enabled by the macro

Automerge-Triggered-By: GH:ericsnowcurrently
2022-05-27 17:56:30 -07:00
Miss Islington (bot) 33336e46da
gh-93217: fix some issues in man page and --help (GH-93219)
(cherry picked from commit da39719483)

Co-authored-by: Éric <merwok@netwok.org>
2022-05-26 07:53:20 -07:00
Miss Islington (bot) 307dacd651
gh-91924: Fix __lltrace__ for non-UTF-8 stdout encoding (GH-93199)
Fix __lltrace__ debug feature if the stdout encoding is not UTF-8.

If the stdout encoding is not UTF-8, the first call to
lltrace_resume_frame() indirectly sets lltrace to 0 when calling
unicode_check_encoding_errors() which calls
encodings.search_function().
(cherry picked from commit 5695c0e0a2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-05-25 03:11:46 -07:00
Miss Islington (bot) c771cbe8f9
gh-93065: Fix HAMT to iterate correctly over 7-level deep trees (GH-93066) (GH-93145)
Also while there, clarify a few things about why we reduce the hash to 32 bits.

Co-authored-by: Eli Libman <eli@hyro.ai>
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>

(cherry picked from commit c1f5c903a7)
2022-05-24 10:52:06 +02:00
Miss Islington (bot) f0950585a3
gh-93061: Mark as artificial: backwards jump after async for (GH-93062) (GH-93110)
(cherry picked from commit a458be3263)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2022-05-23 14:58:53 -04:00
Miss Islington (bot) 2e8b2d0ee2
GH-92236: Remove spurious "line" event when starting coroutine or generator. (GH-92722) (GH-92772)
(cherry picked from commit 22a1db378c)
2022-05-13 11:52:54 +01:00
Miss Islington (bot) 3d1ad42591
Update outdated `LOAD_METHOD` comments in `Python/ceval.c` (GH-92641)
(cherry picked from commit bdf9969197)

Co-authored-by: Crowthebird <78076854+thatbirdguythatuknownot@users.noreply.github.com>
2022-05-12 05:59:36 -07:00
Miss Islington (bot) 6a17cdebe9
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620) (GH-92621)
(cherry picked from commit 7c6b7ade8d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-05-10 22:01:17 +01:00
Miss Islington (bot) 14bd6df094
gh-88279: Fix compiler warning for using deprecated PySys_SetArgvEx (GH-92428)
(cherry picked from commit bd030b633f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-07 21:12:52 -07:00
larryhastings 5021064390
gh-92203: Add closure support to exec(). (#92204)
Add a closure keyword-only parameter to exec(). It can only be specified when exec-ing a code object that uses free variables. When specified, it must be a tuple, with exactly the number of cell variables referenced by the code object. closure has a default value of None, and it must be None if the code object doesn't refer to any free variables.
2022-05-06 10:09:35 -07:00
Victor Stinner 329afe78c3
gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)
Fix tests failing with the PYTHONSAFEPATH=1 env var.

Enhance also -P help in Python usage (python --help).
2022-05-06 03:41:24 +02:00
Victor Stinner ada8b6d1b1
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
Add the -P command line option and the PYTHONSAFEPATH environment
variable to not prepend a potentially unsafe path to sys.path.

* Add sys.flags.safe_path flag.
* Add PyConfig.safe_path member.
* Programs/_bootstrap_python.c uses config.safe_path=0.
* Update subprocess._optim_args_from_interpreter_flags() to handle
  the -P command line option.
* Modules/getpath.py sets safe_path to 1 if a "._pth" file is
  present.
2022-05-06 01:34:11 +02:00
Mark Shannon f8a2fab212
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
Victor Stinner d716a0dfe2
Use static inline function Py_EnterRecursiveCall() (#91988)
Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

* Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
* Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
* pycore_ceval.h: Rename Py_EnterRecursiveCall() to
  _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
  _Py_LeaveRecursiveCall()
2022-05-04 13:30:23 +02:00
Inada Naoki 6dcfd6c5e3
gh-78214: marshal: Stabilize FLAG_REF usage (GH-8226)
Use FLAG_REF always for interned strings.

Refcounts of interned string is very unstable.
When compiling same source, refcounts of interned string in the output may be 1 or >1.
It makes FLAG_REF usage unstable.

To help reproducible build, use FLAG_REF for interned string even if refcnt(obj)==1.
2022-05-04 10:01:15 +09:00
Mark Shannon 836b17c9c3
Add more stats for freelist use and allocations. (GH-92211) 2022-05-03 16:40:24 -06:00
Kumar Aditya e8d7661ff2
GH-91173: disable frozen modules in debug builds (#92023) 2022-05-03 15:20:13 -07:00
Victor Stinner b270b82f11
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
2022-05-03 20:25:41 +02:00
Pieter Eendebak feb45d0ae9
suggestions.c: Improve efficiency of levenshtein_distance method (#91835) 2022-05-02 11:09:35 -06:00
Dennis Sweeney 868b1afa05
gh-92063: Enforce types in specialized PRECALL opcodes (GH-92068)
* Check the types of PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS as well

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_O

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
2022-04-30 12:35:33 -06:00
Dennis Sweeney 37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945) 2022-04-27 22:36:34 -06:00
Victor Stinner 64a54e511d
gh-91719: Add pycore_opcode.h internal header file (#91906)
Move the following API from Include/opcode.h (public C API) to a new
Include/internal/pycore_opcode.h header file (internal C API):

* EXTRA_CASES
* _PyOpcode_Caches
* _PyOpcode_Deopt
* _PyOpcode_Jump
* _PyOpcode_OpName
* _PyOpcode_RelativeJump
2022-04-26 00:14:30 +02:00