Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 46826c4

Browse files
author
Zakaria Zajac
committed
Only process stack_info if we are in python3+
1 parent 32aa512 commit 46826c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/pythonjsonlogger/jsonlogger.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,12 @@ def format(self, record):
191191
message_dict['exc_info'] = record.exc_text
192192
# Display formatted record of stack frames
193193
# default format is a string returned from :func:`traceback.print_stack`
194-
if record.stack_info and not message_dict.get('stack_info'):
195-
message_dict['stack_info'] = self.formatStack(record.stack_info)
194+
try:
195+
if record.stack_info and not message_dict.get('stack_info'):
196+
message_dict['stack_info'] = self.formatStack(record.stack_info)
197+
except AttributeError:
198+
# Python2.7 doesn't have stack_info.
199+
pass
196200

197201
try:
198202
log_record = OrderedDict()

0 commit comments

Comments
 (0)