Skip to content
Merged
Changes from all commits
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
18 changes: 13 additions & 5 deletions src/greenlet/tests/test_tracing.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
from __future__ import print_function
import sys
import sysconfig
import greenlet
import unittest

from . import TestCase
from . import PY312

# https://discuss.python.org/t/cpython-3-12-greenlet-and-tracing-profiling-how-to-not-crash-and-get-correct-results/33144/2
DEBUG_BUILD_PY312 = (
PY312 and hasattr(sys, 'gettotalrefcount'),
"Broken on debug builds of Python 3.12"
# When build variables are available, OPT is the best way of detecting
# the build with assertions enabled. Otherwise, fallback to detecting PyDEBUG
# build.
ASSERTION_BUILD_PY312 = (
PY312 and (
"-DNDEBUG" not in sysconfig.get_config_var("OPT").split()
if sysconfig.get_config_var("OPT") is not None
else hasattr(sys, 'gettotalrefcount')
),
"Broken on assertion-enabled builds of Python 3.12"
)

class SomeError(Exception):
Expand Down Expand Up @@ -198,7 +206,7 @@ def run(self):

self._check_trace_events_from_greenlet_sets_profiler(X(), tracer)

@unittest.skipIf(*DEBUG_BUILD_PY312)
@unittest.skipIf(*ASSERTION_BUILD_PY312)
def test_trace_events_multiple_greenlets_switching(self):
tracer = PythonTracer()

Expand Down Expand Up @@ -236,7 +244,7 @@ def g2_run():
('c_call', '__exit__'),
])

@unittest.skipIf(*DEBUG_BUILD_PY312)
@unittest.skipIf(*ASSERTION_BUILD_PY312)
def test_trace_events_multiple_greenlets_switching_siblings(self):
# Like the first version, but get both greenlets running first
# as "siblings" and then establish the tracing.
Expand Down
Loading