Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.11 alpha 6 support #1872

Closed
wants to merge 1 commit into from
Closed

Add Python 3.11 alpha 6 support #1872

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Contributor

@vstinner vstinner commented Mar 1, 2022

  • On Python 3.11a6 and newer, get the PyFrameObject structure from
    the internal C API ("internal/pycore_frame.h").

  • On Python 3.9 and newer, use PyFrame_GetBack() and
    PyFrame_GetCode().

  • Add frame getter and setter functions to greenlet:

    • get_f_code(frame)
    • set_f_lineno(frame, lineno)
    • set_f_code(frame, code)
  • greenlet.h: the CFrame type has been renamed to _PyCFrame.

@vstinner
Copy link
Contributor Author

vstinner commented Mar 1, 2022

Draft PR: Python 3.11a6 has not been released yet.

* On Python 3.11a6 and newer, get the PyFrameObject structure from
  the internal C API ("internal/pycore_frame.h").
* On Python 3.9 and newer, use PyFrame_GetBack() and
  PyFrame_GetCode().
* Add frame getter and setter functions to greenlet:

  * get_f_code(frame)
  * set_f_lineno(frame, lineno)
  * set_f_code(frame, code)

* greenlet.h: the CFrame type has been renamed to _PyCFrame.
@vstinner
Copy link
Contributor Author

Draft PR: Python 3.11a6 has not been released yet.

It has been released: https://pythoninsider.blogspot.com/2022/03/python-3110a6-is-available.html

@vstinner vstinner marked this pull request as ready for review March 14, 2022 10:00
@vstinner
Copy link
Contributor Author

gevent testing / manylinux_arm64 (3.9) (pull_request) Failing after 33m — manylinux_arm64 (3.9)

The PyFrame_GetCode() function is missing:

Successfully setup CPython (3.9.10)
(...)
latest: Pulling from pypa/manylinux2014_aarch64
(...)
Building /opt/python/cp36-cp36m Python 3.6.15
(...)
running build_ext
(...)
creating build/temp.linux-aarch64-3.6
(...)
ImportError: /opt/python/cp36-cp36m/lib/python3.6/site-packages/gevent/_gevent_cgreenlet.cpython-36m-aarch64-linux-gnu.so: undefined symbol: PyFrame_GetCode

@gvanrossum
Copy link

That's referencing 3.6. So it needs to be ifdef'ed out for older Python versions?

@ncoghlan
Copy link

Please don't merge this yet, as the API changes are not final: https://discuss.python.org/t/proposal-rename-pyinterpreterframe-struct-as-py-framedata/14213/7

@ncoghlan
Copy link

Don't worry about my previous comment - we'll make sure code that works against 3.11a6 keeps working until faster-cpython/ideas#309 provides a proper public API for the relevant frame manipulation tasks (although feel free to chime in there on the public API that you'd like to see to avoid having to delve into frame object internals)

@gvanrossum
Copy link

@ncoghlan Will wheels build for 3.11a6 continue to work?

@ncoghlan
Copy link

Yes, after looking at this PR and Victor's other PRs from the 3.11a6 changes, I realised that any change I proposed needed to be both source and binary compatible to avoid causing excessive hassle for the performance work (even if I might wish the situation were otherwise)

@gvanrossum
Copy link

Please merge.

@vstinner
Copy link
Contributor Author

Please merge.

Sadly, some CI tests are failing :-( So far, I failed to understand why it's failing. It seems like a real bug in my PR, but I don't know how to reproduce it (see my previous comments).

@hroncok
Copy link

hroncok commented Jun 1, 2022

I've tried using this patch in Fedora together with both greenlet 2.0.0a2 and with greenlet 1.1.2 + backported Python 3.11 support. With greenlet 2.0.0a2, I was hitting python-greenlet/greenlet@5bbd0fc and worked around it.

Either way, I ended up with ValueError: types.CodeType size changed, may indicate binary incompatibility. Expected 168 from C header, got 160 from PyObject

@gvanrossum
Copy link

Either way, I ended up with ValueError: types.CodeType size changed, may indicate binary incompatibility. Expected 168 from C header, got 160 from PyObject

Can you link to where that error is generated? (Presumably somewhere in greenlet?) That message is likely correct and may point to a solution (rebuild something using newer header files)?

@hroncok
Copy link

hroncok commented Jun 1, 2022

Can you link to where that error is generated?

Not sure what you mean exactly. The output/traceback i get is:

+ /usr/bin/python3 -m gevent.tests
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/__init__.py", line 90, in <module>
    from gevent.greenlet import Greenlet, joinall, killall
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/greenlet.py", line 1189, in <module>
    import_c_accel(globals(), 'gevent._greenlet')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/_util.py", line 148, in import_c_accel
    mod = importlib.import_module(cname)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/gevent/greenlet.py", line 1, in init gevent._gevent_cgreenlet
    # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
                                                          ^^
ValueError: types.CodeType size changed, may indicate binary incompatibility. Expected 168 from C header, got 160 from PyObject
+ :
+ cd src/gevent/tests
+ GEVENT_FILE=thread
+ /usr/bin/python3 -mgevent.tests test__subprocess.py test__subprocess_interrupted.py test__subprocess_poll.py
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/__init__.py", line 90, in <module>
    from gevent.greenlet import Greenlet, joinall, killall
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/greenlet.py", line 1189, in <module>
    import_c_accel(globals(), 'gevent._greenlet')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/_util.py", line 148, in import_c_accel
    mod = importlib.import_module(cname)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/gevent/greenlet.py", line 1, in init gevent._gevent_cgreenlet
ValueError: types.CodeType size changed, may indicate binary incompatibility. Expected 168 from C header, got 160 from PyObject

Both greenlet and gevent are built against the same headers from Python 3.11.0b3. But Cython was built on a previous Python release, let me try to rebuild that one on b3 as well if it makes a difference.

@hroncok
Copy link

hroncok commented Jun 1, 2022

But Cython was built on a previous Python release, let me try to rebuild that one on b3 as well if it makes a difference.

No difference.

@gvanrossum
Copy link

Can you link to where that error is generated?

Not sure what you mean exactly. The output/traceback i get is:

I meant what source file raises that error. I haven't found it myself (I don't see it in the CPython source tree), but it occurs a lot in StackOverflow, usually for a numpy type. Since it isn't Cython either, what other tool or library could be raising this?

@gvanrossum
Copy link

Found it in Cython: https://github.com/cython/cython/blob/6ac2422b48b689b021a48dff9ee14095232baafe/Cython/Utility/ImportExport.c#L526-L539

@hroncok
Copy link

hroncok commented Jun 1, 2022

$ rg 'may indicate binary incompatibility' /var/lib/mock/fedora-rawhide-python311/root/
/var/lib/mock/fedora-rawhide-python311/root/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/src/debug/python-gevent-21.12.0-2.fc37.x86_64/src/gevent/_generated_include/TypeImport_impl_d5cd5554eec5ba197a2a05afc9fb56ba.h
35:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
42:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
49:            "%s.%s size changed, may indicate binary incompatibility. "

/var/lib/mock/fedora-rawhide-python311/root/builddir/build/BUILD/gevent-21.12.0/src/gevent/_generated_include/TypeImport_impl_2a4fd5b6753492bf016ba4bb4b7299ed55d65264.h
35:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
42:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
49:            "%s.%s size changed, may indicate binary incompatibility. "

/var/lib/mock/fedora-rawhide-python311/root/builddir/build/BUILD/gevent-21.12.0/src/gevent/_generated_include/TypeImport_impl_d5cd5554eec5ba197a2a05afc9fb56ba.h
35:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
42:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
49:            "%s.%s size changed, may indicate binary incompatibility. "

/var/lib/mock/fedora-rawhide-python311/root/usr/lib64/python3.11/site-packages/Cython/Utility/ImportExport.c
363:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
370:            "%.200s.%.200s size changed, may indicate binary incompatibility. "
377:            "%s.%s size changed, may indicate binary incompatibility. "

@gvanrossum
Copy link

I'm guessing something that's generated by Cython needs to be regenerated. Just using a newer Cython doesn't fix that.

@hroncok
Copy link

hroncok commented Jun 1, 2022

We already had:

# Force re-cythonizing the sources
rm $(grep -rl '/\* Generated by Cython')

I've added:

rm src/gevent/_generated_include/*

Still getting the same error. I am out of ideas.

@gvanrossum
Copy link

Me too. :-( Try reading the code that gets executed during that _bootstrap._gcd_import call in the traceback?

@hroncok
Copy link

hroncok commented Jun 1, 2022

If I eliminate the gcd import, I get:

$ cp /builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/_gevent_cgreenlet.cpython-311-x86_64-linux-gnu.so .

$ python3
Python 3.11.0b3 (main, Jun  1 2022, 00:00:00) [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _gevent_cgreenlet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/gevent/greenlet.py", line 1, in init gevent._gevent_cgreenlet
ValueError: types.CodeType size changed, may indicate binary incompatibility. Expected 168 from C header, got 160 from PyObject

It keeps saying file "src/gevent/greenlet.py", line 1 and the Cython-annotated file shows:

+0001: # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.

  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

I'm afraid this is too many layers deep for me for 1 AM. Thanks @gvanrossum, for the pointers anyway. I will sleep on it and will bother @vstinner when he is back from Kernel Recipes :)

@hroncok
Copy link

hroncok commented Jun 3, 2022

This is generated by Cython:

__Pyx_ImportType(__pyx_t_2, "types", "CodeType", sizeof(PyCodeObject), __Pyx_ImportType_CheckSize_Warn);

Hence, the code in https://github.com/cython/cython/blob/6ac2422b48b689b021a48dff9ee14095232baafe/Cython/Utility/ImportExport.c#L515 and further more or less does:

result = PyObject_GetAttrString(PyImport_ImportModule("types"), "CodeType");
basicsize = ((PyTypeObject *)result)->tp_basicsize;
if ((size_t)basicsize < sizeof(PyCodeObject)) { ... error ... }

types.CodeType->tp_basicsize is 160 and sizeof(PyCodeObject) is 168. Let me try to reproduce this in isolation to avoid outdated headers in gevent, greenlet and/or Cython.

See https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#external-extension-types for an explanation for the check.

@hroncok
Copy link

hroncok commented Jun 3, 2022

In Python 3.11.0b3:

PyObject *result;
result = PyObject_GetAttrString(PyImport_ImportModule("types"), "CodeType");
return PyLong_FromLong(((PyTypeObject *)result)->tp_basicsize);

Returns 160.

return PyLong_FromLong(sizeof(PyCodeObject));

Returns 168.

No extra headers, just pure CPython. So either types.CodeType isn't PyCodeObject or this is a bug in CPython, right?

@hroncok
Copy link

hroncok commented Jun 3, 2022

Apparently PyCodeObject is types.CodeType:

PyCodeObject *result = PyCode_NewEmpty("", "", 0);
return (PyObject*)result;
>>> import types
>>> type(reporoducer.gimme_pycodeobject()) is types.CodeType
True

@encukou
Copy link
Contributor

encukou commented Jun 3, 2022

The issue is that PyCodeObject is defined with a trailing variable-sized array, defined with size one to appease the old C gods:

struct PyCodeObject {
   ... (lots of fields) ...
   char co_code_adaptive[1];
}

and the size fields are then:

    .tp_basicsize = offsetof(PyCodeObject, co_code_adaptive),
    .tp_itemsize = sizeof(_Py_CODEUNIT),

(code simplified for clarity)

This is new in 3.11, but tuple or int have been doing essentially the same thing (with ob_item/ob_digit) for a long time.

The basicsize docs say:

the only correct way to get an initializer for the tp_basicsize is to use the sizeof operator on the struct used to declare the instance layout.

The wording could be relaxed (or include offsetoff as well), but that's perhaps nitpicking too much.

Anyway, Cython checks that the struct it's using fits in tp_basicsize, which won't work with a 1-sized “flexible” array.

I guess Cython should skip/relax the check if tp_itemsize is nonzero?
@scoder, does that sound reasonable from your PoV?

(Edit: this check can be controlled using Cython's check_size clause, but in this case -- sizeof(...) > tp_basicsize -- it fails regardless of the setting.)

@hroncok
Copy link

hroncok commented Jun 3, 2022

Thanks! If I do that (itemsize.patch for Cython 0.29.30), the next problem is:

AttributeError: module 'types' has no attribute '_PyInterpreterFrame'

Which is indeed true, ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]: cannot be used because types._PyInterpreterFrame does not exist.

cdef void* f_back
IF PY311A6:
cdef extern from "internal/pycore_frame.h":
ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking I could do something like:

Suggested change
ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]:
ctypedef struct _PyInterpreterFrame:

But that way, I get:

Error compiling Cython file:
------------------------------------------------------------
...
        pass

IF PY311A6:
    cdef extern from "internal/pycore_frame.h":
        ctypedef struct _PyInterpreterFrame:
            cdef CodeType f_code
           ^
------------------------------------------------------------

src/gevent/_gevent_cgreenlet.pxd:63:12: Expected an identifier, found 'cdef'

And when I remove cdef from cdef CodeType f_code as well, I get:

C struct/union member cannot be a Python object

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In if I cascade with using structs:

cdef extern from "Python.h":

    ctypedef struct PyCodeObject:
        pass

...

    cdef extern from "internal/pycore_frame.h":
        ctypedef struct _PyInterpreterFrame:
            PyCodeObject* f_code

I end up with:

cdef inline void set_f_code(FrameType frame, CodeType code):
    IF PY311A6:
        frame.f_frame.f_code = code
                              ^
------------------------------------------------------------

src/gevent/_gevent_cgreenlet.pxd:114:31: Cannot convert Python object to 'PyCodeObject *'

And I am getting into a seemingly neverending hole.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it compile:

diff --git a/src/gevent/_gevent_cgreenlet.pxd b/src/gevent/_gevent_cgreenlet.pxd
index 246773e..47669dc 100644
--- a/src/gevent/_gevent_cgreenlet.pxd
+++ b/src/gevent/_gevent_cgreenlet.pxd
@@ -57,13 +57,16 @@ cdef extern from "Python.h":
     ctypedef class types.CodeType [object PyCodeObject]:
         pass
 
+    ctypedef struct PyCodeObject:
+        pass
+
 IF PY311A6:
     cdef extern from "internal/pycore_frame.h":
-        ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]:
-            cdef CodeType f_code
+        ctypedef struct _PyInterpreterFrame:
+            PyCodeObject* f_code
 
         ctypedef class types.FrameType [object PyFrameObject]:
-            cdef _PyInterpreterFrame f_frame
+            cdef _PyInterpreterFrame* f_frame
             # Accessing the f_lineno directly doesn't work. There is an accessor
             # function, PyFrame_GetLineNumber that is needed to turn the raw line number
             # into the executing line number.
@@ -108,7 +111,7 @@ cdef inline CodeType get_f_code(FrameType frame):
 
 cdef inline void set_f_code(FrameType frame, CodeType code):
     IF PY311A6:
-        frame.f_frame.f_code = code
+        frame.f_frame.f_code = <PyCodeObject *>code
     ELSE:
         frame.f_code = code

But it fails on rutime with:

    File "src/gevent/greenlet.py", line 689, in gevent._gevent_cgreenlet.Greenlet.spawn
      g = cls(*args, **kwargs)
    File "src/gevent/greenlet.py", line 301, in gevent._gevent_cgreenlet.Greenlet.__init__
      self.spawning_stack = _extract_stack(self.spawning_stack_limit)
    File "src/gevent/greenlet.py", line 164, in gevent._gevent_cgreenlet._extract_stack
      set_f_lineno(older_Frame.f_lineno, get_f_lineno(frame)) # pylint:disable=undefined-variable
  TypeError: Cannot convert int to frame

@gvanrossum
Copy link

Maybe @brandtbucher can help here?

@brandtbucher
Copy link

Maybe @brandtbucher can help here?

Perhaps, but maybe somebody could clarify the exact problem that we're trying to solve at this point in the journey?

From what I understand at this point, the issue is that Cython isn't recognizing PyCodeObject as variable-sized. Its basicsize is offsetof(PyCodeObject, co_code_adaptive) (which apparently is 160) and its itemsize is sizeof(_Py_CODEUNIT) (or 2). I'm not sure why Cython needs to know the size of a given PyCodeObject, but this can be pretty easily computed with something like:

Py_TYPE(o)->tp_basicsize + Py_SIZE(o) * Py_TYPE(o)->tp_itemsize

I'm worried I'm likely just repeating what people might already know, though. I've also never used Cython, so lines like ctypedef class types._PyInterpreterFrame [object _PyInterpreterFrame]: are mostly gibberish to me.

@vstinner
Copy link
Contributor Author

vstinner commented Jun 7, 2022

I reported the issue to Cython: cython/cython#4827 I suggest to continue discussing the Cython there, since this is a PR on the gevent project ;-)

@encukou
Copy link
Contributor

encukou commented Jun 7, 2022

Hm, the contents of CodeType aren't actually used, are they?
Perhaps the declaration could be just:

    ctypedef class types.CodeType [object PyObject]:

@da-woods
Copy link

da-woods commented Jun 8, 2022

Quoted from your Python issue:

But I'm not a Cython expert and I don't know how to implement set_f_code() on Python 3.11. This function needs to set _PyInterpreterFrame.f_code, but I don't know how to get the _PyInterpreterFrame structure in Cython.

One thing you can do is include literal c code:

cdef extern from *:
   """
   void set_f_code() {
      // implementation goes here
   }
   """
   void set_f_code()

Of course the arguments still need to be types that Cython understands, but you may find that lets you hide some of the details from Cython

@hroncok
Copy link

hroncok commented Jun 8, 2022

Alright, @encukou reverted some of the changes here and replaced them with others. I've rebased and pushed the result to https://github.com/hroncok/gevent/commits/py311b3 and will test with that in Fedora.

Note that there are 2 unresolved problems - tets failures/errors:

We might leak some references:

  ======================================================================
  FAIL: test_no_refcycle_through_target (gevent.tests.test__threading_2.ThreadTests.test_no_refcycle_through_target)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/tests/test__threading_2.py", line 434, in test_no_refcycle_through_target
      self.assertIsNone(weak_cyclic_object(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AssertionError: <gevent.tests.test__threading_2.ThreadTests.test_no_refcycle_through_target.<locals>.RunSelfFunction object at 0x7fbc7cd58e90> is not None : 3 references still around
  
  ----------------------------------------------------------------------

And greenlet names have changed:

  ======================================================================
  FAIL: test_tree (gevent.tests.test__util.TestTree.test_tree)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/testing/errorhandler.py", line 47, in restore_fatal_error_wrapper
      return method(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/testing/errorhandler.py", line 34, in fatal_error_wrapper
      return method(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/testing/testcase.py", line 182, in timeout_wrapper
      return method(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/builddir/build/BUILDROOT/python-gevent-21.12.0-2.fc37.x86_64/usr/lib64/python3.11/site-packages/gevent/tests/test__util.py", line 195, in test_tree
      self.assertEqual(expected, value)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AssertionError: '<gre[149 chars]--- <HUB>\n :          Parent: <greenlet.green[1142 chars]HUB>' != '<gre[149 chars]--- <Greenlet "Greenlet-0" at X: _run>; finish[5547 chars]HUB>'
    <greenlet.greenlet object at X>
     :    Parent: None
     :    Greenlet Locals:
     :      Local <class '__main__.MyLocal'> at X
     :        {'foo': 42}
  +  +--- <Greenlet "Greenlet-0" at X: _run>; finished
  +  :          Parent: <HUB>
     +--- <HUB>
     :          Parent: <greenlet.greenlet object at X>
  -  +--- <Greenlet "Greenlet-1" at X: t2>; finished with value <Greenlet "CustomName-0" at 0x
  ?                                    ^^                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  +  +--- <Greenlet "Greenlet-1" at X: _run>; finished with value 49
  ?                                    ^^^^                       ^^
     :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-2" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-3" at X: _run>; finished with value 36
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-4" at X: _run>; finished with value b''
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-5" at X: _run>; finished with value b''
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-6" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-7" at X: _run>; finished with value [None, None]
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-8" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-9" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-10" at X: _run>; finished with value 36
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-11" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-12" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-13" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-14" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-15" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-16" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-17" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-18" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-19" at X: _run>; finished with value [None, None, None, None, None,
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-20" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-21" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-22" at X: _run>; finished with value 36
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-23" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-24" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-25" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-26" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-27" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-28" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-29" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-30" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-31" at X: _run>; finished with value [None, None, None, None]
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-32" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-33" at X: _run>; finished with value 49
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-34" at X: _run>; finished with value 36
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-35" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-36" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-37" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-38" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-39" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-40" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-41" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-42" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-43" at X: _run>; finished with value [None, None, None, None, None,
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-44" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-45" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-46" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-47" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-48" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMap "Greenlet-49" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <IMapUnordered "Greenlet-50" at X: _run>; finished
  +  :          Parent: <HUB>
  +  +--- <Greenlet "Greenlet-52" at X: t2>; finished with value <Greenlet "CustomName-51" at 0
  +  :          Parent: <HUB>
  -  |    +--- <Greenlet "CustomName-0" at X: t1>; finished with exception ExpectedException()
  ?                                  ^
  +  |    +--- <Greenlet "CustomName-51" at X: t1>; finished with exception ExpectedException()
  ?                                  ^^
     :                Parent: <HUB>
  -  +--- <Greenlet "Greenlet-2" at X: t2>; finished with value <Greenlet "CustomName-4" at 0x
  ?                           ^                                                       ^      -
  +  +--- <Greenlet "Greenlet-53" at X: t2>; finished with value <Greenlet "CustomName-55" at 0
  ?                           ^^                                                       ^^
     :          Parent: <HUB>
  -  |    +--- <Greenlet "CustomName-4" at X: t1>; finished with exception ExpectedException()
  ?                                  ^
  +  |    +--- <Greenlet "CustomName-55" at X: t1>; finished with exception ExpectedException()
  ?                                  ^^
     :                Parent: <HUB>
  -  +--- <Greenlet "Greenlet-3" at X: t3>; finished with value <Greenlet "Greenlet-5" at X
  +  +--- <Greenlet "Greenlet-54" at X: t3>; finished with value <Greenlet "Greenlet-56" at X
     :          Parent: <HUB>
     :          Spawn Tree Locals
     :          {'stl': 'STL'}
  -  |    +--- <Greenlet "Greenlet-5" at X: t2>; finished with value <Greenlet "CustomName-6" at 0x
  ?                                                                                        ^      -
  +  |    +--- <Greenlet "Greenlet-56" at X: t2>; finished with value <Greenlet "CustomName-57" at 0
  ?                                 +                                                       ^^
     :                Parent: <HUB>
  -  |         +--- <Greenlet "CustomName-6" at X: t1>; finished with exception ExpectedException()
  ?                                       ^
  +  |         +--- <Greenlet "CustomName-57" at X: t1>; finished with exception ExpectedException()
  ?                                       ^^
     :                      Parent: <HUB>
  -  +--- <Greenlet "Greenlet-7" at X: <bound method GreenletTree.current_tree of <class 'gevent.util.GreenletTree'>>>; finished with value <gevent.util.GreenletTree obje
  ?                           ^
  +  +--- <Greenlet "Greenlet-58" at X: <bound method GreenletTree.current_tree of <class 'gevent.util.GreenletTree'>>>; finished with value <gevent.util.GreenletTree obje
  ?                           ^^
                Parent: <HUB>
  
  ----------------------------------------------------------------------

_setuputils.py Show resolved Hide resolved
@jamadden
Copy link
Member

jamadden commented Oct 8, 2022

Thank you all for your help and patience. #1908, based on this PR and passing all tests on 3.11rc2, has been merged and released as gevent-22.8.0; binary wheels will be in the process of building and uploading for the next several hours.

@vstinner vstinner deleted the py311a6 branch October 10, 2022 14:09
@vstinner
Copy link
Contributor Author

Wow, this is really cool! Thanks @jamadden for your nice project! It's great that it's ready before Python 3.11 final release.

@vstinner
Copy link
Contributor Author

FYI we (Fedora) maintainted a downstream patch to unblock Python 3.11 until a new gevent version would be released: https://src.fedoraproject.org/rpms/python-gevent/blob/rawhide/f/master...hroncok:py311b3.patch

@kraj
Copy link

kraj commented Oct 12, 2022

FYI we (Fedora) maintainted a downstream patch to unblock Python 3.11 until a new gevent version would be released: https://src.fedoraproject.org/rpms/python-gevent/blob/rawhide/f/master...hroncok:py311b3.patch

do we still need it with 22.08.0 release or just 21.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants