diff --git a/py/lexer.c b/py/lexer.c
index 17d711696b34c1f318026fe82764efd3f340f7a3..1f1eb6caec9d2d996fa2dd11f0970d1b0f4967d4 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -29,6 +29,7 @@
 
 #include "py/mpstate.h"
 #include "py/lexer.h"
+#include "py/runtime.h"
 
 #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
                                 // 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
-                                assert(!"Unicode name escapes not supported");
+                                mp_not_implemented("unicode name escapes");
                                 break;
                             default:
                                 if (c >= '0' && c <= '7') {
diff --git a/tests/misc/non_compliant_lexer.py b/tests/misc/non_compliant_lexer.py
index e0618efbbecc460ec8411bb9be331717fd07f09d..7e50d2836cdc7ab9fbaefbc4cbc4d853e3597801 100644
--- a/tests/misc/non_compliant_lexer.py
+++ b/tests/misc/non_compliant_lexer.py
@@ -1,5 +1,14 @@
 # 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
 try:
     eval('1and 0')
@@ -17,3 +26,6 @@ try:
     eval('1if 0else 0')
 except SyntaxError:
     print('SyntaxError')
+
+# unicode name escapes are not implemented
+test('"\\N{LATIN SMALL LETTER A}"')
diff --git a/tests/misc/non_compliant_lexer.py.exp b/tests/misc/non_compliant_lexer.py.exp
index 18b00cc767c7f5ca91d0809780bf92f68147bda9..cf1882a78b5a18220b1212bd7547f4965f64a3ec 100644
--- a/tests/misc/non_compliant_lexer.py.exp
+++ b/tests/misc/non_compliant_lexer.py.exp
@@ -2,3 +2,4 @@ SyntaxError
 SyntaxError
 SyntaxError
 SyntaxError
+NotImplementedError