Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134097: Print number of refs & blocks after each statement in new REPL#134136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 4 commits intopython:mainfromEclips4:issue-134097
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Address review comments
  • Loading branch information
@ambv
ambv committedMay 19, 2025
commitcf621d7b6b9dd2c2ff47b3915bf6a4f1ed913f2f
18 changes: 8 additions & 10 deletionsLib/_pyrepl/simple_interact.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,14 +110,9 @@ def run_multiline_interactive_console(
more_lines = functools.partial(_more_lines, console)
input_n = 0

if sys._xoptions.get("showrefcount"):
# Were we compiled --with-pydebug?
if hasattr(sys, "gettotalrefcount"):
showrefcount = True
else:
showrefcount = False
else:
showrefcount = False
_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()
Expand DownExpand Up@@ -176,5 +171,8 @@ def maybe_run_command(statement: str) -> bool:
except:
console.showtraceback()
console.resetbuffer()
if showrefcount:
console.write(f"[{sys.gettotalrefcount()} refs, {sys.getallocatedblocks()} blocks]\n")
if show_ref_count:
console.write(
f"[{sys.gettotalrefcount()} refs,"
f" {sys.getallocatedblocks()} blocks]\n"
)
1 change: 1 addition & 0 deletionsLib/test/test_pyrepl/test_pyrepl.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1614,6 +1614,7 @@ def test_prompt_after_help(self):
@skipUnless(Py_DEBUG, '-X showrefcount requires a Python debug build')
def test_showrefcount(self):
env = os.environ.copy()
env.pop("PYTHON_BASIC_REPL", "")
output, _ = self.run_repl("1\n1+2\nexit()\n", cmdline_args=['-Xshowrefcount'], env=env)
matches = re.findall(r'\[-?\d+ refs, \d+ blocks\]', output)
self.assertEqual(len(matches), 3)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp