Ori.livneh has submitted this change and it was merged.
Change subject: Bugfix: don't pass args as kwargs
......................................................................
Bugfix: don't pass args as kwargs
Change-Id: I1c932d3bee462d1d1112db10029ac1b8ebf29c83
---
M server/eventlogging/factory.py
1 file changed, 6 insertions(+), 2 deletions(-)
Approvals:
Ori.livneh: Verified; Looks good to me, approved
diff --git a/server/eventlogging/factory.py b/server/eventlogging/factory.py
index 6adddda..33a30d9 100644
--- a/server/eventlogging/factory.py
+++ b/server/eventlogging/factory.py
@@ -19,14 +19,18 @@
def apply_safe(f, kwargs):
- """Apply a function with only those kwargs that it would accept."""
+ """Apply a function with only those arguments that it would accept."""
# If the function takes a '**' arg, all keyword args are safe.
# If it doesn't, we have to remove any arguments that are not
# present in the function's signature.
sig = inspect.getargspec(f)
if sig.keywords is None:
kwargs = {k: v for k, v in items(kwargs) if k in sig.args}
- return f(**kwargs)
+ if sig.defaults is not None:
+ args = [kwargs.pop(k) for k in sig.args[:-len(sig.defaults)]]
+ else:
+ args = [kwargs.pop(k) for k in sig.args]
+ return f(*args, **kwargs)
def handle(handlers, uri):
--
To view, visit https://gerrit.wikimedia.org/r/78076
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c932d3bee462d1d1112db10029ac1b8ebf29c83
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits