__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

aptanhua@216.73.217.0: ~ $
import gc
import subprocess
import unittest

import greenlet
import objgraph

from . import WIN
from . import TestCase
from . import _test_extension_cpp


class CPPTests(TestCase):
    def test_exception_switch(self):
        greenlets = []
        for i in range(4):
            g = greenlet.greenlet(_test_extension_cpp.test_exception_switch)
            g.switch(i)
            greenlets.append(g)
        for i, g in enumerate(greenlets):
            self.assertEqual(g.switch(), i)

    def _do_test_unhandled_exception(self, target):
        import os
        import sys
        script = os.path.join(
            os.path.dirname(__file__),
            'fail_cpp_exception.py',
        )
        args = [sys.executable, script, target.__name__ if not isinstance(target, str) else target]
        __traceback_info__ = args
        with self.assertRaises(subprocess.CalledProcessError) as exc:
            subprocess.check_output(
                args,
                encoding='utf-8',
                stderr=subprocess.STDOUT
            )

        ex = exc.exception
        expected_exit = self.get_expected_returncodes_for_aborted_process()
        self.assertIn(ex.returncode, expected_exit)
        self.assertIn('fail_cpp_exception is running', ex.output)
        return ex.output


    def test_unhandled_nonstd_exception_aborts(self):
        # verify that plain unhandled throw aborts
        self._do_test_unhandled_exception(_test_extension_cpp.test_exception_throw_nonstd)

    def test_unhandled_std_exception_aborts(self):
        # verify that plain unhandled throw aborts
        self._do_test_unhandled_exception(_test_extension_cpp.test_exception_throw_std)

    @unittest.skipIf(WIN, "XXX: This does not crash on Windows")
    # Meaning the exception is getting lost somewhere...
    def test_unhandled_std_exception_as_greenlet_function_aborts(self):
        # verify that plain unhandled throw aborts
        output = self._do_test_unhandled_exception('run_as_greenlet_target')
        self.assertIn(
            # We really expect this to be prefixed with "greenlet: Unhandled C++ exception:"
            # as added by our handler for std::exception (see TUserGreenlet.cpp), but
            # that's not correct everywhere --- our handler never runs before std::terminate
            # gets called (for example, on arm32).
            'Thrown from an extension.',
            output
        )

    def test_unhandled_exception_in_greenlet_aborts(self):
        # verify that unhandled throw called in greenlet aborts too
        self._do_test_unhandled_exception('run_unhandled_exception_in_greenlet_aborts')


    def test_leak_test_exception_switch_and_do_in_g2(self):
        def raiser():
            raise ValueError("boom")

        gc.collect()
        before = objgraph.count("greenlet")

        for _ in range(1000):
            with self.assertRaises(ValueError):
                _test_extension_cpp.test_exception_switch_and_do_in_g2(raiser)

        gc.collect()
        after = objgraph.count("greenlet")
        leaked = after - before
        self.assertEqual(0, leaked)


if __name__ == '__main__':
    unittest.main()

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 9.51 KB 0644
_test_extension.c File 7.07 KB 0644
_test_extension.cpython-312-x86_64-linux-gnu.so File 16.92 KB 0755
_test_extension_cpp.cpp File 6.56 KB 0644
_test_extension_cpp.cpython-312-x86_64-linux-gnu.so File 57.35 KB 0755
fail_clearing_run_switches.py File 1.23 KB 0644
fail_cpp_exception.py File 985 B 0644
fail_initialstub_already_started.py File 1.92 KB 0644
fail_slp_switch.py File 524 B 0644
fail_switch_three_greenlets.py File 956 B 0644
fail_switch_three_greenlets2.py File 1.25 KB 0644
fail_switch_two_greenlets.py File 817 B 0644
leakcheck.py File 12.32 KB 0644
test_contextvars.py File 9.34 KB 0644
test_cpp.py File 3.09 KB 0644
test_extension_interface.py File 4.71 KB 0644
test_gc.py File 2.85 KB 0644
test_generator.py File 1.21 KB 0644
test_generator_nested.py File 3.63 KB 0644
test_greenlet.py File 49.31 KB 0644
test_greenlet_trash.py File 8.17 KB 0644
test_interpreter_shutdown.py File 32.29 KB 0644
test_leaks.py File 18.79 KB 0644
test_stack_saved.py File 446 B 0644
test_throw.py File 3.63 KB 0644
test_tracing.py File 8.35 KB 0644
test_version.py File 1.49 KB 0644
test_weakref.py File 883 B 0644