mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #20517: Removed unnecessary new (short-lived) functions from PyErr.
This commit is contained in:
parent
1c143b19c8
commit
8f9f0f12e8
6 changed files with 7 additions and 173 deletions
|
@ -257,14 +257,6 @@ in various ways. There is a separate error indicator for each thread.
|
||||||
(:func:`os.fsdecode`).
|
(:func:`os.fsdecode`).
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetFromErrnoWithFilenames(PyObject *type, const char *filename, const char *filename2)
|
|
||||||
|
|
||||||
Similar to :c:func:`PyErr_SetFromErrnoWithFilename`, but accepts a
|
|
||||||
second filename.
|
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
|
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
|
||||||
|
|
||||||
This is a convenience function to raise :exc:`WindowsError`. If called with
|
This is a convenience function to raise :exc:`WindowsError`. If called with
|
||||||
|
@ -290,14 +282,6 @@ in various ways. There is a separate error indicator for each thread.
|
||||||
encoding (:func:`os.fsdecode`). Availability: Windows.
|
encoding (:func:`os.fsdecode`). Availability: Windows.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilenames(int ierr, const char *filename, const char *filename2)
|
|
||||||
|
|
||||||
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, but accepts
|
|
||||||
a second filename. Availability: Windows.
|
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename)
|
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename)
|
||||||
|
|
||||||
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an
|
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an
|
||||||
|
@ -320,15 +304,6 @@ in various ways. There is a separate error indicator for each thread.
|
||||||
parameter specifying the exception type to be raised. Availability: Windows.
|
parameter specifying the exception type to be raised. Availability: Windows.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenames(PyObject *type, int ierr, const char *filename, const char *filename2)
|
|
||||||
|
|
||||||
Similar to :c:func:`PyErr_SetExcFromWindowsErrWithFilename`,
|
|
||||||
but accepts a second filename object.
|
|
||||||
Availability: Windows.
|
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
|
.. c:function:: PyObject* PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
|
||||||
|
|
||||||
This is a convenience function to raise :exc:`ImportError`. *msg* will be
|
This is a convenience function to raise :exc:`ImportError`. *msg* will be
|
||||||
|
|
|
@ -317,12 +317,6 @@ PyErr_SetExcFromWindowsErrWithFilename:PyObject*:type:0:
|
||||||
PyErr_SetExcFromWindowsErrWithFilename:int:ierr::
|
PyErr_SetExcFromWindowsErrWithFilename:int:ierr::
|
||||||
PyErr_SetExcFromWindowsErrWithFilename:const char*:filename::
|
PyErr_SetExcFromWindowsErrWithFilename:const char*:filename::
|
||||||
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames:PyObject*::null:
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames:PyObject*:type:0:
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames:int:ierr::
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames:const char*:filename::
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames:const char*:filename2::
|
|
||||||
|
|
||||||
PyErr_SetFromErrno:PyObject*::null:
|
PyErr_SetFromErrno:PyObject*::null:
|
||||||
PyErr_SetFromErrno:PyObject*:type:0:
|
PyErr_SetFromErrno:PyObject*:type:0:
|
||||||
|
|
||||||
|
@ -330,11 +324,6 @@ PyErr_SetFromErrnoWithFilename:PyObject*::null:
|
||||||
PyErr_SetFromErrnoWithFilename:PyObject*:type:0:
|
PyErr_SetFromErrnoWithFilename:PyObject*:type:0:
|
||||||
PyErr_SetFromErrnoWithFilename:const char*:filename::
|
PyErr_SetFromErrnoWithFilename:const char*:filename::
|
||||||
|
|
||||||
PyErr_SetFromErrnoWithFilenames:PyObject*::null:
|
|
||||||
PyErr_SetFromErrnoWithFilenames:PyObject*:type:0:
|
|
||||||
PyErr_SetFromErrnoWithFilenames:const char*:filename::
|
|
||||||
PyErr_SetFromErrnoWithFilenames:const char*:filename2::
|
|
||||||
|
|
||||||
PyErr_SetFromWindowsErr:PyObject*::null:
|
PyErr_SetFromWindowsErr:PyObject*::null:
|
||||||
PyErr_SetFromWindowsErr:int:ierr::
|
PyErr_SetFromWindowsErr:int:ierr::
|
||||||
|
|
||||||
|
@ -342,11 +331,6 @@ PyErr_SetFromWindowsErrWithFilename:PyObject*::null:
|
||||||
PyErr_SetFromWindowsErrWithFilename:int:ierr::
|
PyErr_SetFromWindowsErrWithFilename:int:ierr::
|
||||||
PyErr_SetFromWindowsErrWithFilename:const char*:filename::
|
PyErr_SetFromWindowsErrWithFilename:const char*:filename::
|
||||||
|
|
||||||
PyErr_SetFromWindowsErrWithFilenames:PyObject*::null:
|
|
||||||
PyErr_SetFromWindowsErrWithFilenames:int:ierr::
|
|
||||||
PyErr_SetFromWindowsErrWithFilenames:const char*:filename::
|
|
||||||
PyErr_SetFromWindowsErrWithFilenames:const char*:filename2::
|
|
||||||
|
|
||||||
PyErr_SetInterrupt:void:::
|
PyErr_SetInterrupt:void:::
|
||||||
|
|
||||||
PyErr_SetNone:void:::
|
PyErr_SetNone:void:::
|
||||||
|
|
|
@ -232,17 +232,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
|
||||||
PyObject *exc,
|
PyObject *exc,
|
||||||
const char *filename /* decoded from the filesystem encoding */
|
const char *filename /* decoded from the filesystem encoding */
|
||||||
);
|
);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenames(
|
|
||||||
PyObject *exc,
|
|
||||||
/* decoded from the filesystem encoding */
|
|
||||||
const char *filename,
|
|
||||||
const char *filename2
|
|
||||||
);
|
|
||||||
#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
|
#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
||||||
PyObject *, const Py_UNICODE *);
|
PyObject *, const Py_UNICODE *);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilenames(
|
|
||||||
PyObject *, const Py_UNICODE *, const Py_UNICODE *);
|
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyErr_Format(
|
PyAPI_FUNC(PyObject *) PyErr_Format(
|
||||||
|
@ -256,18 +248,10 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
|
||||||
int ierr,
|
int ierr,
|
||||||
const char *filename /* decoded from the filesystem encoding */
|
const char *filename /* decoded from the filesystem encoding */
|
||||||
);
|
);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenames(
|
|
||||||
int ierr,
|
|
||||||
/* decoded from the filesystem encoding */
|
|
||||||
const char *filename,
|
|
||||||
const char *filename2
|
|
||||||
);
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
/* XXX redeclare to use WSTRING */
|
/* XXX redeclare to use WSTRING */
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||||
int, const Py_UNICODE *);
|
int, const Py_UNICODE *);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilenames(
|
|
||||||
int, const Py_UNICODE *, const Py_UNICODE *);
|
|
||||||
#endif
|
#endif
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
||||||
|
@ -279,18 +263,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
|
||||||
int ierr,
|
int ierr,
|
||||||
const char *filename /* decoded from the filesystem encoding */
|
const char *filename /* decoded from the filesystem encoding */
|
||||||
);
|
);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenames(
|
|
||||||
PyObject *exc,
|
|
||||||
int ierr,
|
|
||||||
/* decoded from the filesystem encoding */
|
|
||||||
const char *filename,
|
|
||||||
const char *filename2
|
|
||||||
);
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||||
PyObject *,int, const Py_UNICODE *);
|
PyObject *,int, const Py_UNICODE *);
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilenames(
|
|
||||||
PyObject *,int, const Py_UNICODE *, const Py_UNICODE *);
|
|
||||||
#endif
|
#endif
|
||||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
|
|
@ -246,10 +246,8 @@ C-API
|
||||||
-----
|
-----
|
||||||
|
|
||||||
- Issue #20517: Added new functions allowing OSError exceptions to reference
|
- Issue #20517: Added new functions allowing OSError exceptions to reference
|
||||||
two filenames instead of one: PyErr_SetFromErrnoWithFilenameObjects(),
|
two filenames instead of one: PyErr_SetFromErrnoWithFilenameObjects() and
|
||||||
PyErr_SetFromErrnoWithFilenames(), PyErr_SetFromWindowsErrWithFilenames(),
|
PyErr_SetExcFromWindowsErrWithFilenameObjects().
|
||||||
PyErr_SetExcFromWindowsErrWithFilenameObjects(), and
|
|
||||||
PyErr_SetExcFromWindowsErrWithFilenames().
|
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
|
@ -726,8 +726,8 @@ ComplexExtendsException(PyExc_Exception, ImportError,
|
||||||
* when it was supplied.
|
* when it was supplied.
|
||||||
*
|
*
|
||||||
* (If a function has two filenames, such as rename(), symlink(),
|
* (If a function has two filenames, such as rename(), symlink(),
|
||||||
* or copy(), PyErr_SetFromErrnoWithFilenames() is called, which
|
* or copy(), PyErr_SetFromErrnoWithFilenameObjects() is called,
|
||||||
* allows passing in a second filename.)
|
* which allows passing in a second filename.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This function doesn't cleanup on error, the caller should */
|
/* This function doesn't cleanup on error, the caller should */
|
||||||
|
|
104
Python/errors.c
104
Python/errors.c
|
@ -520,17 +520,6 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
|
||||||
PyErr_SetFromErrnoWithFilenames(PyObject *exc, const char *filename, const char *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
|
|
||||||
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
|
|
||||||
PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
PyObject *
|
PyObject *
|
||||||
PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
|
PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
|
||||||
|
@ -542,21 +531,6 @@ PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
|
||||||
Py_XDECREF(name);
|
Py_XDECREF(name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
|
||||||
PyErr_SetFromErrnoWithUnicodeFilenames(PyObject *exc, const Py_UNICODE *filename, const Py_UNICODE *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ?
|
|
||||||
PyUnicode_FromUnicode(filename, wcslen(filename)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *name2 = filename2 ?
|
|
||||||
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
@ -654,23 +628,6 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilename(
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *PyErr_SetExcFromWindowsErrWithFilenames(
|
|
||||||
PyObject *exc,
|
|
||||||
int ierr,
|
|
||||||
const char *filename,
|
|
||||||
const char *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
|
|
||||||
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
|
|
||||||
PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(exc,
|
|
||||||
ierr,
|
|
||||||
name,
|
|
||||||
name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||||
PyObject *exc,
|
PyObject *exc,
|
||||||
int ierr,
|
int ierr,
|
||||||
|
@ -687,51 +644,15 @@ PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilenames(
|
|
||||||
PyObject *exc,
|
|
||||||
int ierr,
|
|
||||||
const Py_UNICODE *filename,
|
|
||||||
const Py_UNICODE *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ?
|
|
||||||
PyUnicode_FromUnicode(filename, wcslen(filename)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *name2 = filename2 ?
|
|
||||||
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(exc,
|
|
||||||
ierr,
|
|
||||||
name,
|
|
||||||
name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr)
|
PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr)
|
||||||
{
|
{
|
||||||
return PyErr_SetExcFromWindowsErrWithFilenames(exc, ierr, NULL, NULL);
|
return PyErr_SetExcFromWindowsErrWithFilename(exc, ierr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *PyErr_SetFromWindowsErr(int ierr)
|
PyObject *PyErr_SetFromWindowsErr(int ierr)
|
||||||
{
|
{
|
||||||
return PyErr_SetExcFromWindowsErrWithFilenames(PyExc_OSError,
|
return PyErr_SetExcFromWindowsErrWithFilename(PyExc_OSError,
|
||||||
ierr, NULL, NULL);
|
ierr, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *PyErr_SetFromWindowsErrWithFilenames(
|
|
||||||
int ierr,
|
|
||||||
const char *filename,
|
|
||||||
const char *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
|
|
||||||
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
|
|
||||||
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
|
||||||
PyExc_OSError,
|
|
||||||
ierr, name, name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *PyErr_SetFromWindowsErrWithFilename(
|
PyObject *PyErr_SetFromWindowsErrWithFilename(
|
||||||
|
@ -759,25 +680,6 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||||
Py_XDECREF(name);
|
Py_XDECREF(name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *PyErr_SetFromWindowsErrWithUnicodeFilenames(
|
|
||||||
int ierr,
|
|
||||||
const Py_UNICODE *filename,
|
|
||||||
const Py_UNICODE *filename2)
|
|
||||||
{
|
|
||||||
PyObject *name = filename ?
|
|
||||||
PyUnicode_FromUnicode(filename, wcslen(filename)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *name2 = filename2 ?
|
|
||||||
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
|
|
||||||
NULL;
|
|
||||||
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
|
||||||
PyExc_OSError,
|
|
||||||
ierr, name, name2);
|
|
||||||
Py_XDECREF(name);
|
|
||||||
Py_XDECREF(name2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue