mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +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:
@@ -122,7 +122,7 @@ class NdiffCommand(subprocess.Popen):
|
||||
filename_b
|
||||
]
|
||||
self.stdout_file = tempfile.TemporaryFile(
|
||||
mode="rb",
|
||||
mode="r",
|
||||
prefix=APP_NAME + "-ndiff-",
|
||||
suffix=".xml"
|
||||
)
|
||||
@@ -132,6 +132,7 @@ class NdiffCommand(subprocess.Popen):
|
||||
subprocess.Popen.__init__(
|
||||
self,
|
||||
command_list,
|
||||
universal_newlines=True,
|
||||
stdout=self.stdout_file,
|
||||
stderr=self.stdout_file,
|
||||
env=env,
|
||||
@@ -167,7 +168,7 @@ def ndiff(scan_a, scan_b):
|
||||
suffix=".xml"
|
||||
)
|
||||
temporary_filenames.append(filename_a)
|
||||
f = os.fdopen(fd, "wb")
|
||||
f = os.fdopen(fd, "w")
|
||||
scan_a.write_xml(f)
|
||||
f.close()
|
||||
else:
|
||||
@@ -179,7 +180,7 @@ def ndiff(scan_a, scan_b):
|
||||
suffix=".xml"
|
||||
)
|
||||
temporary_filenames.append(filename_b)
|
||||
f = os.fdopen(fd, "wb")
|
||||
f = os.fdopen(fd, "w")
|
||||
scan_b.write_xml(f)
|
||||
f.close()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user