[3.10] bpo-46240: Correct the error for unclosed parentheses when the tokenizer is not finished (GH-30378). (GH-30819)

(cherry picked from commit 70f415fb8b632247e28d87998642317ca7a652ae)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
diff --git a/Parser/pegen.c b/Parser/pegen.c
index f9812c0..26143f5 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -1342,7 +1342,8 @@
         if (PyErr_Occurred()) {
             // Prioritize tokenizer errors to custom syntax errors raised
             // on the second phase only if the errors come from the parser.
-            if (p->tok->done == E_DONE && PyErr_ExceptionMatches(PyExc_SyntaxError)) {
+            int is_tok_ok = (p->tok->done == E_DONE || p->tok->done == E_OK);
+            if (is_tok_ok && PyErr_ExceptionMatches(PyExc_SyntaxError)) {
                 _PyPegen_check_tokenizer_errors(p);
             }
             return NULL;