Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(261062)

Unified Diff: Objects/typeobject.c

Issue 9856: Change object.__format__(s) where s is non-empty to a TypeError
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_unicode.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2919,9 +2919,9 @@
if (type->tp_init != object_init &&
type->tp_new != object_new)
{
- err = PyErr_WarnEx(PyExc_DeprecationWarning,
- "object.__init__() takes no parameters",
- 1);
+ PyErr_SetString(PyExc_TypeError,
+ "object.__init__() takes no parameters");
+ err = -1;
}
else if (type->tp_init != object_init ||
type->tp_new == object_new)
@@ -2942,9 +2942,9 @@
if (type->tp_new != object_new &&
type->tp_init != object_init)
{
- err = PyErr_WarnEx(PyExc_DeprecationWarning,
- "object.__new__() takes no parameters",
- 1);
+ PyErr_SetString(PyExc_TypeError,
+ "object.__new__() takes no parameters");
+ err = -1;
}
else if (type->tp_new != object_new ||
type->tp_init == object_init)
@@ -3561,16 +3561,9 @@
/* Issue 7994: If we're converting to a string, we
should reject format specifications */
if (PyUnicode_GET_LENGTH(format_spec) > 0) {
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "object.__format__ with a non-empty format "
- "string is deprecated", 1) < 0) {
- goto done;
- }
- /* Eventually this will become an error:
- PyErr_Format(PyExc_TypeError,
+ PyErr_SetString(PyExc_TypeError,
"non-empty format string passed to object.__format__");
- goto done;
- */
+ goto done;
}
result = PyObject_Format(self_as_str, format_spec);
@@ -4199,13 +4192,11 @@
/* Warn for a type that implements tp_compare (now known as
tp_reserved) but not tp_richcompare. */
if (type->tp_reserved && !type->tp_richcompare) {
- int error;
- error = PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ PyErr_Format(PyExc_TypeError,
"Type %.100s defines tp_reserved (formerly tp_compare) "
"but not tp_richcompare. Comparisons may not behave as intended.",
type->tp_name);
- if (error == -1)
- goto error;
+ goto error;
}
/* All done -- set the ready flag */
« no previous file with comments | « Lib/test/test_unicode.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+