Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var_dump('\x9F'); crash on Windows on stdout-to-file redirection #19

Open
divinity76 opened this issue Sep 18, 2022 · 2 comments
Open

Comments

@divinity76
Copy link

when stdout is redirected to a file,

from var_dump import var_dump
var_dump('\x9F');

will crash on Windows. Not sure why, and does not happen on Linux. reproducing the issue in cmd:

C:\>Python --version
Python 3.10.4

C:\>type crash.py
from var_dump import var_dump
var_dump('\x9F')
C:\>Python crash.py
#0 str(1) "�"

C:\>Python crash.py > stdoud_to_file.txt
Traceback (most recent call last):
  File "C:\crash.py", line 2, in <module>
    var_dump('\x9F')
  File "C:\Python\Python310\lib\site-packages\var_dump\_var_dump.py", line 109, in var_dump
    dump(x, 0, i, '', object, True)
  File "C:\Python\Python310\lib\site-packages\var_dump\_var_dump.py", line 76, in dump
    r += display(o, space, num, key, typ, proret)
  File "C:\Python\Python310\lib\site-packages\var_dump\_var_dump.py", line 68, in display
    print(st % tuple(l))
  File "C:\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x9f' in position 11: character maps to <undefined>
@divinity76
Copy link
Author

may also happen in VSCode PowerShell terminal when stdout is not redirected to anything, but it doesn't seem to be consistent o.0

divinity76 added a commit to divinity76/python-var-dump that referenced this issue Sep 19, 2022
previously var_dump('\x9F'); may cause a crash on windows cmd.exe , fix that by hex-encoding instead of crashing.
for more info, see sha256#19
@divinity76
Copy link
Author

proposed fix: #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant