mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31: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:
@@ -67,12 +67,6 @@ import xml.sax.saxutils
|
||||
from xml.sax.xmlreader import AttributesImpl as Attributes
|
||||
|
||||
|
||||
def convert_to_utf8(text):
|
||||
"""
|
||||
"""
|
||||
return text.encode('utf8', 'replace')
|
||||
|
||||
|
||||
class XMLNode:
|
||||
"""
|
||||
"""
|
||||
@@ -289,7 +283,7 @@ class XMLReader(xml.sax.ContentHandler):
|
||||
|
||||
# putting attributes and values in node
|
||||
for attr in attrs.getNames():
|
||||
node.add_attr(attr, convert_to_utf8(attrs.get(attr).strip()))
|
||||
node.add_attr(attr, attrs.get(attr).strip())
|
||||
|
||||
# who is my father?
|
||||
if len(self.__status) > 0:
|
||||
@@ -303,7 +297,7 @@ class XMLReader(xml.sax.ContentHandler):
|
||||
def endElement(self, name):
|
||||
"""
|
||||
"""
|
||||
self.__status[-1].set_text(convert_to_utf8(self.__text.strip()))
|
||||
self.__status[-1].set_text(self.__text.strip())
|
||||
|
||||
self.__text = ""
|
||||
self.__status.pop()
|
||||
|
||||
Reference in New Issue
Block a user