From a1b89b7d9322f47c2aeb65e0b72aca8a791741b1 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 16 Feb 2020 13:05:56 +0800 Subject: [PATCH 1/4] add optional encoding --- runtime/Python2/src/antlr4/InputStream.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Python2/src/antlr4/InputStream.py b/runtime/Python2/src/antlr4/InputStream.py index 3218e72df..c0eb71f70 100644 --- a/runtime/Python2/src/antlr4/InputStream.py +++ b/runtime/Python2/src/antlr4/InputStream.py @@ -15,9 +15,9 @@ import sys class InputStream (object): - def __init__(self, data): + def __init__(self, data, encoding = "ascii"): self.name = "" - self.strdata = unicode(data) + self.strdata = unicode(data, encoding) self._loadString() def _loadString(self): From 07ddf8de45e019061faf62ae9b043371c1f19dd3 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 11 Oct 2020 09:24:37 +0800 Subject: [PATCH 2/4] fix failing Python2 tests with utf-8 encoding --- runtime/Python2/src/antlr4/InputStream.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Python2/src/antlr4/InputStream.py b/runtime/Python2/src/antlr4/InputStream.py index c0eb71f70..1cad2c190 100644 --- a/runtime/Python2/src/antlr4/InputStream.py +++ b/runtime/Python2/src/antlr4/InputStream.py @@ -15,9 +15,9 @@ import sys class InputStream (object): - def __init__(self, data, encoding = "ascii"): + def __init__(self, data, encoding = "utf-8"): self.name = "" - self.strdata = unicode(data, encoding) + self.strdata = unicode(data, encoding) if encoding != "utf-8" else data self._loadString() def _loadString(self): From fa0c0b665e7c195b572952b4865bfd94feabdd77 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 11 Oct 2020 09:52:40 +0800 Subject: [PATCH 3/4] fix failing Python2 tests with utf-8 encoding --- runtime/Python2/src/antlr4/InputStream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Python2/src/antlr4/InputStream.py b/runtime/Python2/src/antlr4/InputStream.py index 1cad2c190..f83350f7e 100644 --- a/runtime/Python2/src/antlr4/InputStream.py +++ b/runtime/Python2/src/antlr4/InputStream.py @@ -15,7 +15,7 @@ import sys class InputStream (object): - def __init__(self, data, encoding = "utf-8"): + def __init__(self, data, encoding = "ascii"): self.name = "" self.strdata = unicode(data, encoding) if encoding != "utf-8" else data self._loadString() From 9a288bcb258ca28a63838e0c4e6c80916d6c68b4 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 11 Oct 2020 15:48:11 +0800 Subject: [PATCH 4/4] fix failing Python2 tests with utf-8 encoding --- runtime/Python2/src/antlr4/InputStream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Python2/src/antlr4/InputStream.py b/runtime/Python2/src/antlr4/InputStream.py index f83350f7e..ab12a35da 100644 --- a/runtime/Python2/src/antlr4/InputStream.py +++ b/runtime/Python2/src/antlr4/InputStream.py @@ -17,7 +17,7 @@ class InputStream (object): def __init__(self, data, encoding = "ascii"): self.name = "" - self.strdata = unicode(data, encoding) if encoding != "utf-8" else data + self.strdata = data if isinstance(data, unicode) else unicode(data, encoding) self._loadString() def _loadString(self):