Issue #28139: Fix messed up indentation
Also update the classmethod and staticmethod doc strings and comments to
match the RST documentation.
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index c4e3895..ef18e3f 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -495,20 +495,20 @@
pc->real = pc->imag = 0.0;
if (PyInt_Check(obj)) {
- pc->real = PyInt_AS_LONG(obj);
- return 0;
+ pc->real = PyInt_AS_LONG(obj);
+ return 0;
}
if (PyLong_Check(obj)) {
- pc->real = PyLong_AsDouble(obj);
- if (pc->real == -1.0 && PyErr_Occurred()) {
- *pobj = NULL;
- return -1;
- }
- return 0;
+ pc->real = PyLong_AsDouble(obj);
+ if (pc->real == -1.0 && PyErr_Occurred()) {
+ *pobj = NULL;
+ return -1;
+ }
+ return 0;
}
if (PyFloat_Check(obj)) {
- pc->real = PyFloat_AsDouble(obj);
- return 0;
+ pc->real = PyFloat_AsDouble(obj);
+ return 0;
}
Py_INCREF(Py_NotImplemented);
*pobj = Py_NotImplemented;
@@ -909,25 +909,25 @@
PyObject *format_spec;
if (!PyArg_ParseTuple(args, "O:__format__", &format_spec))
- return NULL;
- if (PyBytes_Check(format_spec))
- return _PyComplex_FormatAdvanced(self,
- PyBytes_AS_STRING(format_spec),
- PyBytes_GET_SIZE(format_spec));
- if (PyUnicode_Check(format_spec)) {
- /* Convert format_spec to a str */
- PyObject *result;
- PyObject *str_spec = PyObject_Str(format_spec);
-
- if (str_spec == NULL)
return NULL;
+ if (PyBytes_Check(format_spec))
+ return _PyComplex_FormatAdvanced(self,
+ PyBytes_AS_STRING(format_spec),
+ PyBytes_GET_SIZE(format_spec));
+ if (PyUnicode_Check(format_spec)) {
+ /* Convert format_spec to a str */
+ PyObject *result;
+ PyObject *str_spec = PyObject_Str(format_spec);
- result = _PyComplex_FormatAdvanced(self,
- PyBytes_AS_STRING(str_spec),
- PyBytes_GET_SIZE(str_spec));
+ if (str_spec == NULL)
+ return NULL;
- Py_DECREF(str_spec);
- return result;
+ result = _PyComplex_FormatAdvanced(self,
+ PyBytes_AS_STRING(str_spec),
+ PyBytes_GET_SIZE(str_spec));
+
+ Py_DECREF(str_spec);
+ return result;
}
PyErr_SetString(PyExc_TypeError, "__format__ requires str or unicode");
return NULL;
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 0e76a44..c62de9c 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -590,8 +590,9 @@
To declare a class method, use this idiom:
class C:
- def f(cls, arg1, arg2, ...): ...
- f = classmethod(f)
+ @classmethod
+ def f(cls, arg1, arg2, ...):
+ ...
It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()); the instance is ignored except for its class.
@@ -676,8 +677,9 @@
To declare a class method, use this idiom:\n\
\n\
class C:\n\
- def f(cls, arg1, arg2, ...): ...\n\
- f = classmethod(f)\n\
+ @classmethod\n\
+ def f(cls, arg1, arg2, ...):\n\
+ ...\n\
\n\
It can be called either on the class (e.g. C.f()) or on an instance\n\
(e.g. C().f()). The instance is ignored except for its class.\n\
@@ -748,8 +750,9 @@
To declare a static method, use this idiom:
class C:
- def f(arg1, arg2, ...): ...
- f = staticmethod(f)
+ @staticmethod
+ def f(arg1, arg2, ...):
+ ....
It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()); the instance is ignored except for its class.
@@ -828,8 +831,9 @@
To declare a static method, use this idiom:\n\
\n\
class C:\n\
- def f(arg1, arg2, ...): ...\n\
- f = staticmethod(f)\n\
+ @staticmethod\n\
+ def f(arg1, arg2, ...):\n\
+ ...\n\
\n\
It can be called either on the class (e.g. C.f()) or on an instance\n\
(e.g. C().f()). The instance is ignored except for its class.\n\
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 41bb074..189413e 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -1461,8 +1461,8 @@
int ival;
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
- if (!free_list && (free_list = fill_free_list()) == NULL)
- return 0;
+ if (!free_list && (free_list = fill_free_list()) == NULL)
+ return 0;
/* PyObject_New is inlined */
v = free_list;
free_list = (PyIntObject *)Py_TYPE(v);
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 5203f40..baa8dee 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -30,11 +30,11 @@
---------------------------------------------------------------*/
assert(step != 0);
if (step > 0 && lo < hi)
- return 1UL + (hi - 1UL - lo) / step;
+ return 1UL + (hi - 1UL - lo) / step;
else if (step < 0 && lo > hi)
- return 1UL + (lo - 1UL - hi) / (0UL - step);
+ return 1UL + (lo - 1UL - hi) / (0UL - step);
else
- return 0UL;
+ return 0UL;
}
/* Return a stop value suitable for reconstructing the xrange from
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index aa88152..60104d5 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -3287,8 +3287,8 @@
}
else
return PyString_FromStringAndSize(
- PyString_AS_STRING(self),
- PyString_GET_SIZE(self)
+ PyString_AS_STRING(self),
+ PyString_GET_SIZE(self)
);
}