Skip to content

Commit 8f9f0f1

Browse files
committed
Issue #20517: Removed unnecessary new (short-lived) functions from PyErr.
1 parent 1c143b1 commit 8f9f0f1

File tree

6 files changed

+7
-173
lines changed

6 files changed

+7
-173
lines changed

Doc/c-api/exceptions.rst

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,6 @@ in various ways. There is a separate error indicator for each thread.
257257
(:func:`os.fsdecode`).
258258
259259
260-
.. c:function:: PyObject* PyErr_SetFromErrnoWithFilenames(PyObject *type, const char *filename, const char *filename2)
261-
262-
Similar to :c:func:`PyErr_SetFromErrnoWithFilename`, but accepts a
263-
second filename.
264-
265-
.. versionadded:: 3.4
266-
267-
268260
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
269261
270262
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.
290282
encoding (:func:`os.fsdecode`). Availability: Windows.
291283
292284
293-
.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilenames(int ierr, const char *filename, const char *filename2)
294-
295-
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, but accepts
296-
a second filename. Availability: Windows.
297-
298-
.. versionadded:: 3.4
299-
300-
301285
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename)
302286
303287
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an
@@ -320,15 +304,6 @@ in various ways. There is a separate error indicator for each thread.
320304
parameter specifying the exception type to be raised. Availability: Windows.
321305
322306
323-
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenames(PyObject *type, int ierr, const char *filename, const char *filename2)
324-
325-
Similar to :c:func:`PyErr_SetExcFromWindowsErrWithFilename`,
326-
but accepts a second filename object.
327-
Availability: Windows.
328-
329-
.. versionadded:: 3.4
330-
331-
332307
.. c:function:: PyObject* PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
333308
334309
This is a convenience function to raise :exc:`ImportError`. *msg* will be

Doc/data/refcounts.dat

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,36 +317,20 @@ PyErr_SetExcFromWindowsErrWithFilename:PyObject*:type:0:
317317
PyErr_SetExcFromWindowsErrWithFilename:int:ierr::
318318
PyErr_SetExcFromWindowsErrWithFilename:const char*:filename::
319319

320-
PyErr_SetExcFromWindowsErrWithFilenames:PyObject*::null:
321-
PyErr_SetExcFromWindowsErrWithFilenames:PyObject*:type:0:
322-
PyErr_SetExcFromWindowsErrWithFilenames:int:ierr::
323-
PyErr_SetExcFromWindowsErrWithFilenames:const char*:filename::
324-
PyErr_SetExcFromWindowsErrWithFilenames:const char*:filename2::
325-
326320
PyErr_SetFromErrno:PyObject*::null:
327321
PyErr_SetFromErrno:PyObject*:type:0:
328322

329323
PyErr_SetFromErrnoWithFilename:PyObject*::null:
330324
PyErr_SetFromErrnoWithFilename:PyObject*:type:0:
331325
PyErr_SetFromErrnoWithFilename:const char*:filename::
332326

333-
PyErr_SetFromErrnoWithFilenames:PyObject*::null:
334-
PyErr_SetFromErrnoWithFilenames:PyObject*:type:0:
335-
PyErr_SetFromErrnoWithFilenames:const char*:filename::
336-
PyErr_SetFromErrnoWithFilenames:const char*:filename2::
337-
338327
PyErr_SetFromWindowsErr:PyObject*::null:
339328
PyErr_SetFromWindowsErr:int:ierr::
340329

341330
PyErr_SetFromWindowsErrWithFilename:PyObject*::null:
342331
PyErr_SetFromWindowsErrWithFilename:int:ierr::
343332
PyErr_SetFromWindowsErrWithFilename:const char*:filename::
344333

345-
PyErr_SetFromWindowsErrWithFilenames:PyObject*::null:
346-
PyErr_SetFromWindowsErrWithFilenames:int:ierr::
347-
PyErr_SetFromWindowsErrWithFilenames:const char*:filename::
348-
PyErr_SetFromWindowsErrWithFilenames:const char*:filename2::
349-
350334
PyErr_SetInterrupt:void:::
351335

352336
PyErr_SetNone:void:::

Include/pyerrors.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
232232
PyObject *exc,
233233
const char *filename /* decoded from the filesystem encoding */
234234
);
235-
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenames(
236-
PyObject *exc,
237-
/* decoded from the filesystem encoding */
238-
const char *filename,
239-
const char *filename2
240-
);
241235
#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
242236
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
243237
PyObject *, const Py_UNICODE *);
244-
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilenames(
245-
PyObject *, const Py_UNICODE *, const Py_UNICODE *);
246238
#endif /* MS_WINDOWS */
247239

248240
PyAPI_FUNC(PyObject *) PyErr_Format(
@@ -256,18 +248,10 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
256248
int ierr,
257249
const char *filename /* decoded from the filesystem encoding */
258250
);
259-
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenames(
260-
int ierr,
261-
/* decoded from the filesystem encoding */
262-
const char *filename,
263-
const char *filename2
264-
);
265251
#ifndef Py_LIMITED_API
266252
/* XXX redeclare to use WSTRING */
267253
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
268254
int, const Py_UNICODE *);
269-
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilenames(
270-
int, const Py_UNICODE *, const Py_UNICODE *);
271255
#endif
272256
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
273257
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
@@ -279,18 +263,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
279263
int ierr,
280264
const char *filename /* decoded from the filesystem encoding */
281265
);
282-
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenames(
283-
PyObject *exc,
284-
int ierr,
285-
/* decoded from the filesystem encoding */
286-
const char *filename,
287-
const char *filename2
288-
);
289266
#ifndef Py_LIMITED_API
290267
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
291268
PyObject *,int, const Py_UNICODE *);
292-
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilenames(
293-
PyObject *,int, const Py_UNICODE *, const Py_UNICODE *);
294269
#endif
295270
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
296271
#endif /* MS_WINDOWS */

Misc/NEWS

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,8 @@ C-API
246246
-----
247247

248248
- Issue #20517: Added new functions allowing OSError exceptions to reference
249-
two filenames instead of one: PyErr_SetFromErrnoWithFilenameObjects(),
250-
PyErr_SetFromErrnoWithFilenames(), PyErr_SetFromWindowsErrWithFilenames(),
251-
PyErr_SetExcFromWindowsErrWithFilenameObjects(), and
252-
PyErr_SetExcFromWindowsErrWithFilenames().
249+
two filenames instead of one: PyErr_SetFromErrnoWithFilenameObjects() and
250+
PyErr_SetExcFromWindowsErrWithFilenameObjects().
253251

254252
Documentation
255253
-------------

Objects/exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@ ComplexExtendsException(PyExc_Exception, ImportError,
726726
* when it was supplied.
727727
*
728728
* (If a function has two filenames, such as rename(), symlink(),
729-
* or copy(), PyErr_SetFromErrnoWithFilenames() is called, which
730-
* allows passing in a second filename.)
729+
* or copy(), PyErr_SetFromErrnoWithFilenameObjects() is called,
730+
* which allows passing in a second filename.)
731731
*/
732732

733733
/* This function doesn't cleanup on error, the caller should */

Python/errors.c

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,6 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename)
520520
return result;
521521
}
522522

523-
PyObject *
524-
PyErr_SetFromErrnoWithFilenames(PyObject *exc, const char *filename, const char *filename2)
525-
{
526-
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
527-
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
528-
PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, name2);
529-
Py_XDECREF(name);
530-
Py_XDECREF(name2);
531-
return result;
532-
}
533-
534523
#ifdef MS_WINDOWS
535524
PyObject *
536525
PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
@@ -542,21 +531,6 @@ PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
542531
Py_XDECREF(name);
543532
return result;
544533
}
545-
546-
PyObject *
547-
PyErr_SetFromErrnoWithUnicodeFilenames(PyObject *exc, const Py_UNICODE *filename, const Py_UNICODE *filename2)
548-
{
549-
PyObject *name = filename ?
550-
PyUnicode_FromUnicode(filename, wcslen(filename)) :
551-
NULL;
552-
PyObject *name2 = filename2 ?
553-
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
554-
NULL;
555-
PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, name2);
556-
Py_XDECREF(name);
557-
Py_XDECREF(name2);
558-
return result;
559-
}
560534
#endif /* MS_WINDOWS */
561535

562536
PyObject *
@@ -654,23 +628,6 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilename(
654628
return ret;
655629
}
656630

657-
PyObject *PyErr_SetExcFromWindowsErrWithFilenames(
658-
PyObject *exc,
659-
int ierr,
660-
const char *filename,
661-
const char *filename2)
662-
{
663-
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
664-
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
665-
PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(exc,
666-
ierr,
667-
name,
668-
name2);
669-
Py_XDECREF(name);
670-
Py_XDECREF(name2);
671-
return ret;
672-
}
673-
674631
PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename(
675632
PyObject *exc,
676633
int ierr,
@@ -687,51 +644,15 @@ PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename(
687644
return ret;
688645
}
689646

690-
PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilenames(
691-
PyObject *exc,
692-
int ierr,
693-
const Py_UNICODE *filename,
694-
const Py_UNICODE *filename2)
695-
{
696-
PyObject *name = filename ?
697-
PyUnicode_FromUnicode(filename, wcslen(filename)) :
698-
NULL;
699-
PyObject *name2 = filename2 ?
700-
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
701-
NULL;
702-
PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(exc,
703-
ierr,
704-
name,
705-
name2);
706-
Py_XDECREF(name);
707-
Py_XDECREF(name2);
708-
return ret;
709-
}
710-
711647
PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr)
712648
{
713-
return PyErr_SetExcFromWindowsErrWithFilenames(exc, ierr, NULL, NULL);
649+
return PyErr_SetExcFromWindowsErrWithFilename(exc, ierr, NULL);
714650
}
715651

716652
PyObject *PyErr_SetFromWindowsErr(int ierr)
717653
{
718-
return PyErr_SetExcFromWindowsErrWithFilenames(PyExc_OSError,
719-
ierr, NULL, NULL);
720-
}
721-
722-
PyObject *PyErr_SetFromWindowsErrWithFilenames(
723-
int ierr,
724-
const char *filename,
725-
const char *filename2)
726-
{
727-
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
728-
PyObject *name2 = filename2 ? PyUnicode_DecodeFSDefault(filename2) : NULL;
729-
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObjects(
730-
PyExc_OSError,
731-
ierr, name, name2);
732-
Py_XDECREF(name);
733-
Py_XDECREF(name2);
734-
return result;
654+
return PyErr_SetExcFromWindowsErrWithFilename(PyExc_OSError,
655+
ierr, NULL);
735656
}
736657

737658
PyObject *PyErr_SetFromWindowsErrWithFilename(
@@ -759,25 +680,6 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
759680
Py_XDECREF(name);
760681
return result;
761682
}
762-
763-
PyObject *PyErr_SetFromWindowsErrWithUnicodeFilenames(
764-
int ierr,
765-
const Py_UNICODE *filename,
766-
const Py_UNICODE *filename2)
767-
{
768-
PyObject *name = filename ?
769-
PyUnicode_FromUnicode(filename, wcslen(filename)) :
770-
NULL;
771-
PyObject *name2 = filename2 ?
772-
PyUnicode_FromUnicode(filename2, wcslen(filename2)) :
773-
NULL;
774-
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObjects(
775-
PyExc_OSError,
776-
ierr, name, name2);
777-
Py_XDECREF(name);
778-
Py_XDECREF(name2);
779-
return result;
780-
}
781683
#endif /* MS_WINDOWS */
782684

783685
PyObject *

0 commit comments

Comments
 (0)