1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 05:01:29 +00:00

Fix encoding issues related to Python 3 upgrade.

Python 3 str() is a unicode already, so can't be decoded.
subprocess.Popen needs to be in text mode (universal_newlines is the
oldest compatible kwarg for this) in order to do line-based buffering.
In general, all the filesystem encoding stuff we were doing is done by
Python itself now.
This commit is contained in:
dmiller
2022-12-07 20:34:07 +00:00
parent 12d41ec2cd
commit 9e4d6f5f5c
14 changed files with 35 additions and 125 deletions

View File

@@ -64,29 +64,6 @@ import sys
from zenmapCore.Name import APP_NAME
def fs_dec(s): # This is unused now
"""Decode s from the filesystem decoding, handling various possible
errors."""
enc = sys.getfilesystemencoding()
if enc is None:
enc = "UTF-8"
return s.decode(enc)
def fs_enc(u):
"""Encode u to the filesystem decoding, handling various possible
errors."""
enc = sys.getfilesystemencoding()
if enc is None:
enc = "UTF-8"
return u.encode(enc)
# We can't just use os.path.expanduser(u"~") to get a unicode version of the
# home directory, because os.path.expanduser doesn't properly decode the raw
# byte string from the file system encoding. You get a UnicodeDecodeError on
# systems like Windows where the file system encoding is different from the
# result of sys.getdefaultencoding(). So we call os.path.expanduser with a
# plain string and decode it from the filesystem encoding.
HOME = os.path.expanduser("~")
# The base_paths dict in this file gives symbolic names to various files. For