mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Fix two instances of empty argument lists, and fix style
('PyObject** x' -> 'PyObject **x')
This commit is contained in:
parent
ba48a3f3ff
commit
0452d1f316
1 changed files with 78 additions and 79 deletions
|
@ -101,15 +101,15 @@ Exception\n\
|
||||||
|
|
||||||
/* Helper function for populating a dictionary with method wrappers. */
|
/* Helper function for populating a dictionary with method wrappers. */
|
||||||
static int
|
static int
|
||||||
populate_methods(PyObject* klass, PyObject* dict, PyMethodDef* methods)
|
populate_methods(PyObject *klass, PyObject *dict, PyMethodDef *methods)
|
||||||
{
|
{
|
||||||
if (!methods)
|
if (!methods)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (methods->ml_name) {
|
while (methods->ml_name) {
|
||||||
/* get a wrapper for the built-in function */
|
/* get a wrapper for the built-in function */
|
||||||
PyObject* func = PyCFunction_New(methods, NULL);
|
PyObject *func = PyCFunction_New(methods, NULL);
|
||||||
PyObject* meth;
|
PyObject *meth;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
|
@ -139,12 +139,12 @@ populate_methods(PyObject* klass, PyObject* dict, PyMethodDef* methods)
|
||||||
|
|
||||||
/* This function is used to create all subsequent exception classes. */
|
/* This function is used to create all subsequent exception classes. */
|
||||||
static int
|
static int
|
||||||
make_class(PyObject** klass, PyObject* base,
|
make_class(PyObject **klass, PyObject *base,
|
||||||
char* name, PyMethodDef* methods,
|
char *name, PyMethodDef *methods,
|
||||||
char* docstr)
|
char *docstr)
|
||||||
{
|
{
|
||||||
PyObject* dict = PyDict_New();
|
PyObject *dict = PyDict_New();
|
||||||
PyObject* str = NULL;
|
PyObject *str = NULL;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
if (!dict)
|
if (!dict)
|
||||||
|
@ -179,9 +179,10 @@ make_class(PyObject** klass, PyObject* base,
|
||||||
|
|
||||||
|
|
||||||
/* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */
|
/* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */
|
||||||
static PyObject* get_self(PyObject* args)
|
static PyObject *
|
||||||
|
get_self(PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* self = PyTuple_GetItem(args, 0);
|
PyObject *self = PyTuple_GetItem(args, 0);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
/* Watch out for being called to early in the bootstrapping process */
|
/* Watch out for being called to early in the bootstrapping process */
|
||||||
if (PyExc_TypeError) {
|
if (PyExc_TypeError) {
|
||||||
|
@ -215,8 +216,8 @@ static char
|
||||||
Exception__doc__[] = "Common base class for all exceptions.";
|
Exception__doc__[] = "Common base class for all exceptions.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
Exception__init__(PyObject* self, PyObject* args)
|
Exception__init__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
@ -238,10 +239,10 @@ Exception__init__(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
Exception__str__(PyObject* self, PyObject* args)
|
Exception__str__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* out;
|
PyObject *out;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &self))
|
if (!PyArg_ParseTuple(args, "O", &self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -256,7 +257,7 @@ Exception__str__(PyObject* self, PyObject* args)
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
PyObject* tmp = PySequence_GetItem(args, 0);
|
PyObject *tmp = PySequence_GetItem(args, 0);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
out = PyObject_Str(tmp);
|
out = PyObject_Str(tmp);
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
|
@ -275,11 +276,11 @@ Exception__str__(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
Exception__getitem__(PyObject* self, PyObject* args)
|
Exception__getitem__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* out;
|
PyObject *out;
|
||||||
PyObject* index;
|
PyObject *index;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "OO", &self, &index))
|
if (!PyArg_ParseTuple(args, "OO", &self, &index))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -305,11 +306,11 @@ Exception_methods[] = {
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
make_Exception(char* modulename)
|
make_Exception(char *modulename)
|
||||||
{
|
{
|
||||||
PyObject* dict = PyDict_New();
|
PyObject *dict = PyDict_New();
|
||||||
PyObject* str = NULL;
|
PyObject *str = NULL;
|
||||||
PyObject* name = NULL;
|
PyObject *name = NULL;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
if (!dict)
|
if (!dict)
|
||||||
|
@ -365,10 +366,10 @@ static char
|
||||||
SystemExit__doc__[] = "Request to exit from the interpreter.";
|
SystemExit__doc__[] = "Request to exit from the interpreter.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
SystemExit__init__(PyObject* self, PyObject* args)
|
SystemExit__init__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* code;
|
PyObject *code;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (!(self = get_self(args)))
|
if (!(self = get_self(args)))
|
||||||
|
@ -430,14 +431,14 @@ static char
|
||||||
EnvironmentError__doc__[] = "Base class for I/O related errors.";
|
EnvironmentError__doc__[] = "Base class for I/O related errors.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
EnvironmentError__init__(PyObject* self, PyObject* args)
|
EnvironmentError__init__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* item0 = NULL;
|
PyObject *item0 = NULL;
|
||||||
PyObject* item1 = NULL;
|
PyObject *item1 = NULL;
|
||||||
PyObject* item2 = NULL;
|
PyObject *item2 = NULL;
|
||||||
PyObject* subslice = NULL;
|
PyObject *subslice = NULL;
|
||||||
PyObject* rtnval = NULL;
|
PyObject *rtnval = NULL;
|
||||||
|
|
||||||
if (!(self = get_self(args)))
|
if (!(self = get_self(args)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -514,14 +515,14 @@ EnvironmentError__init__(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
EnvironmentError__str__(PyObject* self, PyObject* args)
|
EnvironmentError__str__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* originalself = self;
|
PyObject *originalself = self;
|
||||||
PyObject* filename;
|
PyObject *filename;
|
||||||
PyObject* serrno;
|
PyObject *serrno;
|
||||||
PyObject* strerror;
|
PyObject *strerror;
|
||||||
PyObject* rtnval = NULL;
|
PyObject *rtnval = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &self))
|
if (!PyArg_ParseTuple(args, "O", &self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -533,9 +534,9 @@ EnvironmentError__str__(PyObject* self, PyObject* args)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
if (filename != Py_None) {
|
if (filename != Py_None) {
|
||||||
PyObject* fmt = PyString_FromString("[Errno %s] %s: %s");
|
PyObject *fmt = PyString_FromString("[Errno %s] %s: %s");
|
||||||
PyObject* repr = PyObject_Repr(filename);
|
PyObject *repr = PyObject_Repr(filename);
|
||||||
PyObject* tuple = PyTuple_New(3);
|
PyObject *tuple = PyTuple_New(3);
|
||||||
|
|
||||||
if (!fmt || !repr || !tuple) {
|
if (!fmt || !repr || !tuple) {
|
||||||
Py_XDECREF(fmt);
|
Py_XDECREF(fmt);
|
||||||
|
@ -557,8 +558,8 @@ EnvironmentError__str__(PyObject* self, PyObject* args)
|
||||||
strerror = NULL;
|
strerror = NULL;
|
||||||
}
|
}
|
||||||
else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) {
|
else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) {
|
||||||
PyObject* fmt = PyString_FromString("[Errno %s] %s");
|
PyObject *fmt = PyString_FromString("[Errno %s] %s");
|
||||||
PyObject* tuple = PyTuple_New(2);
|
PyObject *tuple = PyTuple_New(2);
|
||||||
|
|
||||||
if (!fmt || !tuple) {
|
if (!fmt || !tuple) {
|
||||||
Py_XDECREF(fmt);
|
Py_XDECREF(fmt);
|
||||||
|
@ -643,9 +644,9 @@ SyntaxError__doc__[] = "Invalid syntax.";
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SyntaxError__classinit__(PyObject* klass)
|
SyntaxError__classinit__(PyObject *klass)
|
||||||
{
|
{
|
||||||
PyObject* emptystring = PyString_FromString("");
|
PyObject *emptystring = PyString_FromString("");
|
||||||
|
|
||||||
/* Additional class-creation time initializations */
|
/* Additional class-creation time initializations */
|
||||||
if (!emptystring ||
|
if (!emptystring ||
|
||||||
|
@ -663,10 +664,10 @@ SyntaxError__classinit__(PyObject* klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
SyntaxError__init__(PyObject* self, PyObject* args)
|
SyntaxError__init__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* rtnval = NULL;
|
PyObject *rtnval = NULL;
|
||||||
int lenargs;
|
int lenargs;
|
||||||
|
|
||||||
if (!(self = get_self(args)))
|
if (!(self = get_self(args)))
|
||||||
|
@ -680,7 +681,7 @@ SyntaxError__init__(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
lenargs = PySequence_Size(args);
|
lenargs = PySequence_Size(args);
|
||||||
if (lenargs >= 1) {
|
if (lenargs >= 1) {
|
||||||
PyObject* item0 = PySequence_GetItem(args, 0);
|
PyObject *item0 = PySequence_GetItem(args, 0);
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (!item0)
|
if (!item0)
|
||||||
|
@ -691,7 +692,7 @@ SyntaxError__init__(PyObject* self, PyObject* args)
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
if (lenargs == 2) {
|
if (lenargs == 2) {
|
||||||
PyObject* info = PySequence_GetItem(args, 1);
|
PyObject *info = PySequence_GetItem(args, 1);
|
||||||
PyObject *filename, *lineno, *offset, *text;
|
PyObject *filename, *lineno, *offset, *text;
|
||||||
int status = 1;
|
int status = 1;
|
||||||
|
|
||||||
|
@ -728,11 +729,11 @@ SyntaxError__init__(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *
|
||||||
SyntaxError__str__(PyObject* self, PyObject* args)
|
SyntaxError__str__(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* msg;
|
PyObject *msg;
|
||||||
PyObject* str;
|
PyObject *str;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &self))
|
if (!PyArg_ParseTuple(args, "O", &self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -854,17 +855,15 @@ PyObject *PyExc_MemoryErrorInst;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* mapping between exception names and their PyObject** */
|
/* mapping between exception names and their PyObject ** */
|
||||||
static struct
|
static struct {
|
||||||
{
|
char *name;
|
||||||
char* name;
|
PyObject **exc;
|
||||||
PyObject** exc;
|
PyObject **base; /* NULL == PyExc_StandardError */
|
||||||
PyObject** base; /* NULL == PyExc_StandardError */
|
char *docstr;
|
||||||
char* docstr;
|
PyMethodDef *methods;
|
||||||
PyMethodDef* methods;
|
int (*classinit)(PyObject *);
|
||||||
int (*classinit)(PyObject*);
|
} exctable[] = {
|
||||||
}
|
|
||||||
exctable[] = {
|
|
||||||
/*
|
/*
|
||||||
* The first three classes MUST appear in exactly this order
|
* The first three classes MUST appear in exactly this order
|
||||||
*/
|
*/
|
||||||
|
@ -928,18 +927,18 @@ void
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
init_exceptions()
|
init_exceptions(void)
|
||||||
{
|
{
|
||||||
char* modulename = "exceptions";
|
char *modulename = "exceptions";
|
||||||
int modnamesz = strlen(modulename);
|
int modnamesz = strlen(modulename);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
PyObject* me = Py_InitModule(modulename, functions);
|
PyObject *me = Py_InitModule(modulename, functions);
|
||||||
PyObject* mydict = PyModule_GetDict(me);
|
PyObject *mydict = PyModule_GetDict(me);
|
||||||
PyObject* bltinmod = PyImport_ImportModule("__builtin__");
|
PyObject *bltinmod = PyImport_ImportModule("__builtin__");
|
||||||
PyObject* bdict = PyModule_GetDict(bltinmod);
|
PyObject *bdict = PyModule_GetDict(bltinmod);
|
||||||
PyObject* doc = PyString_FromString(module__doc__);
|
PyObject *doc = PyString_FromString(module__doc__);
|
||||||
PyObject* args;
|
PyObject *args;
|
||||||
|
|
||||||
PyDict_SetItemString(mydict, "__doc__", doc);
|
PyDict_SetItemString(mydict, "__doc__", doc);
|
||||||
Py_DECREF(doc);
|
Py_DECREF(doc);
|
||||||
|
@ -959,8 +958,8 @@ init_exceptions()
|
||||||
*/
|
*/
|
||||||
for (i=1; exctable[i].name; i++) {
|
for (i=1; exctable[i].name; i++) {
|
||||||
int status;
|
int status;
|
||||||
char* cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2);
|
char *cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2);
|
||||||
PyObject* base;
|
PyObject *base;
|
||||||
|
|
||||||
(void)strcpy(cname, modulename);
|
(void)strcpy(cname, modulename);
|
||||||
(void)strcat(cname, ".");
|
(void)strcat(cname, ".");
|
||||||
|
@ -1014,7 +1013,7 @@ void
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
fini_exceptions()
|
fini_exceptions(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue