Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions var_dump/_var_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ def display(o, space, num, key, typ, proret):
l.append(str(o))

if proret:
print(st % tuple(l))

try:
print(st % tuple(l))
except UnicodeEncodeError as err:
# may happen on Windows when stdout is piped to a file
# for unknown reasons... ref https://github.com/sha256/python-var-dump/issues/19
# lets replace all non-ascii characters with \xHEX
lc = list(l)
lc[3] = lc[3].encode('ascii', 'backslashreplace').decode('ascii', 'backslashreplace')
print(st % tuple(lc))
return st % tuple(l)


Expand Down