Skip to content

Commit 878e416

Browse files
committed
Raise NotImplementedError for contextvars for Python < 3.7
1 parent ed2723f commit 878e416

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tests/test_context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ def test_context_arg(self):
125125
def cb():
126126
pass
127127

128-
with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
128+
with self.assertRaisesRegex(NotImplementedError,
129+
'requires Python 3.7'):
129130
self.loop.call_soon(cb, context=1)
130131

131-
with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
132+
with self.assertRaisesRegex(NotImplementedError,
133+
'requires Python 3.7'):
132134
self.loop.call_soon_threadsafe(cb, context=1)
133135

134-
with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
136+
with self.assertRaisesRegex(NotImplementedError,
137+
'requires Python 3.7'):
135138
self.loop.call_later(0.1, cb, context=1)
136139

137140

uvloop/cbhandles.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ cdef class Handle:
2121
self.context = context
2222
else:
2323
if context is not None:
24-
raise RuntimeError('"context" argument requires Python 3.7')
24+
raise NotImplementedError(
25+
'"context" argument requires Python 3.7')
2526
self.context = None
2627

2728
def __dealloc__(self):
@@ -182,7 +183,8 @@ cdef class TimerHandle:
182183
self.context = context
183184
else:
184185
if context is not None:
185-
raise RuntimeError('"context" argument requires Python 3.7')
186+
raise NotImplementedError(
187+
'"context" argument requires Python 3.7')
186188
self.context = None
187189

188190
if loop._debug:

0 commit comments

Comments
 (0)