PATH:
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
greenlet
/
tests
# -*- coding: utf-8 -*- """ If we have a run callable passed to the constructor or set as an attribute, but we don't actually use that (because ``__getattribute__`` or the like interferes), then when we clear callable before beginning to run, there's an opportunity for Python code to run. """ import greenlet g = None main = greenlet.getcurrent() results = [] class RunCallable: def __del__(self): results.append(('RunCallable', '__del__')) main.switch('from RunCallable') class G(greenlet.greenlet): def __getattribute__(self, name): if name == 'run': results.append(('G.__getattribute__', 'run')) return run_func return object.__getattribute__(self, name) def run_func(): results.append(('run_func', 'enter')) g = G(RunCallable()) # Try to start G. It will get to the point where it deletes # its run callable C++ variable in inner_bootstrap. That triggers # the __del__ method, which switches back to main before g # actually even starts running. x = g.switch() results.append(('main: g.switch()', x)) # In the C++ code, this results in g->g_switch() appearing to return, even though # it has yet to run. print('In main with', x, flush=True) g.switch() print('RESULTS', results)
[-] fail_clearing_run_switches.py
[edit]
[+]
__pycache__
[-] fail_switch_two_greenlets.py
[edit]
[-] fail_slp_switch.py
[edit]
[-] _test_extension.cpython-312-x86_64-linux-gnu.so
[edit]
[-] test_generator.py
[edit]
[-] test_extension_interface.py
[edit]
[-] test_greenlet.py
[edit]
[-] test_tracing.py
[edit]
[-] _test_extension_cpp.cpp
[edit]
[-] __init__.py
[edit]
[-] test_throw.py
[edit]
[-] test_version.py
[edit]
[-] test_greenlet_trash.py
[edit]
[-] test_gc.py
[edit]
[+]
..
[-] _test_extension.c
[edit]
[-] test_stack_saved.py
[edit]
[-] test_cpp.py
[edit]
[-] test_weakref.py
[edit]
[-] fail_switch_three_greenlets2.py
[edit]
[-] fail_initialstub_already_started.py
[edit]
[-] leakcheck.py
[edit]
[-] fail_cpp_exception.py
[edit]
[-] test_contextvars.py
[edit]
[-] _test_extension_cpp.cpython-312-x86_64-linux-gnu.so
[edit]
[-] test_leaks.py
[edit]
[-] test_generator_nested.py
[edit]
[-] fail_switch_three_greenlets.py
[edit]