Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
9a7f7061
Commit
9a7f7061
authored
Jun 20, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that the handler for gevent.hub.signal is callable at construction time. Fixes #818.
parent
c02a1bdd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
0 deletions
+16
-0
changelog.rst
changelog.rst
+3
-0
doc/gevent.rst
doc/gevent.rst
+4
-0
src/gevent/hub.py
src/gevent/hub.py
+6
-0
src/greentest/test__signal.py
src/greentest/test__signal.py
+3
-0
No files found.
changelog.rst
View file @
9a7f7061
...
...
@@ -111,6 +111,9 @@ Other Changes
while it's being read from or written to in a different greenlet is
less likely to raise a :exc:`TypeError` instead of a
:exc:`ValueError`. Reported in :issue:`800` by Kevin Chen.
- :class:`gevent.hub.signal` (aka :func:`gevent.signal`) now verifies
that its `handler` argument is callable, raising a :exc:`TypeError`
if it isn't. Reported in :issue:`818` by Peter Renström.
1.1.1 (Apr 4, 2016)
===================
...
...
doc/gevent.rst
View file @
9a7f7061
...
...
@@ -175,6 +175,10 @@ Signals
is replacing this name. This alias will be removed in a
future release.
.. versionchanged:: 1.2a1
The *handler* is required to be callable at construction time.
.. This is also in the docstring of gevent.hub.signal, which is the
actual callable invoked
...
...
src/gevent/hub.py
View file @
9a7f7061
...
...
@@ -228,6 +228,9 @@ class signal(object):
This may not operate correctly with SIGCHLD if libev child watchers
are used (as they are by default with os.fork).
.. versionchanged:: 1.2a1
The ``handler`` argument is required to be callable at construction time.
"""
# XXX: This is manually documented in gevent.rst while it is aliased in
...
...
@@ -236,6 +239,9 @@ class signal(object):
greenlet_class
=
None
def
__init__
(
self
,
signalnum
,
handler
,
*
args
,
**
kwargs
):
if
not
callable
(
handler
):
raise
TypeError
(
"signal handler must be callable."
)
self
.
hub
=
get_hub
()
self
.
watcher
=
self
.
hub
.
loop
.
signal
(
signalnum
,
ref
=
False
)
self
.
watcher
.
start
(
self
.
_start
)
...
...
src/greentest/test__signal.py
View file @
9a7f7061
...
...
@@ -18,6 +18,9 @@ if hasattr(signal, 'SIGALRM'):
error_fatal
=
False
__timeout__
=
5
def
test_handler
(
self
):
self
.
assertRaises
(
TypeError
,
gevent
.
signal
,
signal
.
SIGALRM
,
1
)
def
test_alarm
(
self
):
sig
=
gevent
.
signal
(
signal
.
SIGALRM
,
raise_Expected
)
assert
sig
.
ref
is
False
,
repr
(
sig
.
ref
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment