✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ server366.web-hosting.com ​🇻​♯➤ 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 67.223.118.204 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.36
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/hc_python/lib/python3.12/site-packages/greenlet/tests//_test_extension.c
/* This is a set of functions used by test_extension_interface.py to test the
 * Greenlet C API.
 */

#include "../greenlet.h"

#ifndef Py_RETURN_NONE
#    define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
#endif

#define TEST_MODULE_NAME "_test_extension"

// CAUTION: MSVC is stupidly picky:
//
// "The compiler ignores, without warning, any __declspec keywords
// placed after * or & and in front of the variable identifier in a
// declaration."
// (https://docs.microsoft.com/en-us/cpp/cpp/declspec?view=msvc-160)
//
// So pointer return types must be handled differently (because of the
// trailing *), or you get inscrutable compiler warnings like "error
// C2059: syntax error: ''"
//
// In C23, there is a standard syntax for attributes, and
// GCC defines an attribute to use with this: [[gnu:noinline]].
// In the future, this is expected to become standard.

#if defined(__GNUC__) || defined(__clang__)
/* We used to check for GCC 4+ or 3.4+, but those compilers are
   laughably out of date. Just assume they support it. */
#    define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#elif defined(_MSC_VER)
/* We used to check for  && (_MSC_VER >= 1300) but that's also out of date. */
#    define UNUSED(x) UNUSED_ ## x
#endif

static PyObject*
test_switch(PyObject* UNUSED(self), PyObject* greenlet)
{
    PyObject* result = NULL;

    if (greenlet == NULL || !PyGreenlet_Check(greenlet)) {
        PyErr_BadArgument();
        return NULL;
    }

    result = PyGreenlet_Switch((PyGreenlet*)greenlet, NULL, NULL);
    if (result == NULL) {
        if (!PyErr_Occurred()) {
            PyErr_SetString(PyExc_AssertionError,
                            "greenlet.switch() failed for some reason.");
        }
        return NULL;
    }
    return result;
}

static PyObject*
test_switch_kwargs(PyObject* UNUSED(self), PyObject* args, PyObject* kwargs)
{
    PyGreenlet* g = NULL;
    PyObject* result = NULL;

    if (!PyArg_ParseTuple(args, "O!", &PyGreenlet_Type, &g)) {
        return NULL;
    }

    if (g == NULL || !PyGreenlet_Check(g)) {
        PyErr_BadArgument();
        return NULL;
    }

    result = PyGreenlet_Switch(g, NULL, kwargs);
    if (result == NULL) {
        if (!PyErr_Occurred()) {
            PyErr_SetString(PyExc_AssertionError,
                            "greenlet.switch() failed for some reason.");
        }
        return NULL;
    }
    return result;
}

static PyObject*
test_getcurrent(PyObject* UNUSED(self))
{
    PyGreenlet* g = PyGreenlet_GetCurrent();
    if (g == NULL || !PyGreenlet_Check(g) || !PyGreenlet_ACTIVE(g)) {
        PyErr_SetString(PyExc_AssertionError,
                        "getcurrent() returned an invalid greenlet");
        Py_XDECREF(g);
        return NULL;
    }
    Py_DECREF(g);
    Py_RETURN_NONE;
}

static PyObject*
test_setparent(PyObject* UNUSED(self), PyObject* arg)
{
    PyGreenlet* current;
    PyGreenlet* greenlet = NULL;
    PyObject* switch_result = NULL;

    if (arg == NULL || !PyGreenlet_Check(arg)) {
        PyErr_BadArgument();
        return NULL;
    }
    if ((current = PyGreenlet_GetCurrent()) == NULL) {
        return NULL;
    }
    greenlet = (PyGreenlet*)arg;
    if (PyGreenlet_SetParent(greenlet, current)) {
        Py_DECREF(current);
        return NULL;
    }
    Py_DECREF(current);

    switch_result = PyGreenlet_Switch(greenlet, NULL, NULL);
    if (switch_result == NULL) {
        return NULL;
    }
    Py_DECREF(switch_result);
    Py_RETURN_NONE;
}

static PyObject*
test_new_greenlet(PyObject* UNUSED(self), PyObject* callable)
{
    PyObject* result = NULL;
    PyGreenlet* greenlet = PyGreenlet_New(callable, NULL);

    if (!greenlet) {
        return NULL;
    }

    result = PyGreenlet_Switch(greenlet, NULL, NULL);
    Py_CLEAR(greenlet);
    if (result == NULL) {
        return NULL;
    }

    return result;
}

static PyObject*
test_raise_dead_greenlet(PyObject* UNUSED(self))
{
    PyErr_SetString(PyExc_GreenletExit, "test GreenletExit exception.");
    return NULL;
}

static PyObject*
test_raise_greenlet_error(PyObject* UNUSED(self))
{
    PyErr_SetString(PyExc_GreenletError, "test greenlet.error exception");
    return NULL;
}

static PyObject*
test_throw(PyObject* UNUSED(self), PyGreenlet* g)
{
    const char msg[] = "take that sucka!";
    PyObject* msg_obj = Py_BuildValue("s", msg);
    PyGreenlet_Throw(g, PyExc_ValueError, msg_obj, NULL);
    Py_DECREF(msg_obj);
    if (PyErr_Occurred()) {
        return NULL;
    }
    Py_RETURN_NONE;
}

static PyObject*
test_throw_exact(PyObject* UNUSED(self), PyObject* args)
{
    PyGreenlet* g = NULL;
    PyObject* typ = NULL;
    PyObject* val = NULL;
    PyObject* tb = NULL;

    if (!PyArg_ParseTuple(args, "OOOO:throw", &g, &typ, &val, &tb)) {
        return NULL;
    }

    PyGreenlet_Throw(g, typ, val, tb);
    if (PyErr_Occurred()) {
        return NULL;
    }
    Py_RETURN_NONE;
}

static PyObject*
getcurrent_api(PyObject* UNUSED(self))
{
    return (PyObject*)PyGreenlet_GetCurrent();

}

static PyMethodDef test_methods[] = {
    {"test_switch",
     (PyCFunction)test_switch,
     METH_O,
     "Switch to the provided greenlet sending provided arguments, and \n"
     "return the results."},
    {"test_switch_kwargs",
     (PyCFunction)test_switch_kwargs,
     METH_VARARGS | METH_KEYWORDS,
     "Switch to the provided greenlet sending the provided keyword args."},
    {"test_getcurrent",
     (PyCFunction)test_getcurrent,
     METH_NOARGS,
     "Test PyGreenlet_GetCurrent()"},
    {"test_setparent",
     (PyCFunction)test_setparent,
     METH_O,
     "Se the parent of the provided greenlet and switch to it."},
    {"test_new_greenlet",
     (PyCFunction)test_new_greenlet,
     METH_O,
     "Test PyGreenlet_New()"},
    {"test_raise_dead_greenlet",
     (PyCFunction)test_raise_dead_greenlet,
     METH_NOARGS,
     "Just raise greenlet.GreenletExit"},
    {"test_raise_greenlet_error",
     (PyCFunction)test_raise_greenlet_error,
     METH_NOARGS,
     "Just raise greenlet.error"},
    {"test_throw",
     (PyCFunction)test_throw,
     METH_O,
     "Throw a ValueError at the provided greenlet"},
    {"test_throw_exact",
     (PyCFunction)test_throw_exact,
     METH_VARARGS,
     "Throw exactly the arguments given at the provided greenlet"},
    {
        "getcurrent_api",
        (PyCFunction)getcurrent_api,
        METH_NOARGS,
        "Direct call to the PyGreenlet_GetCurrent API."},
    {NULL, NULL, 0, NULL}
};


#define INITERROR return NULL

static struct PyModuleDef moduledef = {PyModuleDef_HEAD_INIT,
                                       TEST_MODULE_NAME,
                                       NULL,
                                       0,
                                       test_methods,
                                       NULL,
                                       NULL,
                                       NULL,
                                       NULL};

PyMODINIT_FUNC
PyInit__test_extension(void)
{
    PyObject* module = NULL;
    module = PyModule_Create(&moduledef);

    if (module == NULL) {
        return NULL;
    }

    PyGreenlet_Import();
#ifdef Py_GIL_DISABLED
    PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
    return module;
}


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
11 Jun 2026 5.00 AM
root / root
0755
__pycache__
--
11 Jun 2026 5.00 AM
root / root
0755
__init__.py
9.508 KB
11 Jun 2026 5.00 AM
root / root
0644
_test_extension.c
7.074 KB
11 Jun 2026 5.00 AM
root / root
0644
_test_extension.cpython-312-x86_64-linux-gnu.so
16.922 KB
11 Jun 2026 5.00 AM
root / root
0755
_test_extension_cpp.cpp
6.556 KB
11 Jun 2026 5.00 AM
root / root
0644
_test_extension_cpp.cpython-312-x86_64-linux-gnu.so
57.352 KB
11 Jun 2026 5.00 AM
root / root
0755
fail_clearing_run_switches.py
1.233 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_cpp_exception.py
0.962 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_initialstub_already_started.py
1.915 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_slp_switch.py
0.512 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_switch_three_greenlets.py
0.934 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_switch_three_greenlets2.py
1.255 KB
11 Jun 2026 5.00 AM
root / root
0644
fail_switch_two_greenlets.py
0.798 KB
11 Jun 2026 5.00 AM
root / root
0644
leakcheck.py
12.317 KB
11 Jun 2026 5.00 AM
root / root
0644
test_contextvars.py
9.34 KB
11 Jun 2026 5.00 AM
root / root
0644
test_cpp.py
3.09 KB
11 Jun 2026 5.00 AM
root / root
0644
test_extension_interface.py
4.707 KB
11 Jun 2026 5.00 AM
root / root
0644
test_gc.py
2.854 KB
11 Jun 2026 5.00 AM
root / root
0644
test_generator.py
1.211 KB
11 Jun 2026 5.00 AM
root / root
0644
test_generator_nested.py
3.631 KB
11 Jun 2026 5.00 AM
root / root
0644
test_greenlet.py
49.312 KB
11 Jun 2026 5.00 AM
root / root
0644
test_greenlet_trash.py
8.173 KB
11 Jun 2026 5.00 AM
root / root
0644
test_interpreter_shutdown.py
32.29 KB
11 Jun 2026 5.00 AM
root / root
0644
test_leaks.py
18.791 KB
11 Jun 2026 5.00 AM
root / root
0644
test_stack_saved.py
0.436 KB
11 Jun 2026 5.00 AM
root / root
0644
test_throw.py
3.625 KB
11 Jun 2026 5.00 AM
root / root
0644
test_tracing.py
8.353 KB
11 Jun 2026 5.00 AM
root / root
0644
test_version.py
1.492 KB
11 Jun 2026 5.00 AM
root / root
0644
test_weakref.py
0.862 KB
11 Jun 2026 5.00 AM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF