Merge pull request #2747 from ericvergnaud/support-string-encoding

add optional encoding for string input in python 2
This commit is contained in:
ericvergnaud 2020-11-26 23:32:38 +08:00 committed by GitHub
commit c23cafd126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -15,9 +15,9 @@ import sys
class InputStream (object):
def __init__(self, data):
def __init__(self, data, encoding = "ascii"):
self.name = "<empty>"
self.strdata = unicode(data)
self.strdata = data if isinstance(data, unicode) else unicode(data, encoding)
self._loadString()
def _loadString(self):