diff options
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/pickle.py | 2 | ||||
| -rw-r--r-- | Lib/test/pickletester.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 998fce0..a4acbe9 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -903,7 +903,7 @@ class _Unpickler: orig = self.readline() rep = orig[:-1] # Strip outermost quotes - if rep[0] == rep[-1] and rep[0] in b'"\'': + if len(rep) >= 2 and rep[0] == rep[-1] and rep[0] in b'"\'': rep = rep[1:-1] else: raise ValueError("insecure string pickle") diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 5d12375..a72ab37 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -609,6 +609,14 @@ class AbstractPickleTests(unittest.TestCase): b"'abc\"", # open quote and close quote don't match b"'abc' ?", # junk after close quote b"'\\'", # trailing backslash + # Variations on issue #17710 + b"'", + b'"', + b"' ", + b"' ", + b"' ", + b"' ", + b'" ', # some tests of the quoting rules ## b"'abc\"\''", ## b"'\\\\a\'\'\'\\\'\\\\\''", |
