Blob Blame History Raw
From 7ab1ac59010b8907a72cd43b1c603fb87845d085 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Mon, 10 Jun 2019 14:02:52 +0200
Subject: [PATCH] sys.set_coroutine_wrapper is removed in Python 3.8

The functions `sys.set_coroutine_wrapper` and `sys.get_coroutine_wrapper`,
which were provisionally added to Python 3.5 and deprecated in Python 3.7,
are removed in Python 3.8.

uvloop doesn't use them since Python 3.7, but they remained defined
in stdlib.pxi, leading to AttributeErrors on Python 3.8+.

This makes the definition fallback to None if such functions don't exist.

Fixes https://github.com/MagicStack/uvloop/issues/251
---
 uvloop/includes/stdlib.pxi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/uvloop/includes/stdlib.pxi b/uvloop/includes/stdlib.pxi
index 8c14ddd..6a08f31 100644
--- a/uvloop/includes/stdlib.pxi
+++ b/uvloop/includes/stdlib.pxi
@@ -111,8 +111,8 @@ cdef stat_S_ISSOCK = stat.S_ISSOCK
 
 cdef sys_ignore_environment = sys.flags.ignore_environment
 cdef sys_exc_info = sys.exc_info
-cdef sys_set_coroutine_wrapper = sys.set_coroutine_wrapper
-cdef sys_get_coroutine_wrapper = sys.get_coroutine_wrapper
+cdef sys_set_coroutine_wrapper = getattr(sys, 'set_coroutine_wrapper', None)
+cdef sys_get_coroutine_wrapper = getattr(sys, 'get_coroutine_wrapper', None)
 cdef sys_getframe = sys._getframe
 cdef sys_version_info = sys.version_info
 
-- 
2.21.0