8000 gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from stable ABI by pablogsal · Pull Request #119680 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from stable ABI #119680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-119521: Rename IncompleteInputError to _IncompleteInputError and r…
…emove from stable ABI

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal committed May 30, 2024
commit edfed4d8db580bd5738ada02d0a5ff7e6e178d1a
1 change: 0 additions & 1 deletion Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
PyAPI_DATA(PyObject *) PyExc_IndentationError;
PyAPI_DATA(PyObject *) PyExc_TabError;
#if !defined(Py_LIMITED_API)
PyAPI_DATA(PyObject *) PyExc_IncompleteInputError;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be exported at all? An extension can always do PyObject_GetAttrString(Py_GetBuiltins(), "_IncompleteInputError")) (or whatever the "GetBuiltins" call actually is) if it needs a reference.

Removing from the limited API is definitely the right thing. Luckily we caught it pre-release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using it in the parser so it needs to be exported in the headers somehow. Or do you mean we can just use "extern" for it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just extern would mean it's available in builds that are also building its source file, while PyAPI_ means it's exported for use by other apps that link to our binaries. (I think the distinction is more strictly enforced on Windows than POSIX, but we can at least capture our intent.)

#endif
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
PyAPI_DATA(PyObject *) PyExc_SystemError;
PyAPI_DATA(PyObject *) PyExc_SystemExit;
Expand Down
2 changes: 1 addition & 1 deletion Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _maybe_compile(compiler, source, filename, symbol):
try:
compiler(source + "\n", filename, symbol)
return None
except IncompleteInputError as e:
except _IncompleteInputError as e:
return None
except SyntaxError as e:
pass
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/exception_hierarchy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BaseException
├── StopAsyncIteration
├── StopIteration
├── SyntaxError
│ └── IncompleteInputError
│ └── _IncompleteInputError
│ └── IndentationError
│ └── TabError
├── SystemError
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def test_exceptions(self):
EncodingWarning,
BaseExceptionGroup,
ExceptionGroup,
IncompleteInputError):
_IncompleteInputError):
continue
if exc is not OSError and issubclass(exc, OSError):
self.assertEqual(reverse_mapping('builtins', name),
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_stable_abi_ctypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,6 @@
[function._Py_SetRefcnt]
added = '3.13'
abi_only = true
[data.PyExc_IncompleteInputError]
added = '3.13'
[function.PyList_GetItemRef]
added = '3.13'
[typedef.PyCFunctionFast]
Expand Down
13 changes: 8 additions & 5 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \
}; \
PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME

#define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \
#define MiddlingExtendsExceptionEx(EXCBASE, EXCNAME, PYEXCNAME, EXCSTORE, EXCDOC) \
static PyTypeObject _PyExc_ ## EXCNAME = { \
PyVarObject_HEAD_INIT(NULL, 0) \
# EXCNAME, \
# PYEXCNAME, \
sizeof(Py ## EXCSTORE ## Object), \
0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, \
Expand All @@ -560,6 +560,9 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \
}; \
PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME

#define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \
MiddlingExtendsExceptionEx(EXCBASE, EXCNAME, EXCNAME, EXCSTORE, EXCDOC)

#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCNEW, \
EXCMETHODS, EXCMEMBERS, EXCGETSET, \
EXCSTR, EXCDOC) \
Expand Down Expand Up @@ -2608,8 +2611,8 @@ MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError,
/*
* IncompleteInputError extends SyntaxError
*/
MiddlingExtendsException(PyExc_SyntaxError, IncompleteInputError, SyntaxError,
"incomplete input.");
MiddlingExtendsExceptionEx(PyExc_SyntaxError, IncompleteInputError, _IncompleteInputError,
SyntaxError, "incomplete input.");

/*
* LookupError extends Exception
Expand Down Expand Up @@ -3675,7 +3678,7 @@ static struct static_exception static_exceptions[] = {

// Level 4: Other subclasses
ITEM(IndentationError), // base: SyntaxError(Exception)
ITEM(IncompleteInputError), // base: SyntaxError(Exception)
{&_PyExc_IncompleteInputError, "_IncompleteInputError"}, // base: SyntaxError(Exception)
ITEM(IndexError), // base: LookupError(Exception)
ITEM(KeyError), // base: LookupError(Exception)
ITEM(ModuleNotFoundError), // base: ImportError(Exception)
Expand Down
1 change: 0 additions & 1 deletion PC/python3dll.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0