diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 (GMT) |
commit | 40d37814166380b0fb585f818b446159cfbcec0f (patch) | |
tree | 80082c1713d2e7951b29b928e57ece73d3a4883b /Parser/tokenizer.c | |
parent | d45014b236f5a8707c104bb5b47bbb006e3bd4f3 (diff) | |
download | cpython-40d37814166380b0fb585f818b446159cfbcec0f.zip cpython-40d37814166380b0fb585f818b446159cfbcec0f.tar.gz cpython-40d37814166380b0fb585f818b446159cfbcec0f.tar.bz2 |
- Fix segfault with invalid coding.
- SF Bug #772896, unknown encoding results in MemoryError, which is not helpful
I will only backport the segfault fix. I'll let Anthony decide if he wants
the other changes backported. I will do the backport if asked.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r-- | Parser/tokenizer.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 6957cc9..ce61322 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -603,8 +603,11 @@ decode_str(const char *str, struct tok_state *tok) if (tok->enc != NULL) { assert(utf8 == NULL); utf8 = translate_into_utf8(str, tok->enc); - if (utf8 == NULL) + if (utf8 == NULL) { + PyErr_Format(PyExc_SyntaxError, + "unknown encoding: %s", tok->enc); return NULL; + } str = PyString_AsString(utf8); } #endif |