Add Python 3.8 support: use CodeType.replace() if available
Backport upstream change:806713333aRemove also 0001-always-obey-GEVENT_NO_CFFI_BUILD.patch, the change has bene merged into gevent 1.3:14b28c678f
This commit is contained in:
parent
1c32ec07c1
commit
9ac63267e9
3 changed files with 37 additions and 44 deletions
26
0001-code-replace.patch
Normal file
26
0001-code-replace.patch
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
commit 1b84da94c2aa2d171881482c22298ad189b79764
|
||||
Author: Victor Stinner <vstinner@redhat.com>
|
||||
Date: Tue Jun 11 16:38:52 2019 +0200
|
||||
|
||||
Use CodeType.replace() if available
|
||||
|
||||
Port _tblib.Traceback to Python 3.8: use code.replace() method if
|
||||
available.
|
||||
|
||||
diff --git a/src/gevent/_tblib.py b/src/gevent/_tblib.py
|
||||
index 13364012..b9553a9e 100644
|
||||
--- a/src/gevent/_tblib.py
|
||||
+++ b/src/gevent/_tblib.py
|
||||
@@ -198,7 +198,11 @@ class Traceback(object):
|
||||
while current:
|
||||
f_code = current.tb_frame.f_code
|
||||
code = compile('\n' * (current.tb_lineno - 1) + 'raise __traceback_maker', current.tb_frame.f_code.co_filename, 'exec')
|
||||
- if PY3:
|
||||
+ if hasattr(code, "replace"):
|
||||
+ # Python 3.8 and newer
|
||||
+ code = code.replace(co_argcount=0,
|
||||
+ co_freevars=(), co_cellvars=())
|
||||
+ elif PY3:
|
||||
code = CodeType(
|
||||
0, code.co_kwonlyargcount,
|
||||
code.co_nlocals, code.co_stacksize, code.co_flags,
|
||||
Loading…
Add table
Add a link
Reference in a new issue