mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.14] gh-134097: Print number of refs & blocks after each statement in new REPL (gh-134136) (gh-134220)
(cherry picked from commit c31547a591
)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
e3cc4008c4
commit
182464eb9e
3 changed files with 24 additions and 1 deletions
|
@ -110,6 +110,10 @@ def run_multiline_interactive_console(
|
|||
more_lines = functools.partial(_more_lines, console)
|
||||
input_n = 0
|
||||
|
||||
_is_x_showrefcount_set = sys._xoptions.get("showrefcount")
|
||||
_is_pydebug_build = hasattr(sys, "gettotalrefcount")
|
||||
show_ref_count = _is_x_showrefcount_set and _is_pydebug_build
|
||||
|
||||
def maybe_run_command(statement: str) -> bool:
|
||||
statement = statement.strip()
|
||||
if statement in console.locals or statement not in REPL_COMMANDS:
|
||||
|
@ -167,3 +171,8 @@ def run_multiline_interactive_console(
|
|||
except:
|
||||
console.showtraceback()
|
||||
console.resetbuffer()
|
||||
if show_ref_count:
|
||||
console.write(
|
||||
f"[{sys.gettotalrefcount()} refs,"
|
||||
f" {sys.getallocatedblocks()} blocks]\n"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue