Skip to content

Commit 8772ac4

Browse files
committed
Fix py2_str flag for python 2 compatibility mode (usage in standard repr call)
Signed-off-by: Alexey Stepanov <penguinolog@gmail.com>
1 parent 706cdc6 commit 8772ac4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

logwrap/_repr_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def __init__(
172172
self.__keyword = keyword
173173
self.__max_indent = max_indent
174174
self.__indent_step = indent_step
175-
self.__py2_str = py2_str
175+
self.__py2_str = py2_str and not _PY3 # Python 2 only behavior
176176

177177
@property
178178
def max_indent(self):

test/test_repr_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,6 @@ def __pretty_repr__(
347347
result,
348348
"u'''<Test Class at 0x{:X}>'''".format(id(Tst))
349349
)
350+
351+
def test_py2_compatibility_flag(self):
352+
self.assertIsInstance(logwrap.pretty_repr(u'Text', py2_str=True), str)

0 commit comments

Comments
 (0)