Skip to content

Commit

Permalink
Raise NotImplementedError for contextvars for Python < 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
1st1 committed May 25, 2018
1 parent ed2723f commit 878e416
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,16 @@ def test_context_arg(self):
def cb():
pass

with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
with self.assertRaisesRegex(NotImplementedError,
'requires Python 3.7'):
self.loop.call_soon(cb, context=1)

with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
with self.assertRaisesRegex(NotImplementedError,
'requires Python 3.7'):
self.loop.call_soon_threadsafe(cb, context=1)

with self.assertRaisesRegex(RuntimeError, 'requires Python 3.7'):
with self.assertRaisesRegex(NotImplementedError,
'requires Python 3.7'):
self.loop.call_later(0.1, cb, context=1)


Expand Down
6 changes: 4 additions & 2 deletions uvloop/cbhandles.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ cdef class Handle:
self.context = context
else:
if context is not None:
raise RuntimeError('"context" argument requires Python 3.7')
raise NotImplementedError(
'"context" argument requires Python 3.7')
self.context = None

def __dealloc__(self):
Expand Down Expand Up @@ -182,7 +183,8 @@ cdef class TimerHandle:
self.context = context
else:
if context is not None:
raise RuntimeError('"context" argument requires Python 3.7')
raise NotImplementedError(
'"context" argument requires Python 3.7')
self.context = None

if loop._debug:
Expand Down

0 comments on commit 878e416

Please sign in to comment.