Skip to content

Commit 14e6f79

Browse files
committed
gh-124613: Don't run perf tests in JIT builds
1 parent 6d0d26e commit 14e6f79

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

Lib/_pyrepl/unix_console.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ def __init__(self):
118118

119119
def register(self, fd, flag):
120120
self.fd = fd
121+
121122
# note: The 'timeout' argument is received as *milliseconds*
122123
def poll(self, timeout: float | None = None) -> list[int]:
123124
if timeout is None:
124125
r, w, e = select.select([self.fd], [], [])
125126
else:
126-
r, w, e = select.select([self.fd], [], [], timeout/1000)
127+
r, w, e = select.select([self.fd], [], [], timeout / 1000)
127128
return r
128129

129130
poll = MinimalPoll # type: ignore[assignment]
@@ -201,8 +202,7 @@ def _my_getstr(cap: str, optional: bool = False) -> bytes | None:
201202

202203
def more_in_buffer(self) -> bool:
203204
return bool(
204-
self.input_buffer
205-
and self.input_buffer_pos < len(self.input_buffer)
205+
self.input_buffer and self.input_buffer_pos < len(self.input_buffer)
206206
)
207207

208208
def __read(self, n: int) -> bytes:
@@ -216,7 +216,6 @@ def __read(self, n: int) -> bytes:
216216
self.input_buffer_pos = 0
217217
return ret
218218

219-
220219
def change_encoding(self, encoding: str) -> None:
221220
"""
222221
Change the encoding used for I/O operations.
@@ -342,8 +341,11 @@ def prepare(self):
342341
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
343342

344343
# In macOS terminal we need to deactivate line wrap via ANSI escape code
345-
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
346-
os.write(self.output_fd, b"\033[?7l")
344+
# if (
345+
# platform.system() == "Darwin"
346+
# and os.getenv("TERM_PROGRAM") == "Apple_Terminal"
347+
# ):
348+
# os.write(self.output_fd, b"\033[?7l")
347349

348350
self.screen = []
349351
self.height, self.width = self.getheightwidth()
@@ -373,8 +375,11 @@ def restore(self):
373375
self.flushoutput()
374376
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
375377

376-
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
377-
os.write(self.output_fd, b"\033[?7h")
378+
# if (
379+
# platform.system() == "Darwin"
380+
# and os.getenv("TERM_PROGRAM") == "Apple_Terminal"
381+
# ):
382+
# os.write(self.output_fd, b"\033[?7h")
378383

379384
if hasattr(self, "old_sigwinch"):
380385
signal.signal(signal.SIGWINCH, self.old_sigwinch)
@@ -448,14 +453,14 @@ def getheightwidth(self):
448453
- tuple: Height and width of the console.
449454
"""
450455
try:
451-
return int(os.environ["LINES"]), int(os.environ["COLUMNS"])
456+
return int(os.environ["LINES"]), int(os.environ["COLUMNS"]) - 1
452457
except KeyError:
453458
height, width = struct.unpack(
454459
"hhhh", ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8)
455460
)[0:2]
456461
if not height:
457462
return 25, 80
458-
return height, width
463+
return height, width - 1
459464

460465
else:
461466

Lib/test/test_perf_profiler.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
2424

2525

26+
def is_jit_build():
27+
cflags = sysconfig.get_config_var("PY_CORE_CFLAGS")
28+
if not cflags:
29+
return False
30+
return "_Py_JIT" in cflags
31+
32+
33+
if is_jit_build():
34+
raise unittest.SkipTest("Perf support is not available in jit builds")
35+
36+
2637
def supports_trampoline_profiling():
2738
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
2839
if not perf_trampoline:
@@ -229,7 +240,7 @@ def is_unwinding_reliable_with_frame_pointers():
229240
cflags = sysconfig.get_config_var("PY_CORE_CFLAGS")
230241
if not cflags:
231242
return False
232-
return "no-omit-frame-pointer" in cflags and "_Py_JIT" not in cflags
243+
return "no-omit-frame-pointer" in cflags
233244

234245

235246
def perf_command_works():
@@ -382,6 +393,7 @@ def baz(n):
382393
self.assertNotIn(f"py::bar:{script}", stdout)
383394
self.assertNotIn(f"py::baz:{script}", stdout)
384395

396+
385397
@unittest.skipUnless(perf_command_works(), "perf command doesn't work")
386398
@unittest.skipUnless(
387399
is_unwinding_reliable_with_frame_pointers(),
@@ -494,7 +506,9 @@ def _is_perf_version_at_least(major, minor):
494506

495507

496508
@unittest.skipUnless(perf_command_works(), "perf command doesn't work")
497-
@unittest.skipUnless(_is_perf_version_at_least(6, 6), "perf command may not work due to a perf bug")
509+
@unittest.skipUnless(
510+
_is_perf_version_at_least(6, 6), "perf command may not work due to a perf bug"
511+
)
498512
class TestPerfProfilerWithDwarf(unittest.TestCase, TestPerfProfilerMixin):
499513
def run_perf(self, script_dir, script, activate_trampoline=True):
500514
if activate_trampoline:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy