Skip to content

Commit

Permalink
Merge pull request #30 from RonnyPfannschmidt/fix-17-detect-module
Browse files Browse the repository at this point in the history
fix #17 by considering only routines
  • Loading branch information
hpk42 authored Nov 11, 2016
2 parents 71c1cb3 + df1f335 commit ca39b4b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- fix bug where callbacks for historic hooks would not be called for
already registered plugins. Thanks Simon Gmizelj for the PR
and holger krekel for further fixes.
- fix #17 by considering only actual functions for hooks
this removes the ability to register arbitrary callable objects
which at first glance is a reasonable simplification,
thanks RonnyPfannschmidt for report and pr.

0.4.0
-----
Expand Down
2 changes: 2 additions & 0 deletions pluggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ def register(self, plugin, name=None):

def parse_hookimpl_opts(self, plugin, name):
method = getattr(plugin, name)
if not inspect.isroutine(method):
return
try:
res = getattr(method, self.project_name + "_impl", None)
except Exception:
Expand Down
9 changes: 9 additions & 0 deletions testing/test_pluggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,15 @@ def hello_myhook(self, arg1):
results = pm.hook.hello_myhook(arg1=17)
assert results == [18, 18]

def test_prefix_hookimpl_dontmatch_module(self):
pm = PluginManager(hookspec.project_name, "hello_")

class BadPlugin:
hello_module = __import__('email')

pm.register(BadPlugin())
pm.check_pending()


def test_parse_hookimpl_override():
class MyPluginManager(PluginManager):
Expand Down

0 comments on commit ca39b4b

Please sign in to comment.