Skip to content

Commit df1f335

Browse files
fix issue #17 by considering only routines as hooks
1 parent 6aaaf0e commit df1f335

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
- fix bug where callbacks for historic hooks would not be called for
55
already registered plugins. Thanks Simon Gmizelj for the PR
66
and holger krekel for further fixes.
7+
- fix #17 by considering only actual functions for hooks
8+
this removes the ability to register arbitrary callable objects
9+
which at first glance is a reasonable simplification,
10+
thanks RonnyPfannschmidt for report and pr.
711

812
0.4.0
913
-----

pluggy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ def register(self, plugin, name=None):
375375

376376
def parse_hookimpl_opts(self, plugin, name):
377377
method = getattr(plugin, name)
378+
if not inspect.isroutine(method):
379+
return
378380
try:
379381
res = getattr(method, self.project_name + "_impl", None)
380382
except Exception:

testing/test_pluggy.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,17 +660,12 @@ def test_prefix_hookimpl_dontmatch_module(self):
660660
pm = PluginManager(hookspec.project_name, "hello_")
661661

662662
class BadPlugin:
663-
def hello_fine(self):
664-
pass
665-
hello_fine.optionalhook = True
666-
667663
hello_module = __import__('email')
668664

669665
pm.register(BadPlugin())
670666
pm.check_pending()
671667

672668

673-
674669
def test_parse_hookimpl_override():
675670
class MyPluginManager(PluginManager):
676671
def parse_hookimpl_opts(self, module_or_class, name):

0 commit comments

Comments
 (0)