@@ -257,20 +257,32 @@ def __call__(self, *args, **kwargs):
257
257
)
258
258
return self ._hookexec (self , self ._nonwrappers + self ._wrappers , kwargs )
259
259
260
- def call_historic (self , proc = None , kwargs = None ):
261
- """ call the hook with given ``kwargs`` for all registered plugins and
260
+ def call_historic (self , result_callback = None , kwargs = None , proc = None ):
261
+ """Call the hook with given ``kwargs`` for all registered plugins and
262
262
for all plugins which will be registered afterwards.
263
263
264
- If ``proc`` is not None it will be called for for each non-None result
265
- obtained from a hook implementation.
264
+ If ``result_callback`` is not ``None`` it will be called for for each
265
+ non-None result obtained from a hook implementation.
266
+
267
+ .. note::
268
+ The ``proc`` argument is now deprecated.
266
269
"""
267
- self ._call_history .append ((kwargs or {}, proc ))
270
+ if proc is not None :
271
+ warnings .warn (
272
+ "Support for `proc` argument is now deprecated and will be"
273
+ "removed in an upcoming release." ,
274
+ DeprecationWarning
275
+ )
276
+ result_callback = proc
277
+
278
+ self ._call_history .append ((kwargs or {}, result_callback ))
268
279
# historizing hooks don't return results
269
280
res = self ._hookexec (self , self ._nonwrappers + self ._wrappers , kwargs )
270
- if proc is None :
281
+ if result_callback is None :
271
282
return
283
+ # XXX: remember firstresult isn't compat with historic
272
284
for x in res or []:
273
- proc (x )
285
+ result_callback (x )
274
286
275
287
def call_extra (self , methods , kwargs ):
276
288
""" Call the hook with some additional temporarily participating
@@ -289,10 +301,10 @@ def _maybe_apply_history(self, method):
289
301
"""Apply call history to a new hookimpl if it is marked as historic.
290
302
"""
291
303
if self .is_historic ():
292
- for kwargs , proc in self ._call_history :
304
+ for kwargs , result_callback in self ._call_history :
293
305
res = self ._hookexec (self , [method ], kwargs )
294
- if res and proc is not None :
295
- proc (res [0 ])
306
+ if res and result_callback is not None :
307
+ result_callback (res [0 ])
296
308
297
309
298
310
class HookImpl (object ):
0 commit comments