py/lexer: Raise NotImplError for unicode name escape, instead of assert.

This commit is contained in:
Damien George 2015-09-07 17:08:49 +01:00
parent a7ffa972f3
commit 081f9325f5
3 changed files with 15 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include "py/mpstate.h" #include "py/mpstate.h"
#include "py/lexer.h" #include "py/lexer.h"
#include "py/runtime.h"
#define TAB_SIZE (8) #define TAB_SIZE (8)
@ -466,7 +467,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, bool first_token) {
// 3MB of text; even gzip-compressed and with minimal structure, it'll take // 3MB of text; even gzip-compressed and with minimal structure, it'll take
// roughly half a meg of storage. This form of Unicode escape may be added // roughly half a meg of storage. This form of Unicode escape may be added
// later on, but it's definitely not a priority right now. -- CJA 20140607 // later on, but it's definitely not a priority right now. -- CJA 20140607
assert(!"Unicode name escapes not supported"); mp_not_implemented("unicode name escapes");
break; break;
default: default:
if (c >= '0' && c <= '7') { if (c >= '0' && c <= '7') {

View File

@ -1,5 +1,14 @@
# lexer tests for things that are not implemented, or have non-compliant behaviour # lexer tests for things that are not implemented, or have non-compliant behaviour
def test(code):
try:
exec(code)
print('no Error')
except SyntaxError:
print('SyntaxError')
except NotImplementedError:
print('NotImplementedError')
# uPy requires spaces between literal numbers and keywords, CPy doesn't # uPy requires spaces between literal numbers and keywords, CPy doesn't
try: try:
eval('1and 0') eval('1and 0')
@ -17,3 +26,6 @@ try:
eval('1if 0else 0') eval('1if 0else 0')
except SyntaxError: except SyntaxError:
print('SyntaxError') print('SyntaxError')
# unicode name escapes are not implemented
test('"\\N{LATIN SMALL LETTER A}"')

View File

@ -2,3 +2,4 @@ SyntaxError
SyntaxError SyntaxError
SyntaxError SyntaxError
SyntaxError SyntaxError
NotImplementedError