| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,6 +108,7 @@ PyAPI_DATA(PyObject *) PyExc_NotImplementedError; | |||
| 108 | 108 | PyAPI_DATA(PyObject *) PyExc_SyntaxError; | |
| 109 | 109 | PyAPI_DATA(PyObject *) PyExc_IndentationError; | |
| 110 | 110 | PyAPI_DATA(PyObject *) PyExc_TabError; | |
| 111 | + PyAPI_DATA(PyObject *) PyExc_IncompleteInputError; | ||
| 111 | 112 | PyAPI_DATA(PyObject *) PyExc_ReferenceError; | |
| 112 | 113 | PyAPI_DATA(PyObject *) PyExc_SystemError; | |
| 113 | 114 | PyAPI_DATA(PyObject *) PyExc_SystemExit; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,9 +65,10 @@ def _maybe_compile(compiler, source, filename, symbol): | |||
| 65 | 65 | try: | |
| 66 | 66 | compiler(source + "\n", filename, symbol) | |
| 67 | 67 | return None | |
| 68 | + except IncompleteInputError as e: | ||
| 69 | + return None | ||
| 68 | 70 | except SyntaxError as e: | |
| 69 | - if "incomplete input" in str(e): | ||
| 70 | - return None | ||
| 71 | + pass | ||
| 71 | 72 | # fallthrough | |
| 72 | 73 | ||
| 73 | 74 | return compiler(source, filename, symbol, incomplete_input=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ BaseException | |||
| 44 | 44 | ├── StopAsyncIteration | |
| 45 | 45 | ├── StopIteration | |
| 46 | 46 | ├── SyntaxError | |
| 47 | + │ └── IncompleteInputError | ||
| 47 | 48 | │ └── IndentationError | |
| 48 | 49 | │ └── TabError | |
| 49 | 50 | ├── SystemError | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -567,7 +567,8 @@ def test_exceptions(self): | |||
| 567 | 567 | RecursionError, | |
| 568 | 568 | EncodingWarning, | |
| 569 | 569 | BaseExceptionGroup, | |
| 570 | - ExceptionGroup): | ||
| 570 | + ExceptionGroup, | ||
| 571 | + IncompleteInputError): | ||
| 571 | 572 | continue | |
| 572 | 573 | if exc is not OSError and issubclass(exc, OSError): | |
| 573 | 574 | self.assertEqual(reverse_mapping('builtins', name), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2485,3 +2485,5 @@ | |||
| 2485 | 2485 | [function._Py_SetRefcnt] | |
| 2486 | 2486 | added = '3.13' | |
| 2487 | 2487 | abi_only = true | |
| 2488 | + [data.PyExc_IncompleteInputError] | ||
| 2489 | + added = '3.13' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2566,6 +2566,11 @@ MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, | |||
| 2566 | 2566 | MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, | |
| 2567 | 2567 | "Improper mixture of spaces and tabs."); | |
| 2568 | 2568 | ||
| 2569 | + /* | ||
| 2570 | + * IncompleteInputError extends SyntaxError | ||
| 2571 | + */ | ||
| 2572 | + MiddlingExtendsException(PyExc_SyntaxError, IncompleteInputError, SyntaxError, | ||
| 2573 | + "incomplete input."); | ||
| 2569 | 2574 | ||
| 2570 | 2575 | /* | |
| 2571 | 2576 | * LookupError extends Exception | |
@@ -3635,6 +3640,7 @@ static struct static_exception static_exceptions[] = { | |||
| 3635 | 3640 | ||
| 3636 | 3641 | // Level 4: Other subclasses | |
| 3637 | 3642 | ITEM(IndentationError), // base: SyntaxError(Exception) | |
| 3643 | + ITEM(IncompleteInputError), // base: SyntaxError(Exception) | ||
| 3638 | 3644 | ITEM(IndexError), // base: LookupError(Exception) | |
| 3639 | 3645 | ITEM(KeyError), // base: LookupError(Exception) | |
| 3640 | 3646 | ITEM(ModuleNotFoundError), // base: ImportError(Exception) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -844,7 +844,7 @@ _PyPegen_run_parser(Parser *p) | |||
| 844 | 844 | if (res == NULL) { | |
| 845 | 845 | if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && _is_end_of_source(p)) { | |
| 846 | 846 | PyErr_Clear(); | |
| 847 | - return RAISE_SYNTAX_ERROR("incomplete input"); | ||
| 847 | + return _PyPegen_raise_error(p, PyExc_IncompleteInputError, 0, "incomplete input"); | ||
| 848 | 848 | } | |
| 849 | 849 | if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_SyntaxError)) { | |
| 850 | 850 | return NULL; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments