22import logging
33from contextlib import contextmanager
44from functools import wraps
5+ from six import PY2
56
67from .service import PyTestService
78
@@ -22,7 +23,13 @@ def _log(self, level, msg, args,
2223 # exception on some versions of IronPython. We trap it here so that
2324 # IronPython can use logging.
2425 try :
25- fn , lno , func , sinfo = self .findCaller (stack_info )
26+ if PY2 :
27+ # In python2.7 findCaller() don't accept any parameters
28+ # and returns 3 elements
29+ fn , lno , func = self .findCaller ()
30+ else :
31+ fn , lno , func , sinfo = self .findCaller (stack_info )
32+
2633 except ValueError : # pragma: no cover
2734 fn , lno , func = '(unknown file)' , 0 , '(unknown function)'
2835 else :
@@ -31,9 +38,14 @@ def _log(self, level, msg, args,
3138 if exc_info and not isinstance (exc_info , tuple ):
3239 exc_info = sys .exc_info ()
3340
34- record = self .makeRecord (
35- self .name , level , fn , lno , msg , args , exc_info , func , extra , sinfo
36- )
41+ if PY2 :
42+ # In python2.7 makeRecord() accepts everything but sinfo
43+ record = self .makeRecord (self .name , level , fn , lno , msg , args ,
44+ exc_info , func , extra )
45+ else :
46+ record = self .makeRecord (self .name , level , fn , lno , msg , args ,
47+ exc_info , func , extra , sinfo )
48+
3749 record .attachment = attachment
3850 self .handle (record )
3951
0 commit comments