Skip to content

Commit fa5cfda

Browse files
author
Nick Berezin
committed
Fixing issue #45: adding python2.7 compatibility using six
1 parent f6c61f2 commit fa5cfda

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

pytest_reportportal/rp_logging.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
from contextlib import contextmanager
44
from functools import wraps
5+
from six import PY2
56

67
from .service import PyTestService
78

@@ -16,21 +17,14 @@ def _log(self, level, msg, args,
1617
Low-level logging routine which creates a LogRecord and then calls
1718
all the handlers of this logger to handle the record.
1819
"""
19-
2020
sinfo = None
21-
p_version_flag = False
22-
23-
if (sys.version_info[0] < 3):
24-
# For python2.x compatibility
25-
p_version_flag = True
26-
2721
if logging._srcfile:
2822
# IronPython doesn't track Python frames, so findCaller raises an
2923
# exception on some versions of IronPython. We trap it here so that
3024
# IronPython can use logging.
3125
try:
32-
if (p_version_flag):
33-
# In python2.x findCaller() don't accept any parameters
26+
if PY2:
27+
# In python2.7 findCaller() don't accept any parameters
3428
# and returns 3 elements
3529
fn, lno, func = self.findCaller()
3630
else:
@@ -44,8 +38,8 @@ def _log(self, level, msg, args,
4438
if exc_info and not isinstance(exc_info, tuple):
4539
exc_info = sys.exc_info()
4640

47-
if p_version_flag:
48-
# In python2.x makeRecord() accepts everything but sinfo
41+
if PY2:
42+
# In python2.7 makeRecord() accepts everything but sinfo
4943
record = self.makeRecord(self.name, level, fn, lno, msg, args,
5044
exc_info, func, extra)
5145
else:

0 commit comments

Comments
 (0)