Commit f95a1b3c authored by Antoine Pitrou's avatar Antoine Pitrou

Recorded merge of revisions 81029 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
parent bd250300
...@@ -6,44 +6,44 @@ PyObject* PyInit_xyzzy(void); /* Forward */ ...@@ -6,44 +6,44 @@ PyObject* PyInit_xyzzy(void); /* Forward */
main(int argc, char **argv) main(int argc, char **argv)
{ {
/* Ignore passed-in argc/argv. If desired, conversion /* Ignore passed-in argc/argv. If desired, conversion
should use mbstowcs to convert them. */ should use mbstowcs to convert them. */
wchar_t *args[] = {L"embed", L"hello", 0}; wchar_t *args[] = {L"embed", L"hello", 0};
/* Pass argv[0] to the Python interpreter */ /* Pass argv[0] to the Python interpreter */
Py_SetProgramName(args[0]); Py_SetProgramName(args[0]);
/* Add a static module */ /* Add a static module */
PyImport_AppendInittab("xyzzy", PyInit_xyzzy); PyImport_AppendInittab("xyzzy", PyInit_xyzzy);
/* Initialize the Python interpreter. Required. */ /* Initialize the Python interpreter. Required. */
Py_Initialize(); Py_Initialize();
/* Define sys.argv. It is up to the application if you /* Define sys.argv. It is up to the application if you
want this; you can also let it undefined (since the Python want this; you can also let it undefined (since the Python
code is generally not a main program it has no business code is generally not a main program it has no business
touching sys.argv...) */ touching sys.argv...) */
PySys_SetArgv(2, args); PySys_SetArgv(2, args);
/* Do some application specific code */ /* Do some application specific code */
printf("Hello, brave new world\n\n"); printf("Hello, brave new world\n\n");
/* Execute some Python statements (in module __main__) */ /* Execute some Python statements (in module __main__) */
PyRun_SimpleString("import sys\n"); PyRun_SimpleString("import sys\n");
PyRun_SimpleString("print(sys.builtin_module_names)\n"); PyRun_SimpleString("print(sys.builtin_module_names)\n");
PyRun_SimpleString("print(sys.modules.keys())\n"); PyRun_SimpleString("print(sys.modules.keys())\n");
PyRun_SimpleString("print(sys.executable)\n"); PyRun_SimpleString("print(sys.executable)\n");
PyRun_SimpleString("print(sys.argv)\n"); PyRun_SimpleString("print(sys.argv)\n");
/* Note that you can call any public function of the Python /* Note that you can call any public function of the Python
interpreter here, e.g. call_object(). */ interpreter here, e.g. call_object(). */
/* Some more application specific code */ /* Some more application specific code */
printf("\nGoodbye, cruel world\n"); printf("\nGoodbye, cruel world\n");
/* Exit, cleaning up the interpreter */ /* Exit, cleaning up the interpreter */
Py_Exit(0); Py_Exit(0);
/*NOTREACHED*/ /*NOTREACHED*/
} }
/* A static module */ /* A static module */
...@@ -52,29 +52,29 @@ main(int argc, char **argv) ...@@ -52,29 +52,29 @@ main(int argc, char **argv)
static PyObject * static PyObject *
xyzzy_foo(PyObject *self, PyObject* args) xyzzy_foo(PyObject *self, PyObject* args)
{ {
return PyLong_FromLong(42L); return PyLong_FromLong(42L);
} }
static PyMethodDef xyzzy_methods[] = { static PyMethodDef xyzzy_methods[] = {
{"foo", xyzzy_foo, METH_NOARGS, {"foo", xyzzy_foo, METH_NOARGS,
"Return the meaning of everything."}, "Return the meaning of everything."},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
static struct PyModuleDef xyzzymodule = { static struct PyModuleDef xyzzymodule = {
{}, /* m_base */ {}, /* m_base */
"xyzzy", /* m_name */ "xyzzy", /* m_name */
0, /* m_doc */ 0, /* m_doc */
0, /* m_size */ 0, /* m_size */
xyzzy_methods, /* m_methods */ xyzzy_methods, /* m_methods */
0, /* m_reload */ 0, /* m_reload */
0, /* m_traverse */ 0, /* m_traverse */
0, /* m_clear */ 0, /* m_clear */
0, /* m_free */ 0, /* m_free */
}; };
PyObject* PyObject*
PyInit_xyzzy(void) PyInit_xyzzy(void)
{ {
return PyModule_Create(&xyzzymodule); return PyModule_Create(&xyzzymodule);
} }
...@@ -6,28 +6,28 @@ ...@@ -6,28 +6,28 @@
main(int argc, char **argv) main(int argc, char **argv)
{ {
int count = -1; int count = -1;
char *command; char *command;
if (argc < 2 || argc > 3) { if (argc < 2 || argc > 3) {
fprintf(stderr, "usage: loop <python-command> [count]\n"); fprintf(stderr, "usage: loop <python-command> [count]\n");
exit(2); exit(2);
} }
command = argv[1]; command = argv[1];
if (argc == 3) { if (argc == 3) {
count = atoi(argv[2]); count = atoi(argv[2]);
} }
Py_SetProgramName(argv[0]); Py_SetProgramName(argv[0]);
/* uncomment this if you don't want to load site.py */ /* uncomment this if you don't want to load site.py */
/* Py_NoSiteFlag = 1; */ /* Py_NoSiteFlag = 1; */
while (count == -1 || --count >= 0 ) { while (count == -1 || --count >= 0 ) {
Py_Initialize(); Py_Initialize();
PyRun_SimpleString(command); PyRun_SimpleString(command);
Py_Finalize(); Py_Finalize();
} }
return 0; return 0;
} }
This diff is collapsed.
This diff is collapsed.
...@@ -8,11 +8,11 @@ extern "C" { ...@@ -8,11 +8,11 @@ extern "C" {
/* Interface to random parts in ceval.c */ /* Interface to random parts in ceval.c */
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
PyObject *, PyObject *, PyObject *); PyObject *, PyObject *, PyObject *);
/* Inline this */ /* Inline this */
#define PyEval_CallObject(func,arg) \ #define PyEval_CallObject(func,arg) \
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
const char *format, ...); const char *format, ...);
...@@ -45,7 +45,7 @@ PyAPI_FUNC(int) Py_MakePendingCalls(void); ...@@ -45,7 +45,7 @@ PyAPI_FUNC(int) Py_MakePendingCalls(void);
exceeds the current recursion limit. It raises a RuntimeError, and sets exceeds the current recursion limit. It raises a RuntimeError, and sets
the "overflowed" flag in the thread state structure. This flag the "overflowed" flag in the thread state structure. This flag
temporarily *disables* the normal protection; this allows cleanup code temporarily *disables* the normal protection; this allows cleanup code
to potentially outgrow the recursion limit while processing the to potentially outgrow the recursion limit while processing the
RuntimeError. RuntimeError.
* "last chance" anti-recursion protection is triggered when the recursion * "last chance" anti-recursion protection is triggered when the recursion
level exceeds "current recursion limit + 50". By construction, this level exceeds "current recursion limit + 50". By construction, this
...@@ -67,12 +67,12 @@ PyAPI_FUNC(void) Py_SetRecursionLimit(int); ...@@ -67,12 +67,12 @@ PyAPI_FUNC(void) Py_SetRecursionLimit(int);
PyAPI_FUNC(int) Py_GetRecursionLimit(void); PyAPI_FUNC(int) Py_GetRecursionLimit(void);
#define Py_EnterRecursiveCall(where) \ #define Py_EnterRecursiveCall(where) \
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
_Py_CheckRecursiveCall(where)) _Py_CheckRecursiveCall(where))
#define Py_LeaveRecursiveCall() \ #define Py_LeaveRecursiveCall() \
do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \ do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \
PyThreadState_GET()->overflowed = 0; \ PyThreadState_GET()->overflowed = 0; \
} while(0) } while(0)
PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);
PyAPI_DATA(int) _Py_CheckRecursionLimit; PyAPI_DATA(int) _Py_CheckRecursionLimit;
...@@ -83,15 +83,15 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit; ...@@ -83,15 +83,15 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit;
of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly. of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly.
*/ */
# define _Py_MakeRecCheck(x) \ # define _Py_MakeRecCheck(x) \
(++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1)) (++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1))
#else #else
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
#endif #endif
#define _Py_MakeEndRecCheck(x) \ #define _Py_MakeEndRecCheck(x) \
(--(x) < ((_Py_CheckRecursionLimit > 100) \ (--(x) < ((_Py_CheckRecursionLimit > 100) \
? (_Py_CheckRecursionLimit - 50) \ ? (_Py_CheckRecursionLimit - 50) \
: (3 * (_Py_CheckRecursionLimit >> 2)))) : (3 * (_Py_CheckRecursionLimit >> 2))))
#define Py_ALLOW_RECURSION \ #define Py_ALLOW_RECURSION \
do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ do { unsigned char _old = PyThreadState_GET()->recursion_critical;\
...@@ -114,31 +114,31 @@ PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); ...@@ -114,31 +114,31 @@ PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
that lasts a long time and doesn't touch Python data) can allow other that lasts a long time and doesn't touch Python data) can allow other
threads to run as follows: threads to run as follows:
...preparations here... ...preparations here...
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...blocking system call here... ...blocking system call here...
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
...interpret result here... ...interpret result here...
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
{}-surrounded block. {}-surrounded block.
To leave the block in the middle (e.g., with return), you must insert To leave the block in the middle (e.g., with return), you must insert
a line containing Py_BLOCK_THREADS before the return, e.g. a line containing Py_BLOCK_THREADS before the return, e.g.
if (...premature_exit...) { if (...premature_exit...) {
Py_BLOCK_THREADS Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
} }
An alternative is: An alternative is:
Py_BLOCK_THREADS Py_BLOCK_THREADS
if (...premature_exit...) { if (...premature_exit...) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
} }
Py_UNBLOCK_THREADS Py_UNBLOCK_THREADS
For convenience, that the value of 'errno' is restored across For convenience, that the value of 'errno' is restored across
Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
...@@ -170,12 +170,12 @@ PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds); ...@@ -170,12 +170,12 @@ PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void); PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
#define Py_BEGIN_ALLOW_THREADS { \ #define Py_BEGIN_ALLOW_THREADS { \
PyThreadState *_save; \ PyThreadState *_save; \
_save = PyEval_SaveThread(); _save = PyEval_SaveThread();
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
} }
#else /* !WITH_THREAD */ #else /* !WITH_THREAD */
......
...@@ -11,13 +11,13 @@ extern "C" { ...@@ -11,13 +11,13 @@ extern "C" {
* big-endian, unless otherwise noted: * big-endian, unless otherwise noted:
* *
* byte offset * byte offset
* 0 year 2 bytes, 1-9999 * 0 year 2 bytes, 1-9999
* 2 month 1 byte, 1-12 * 2 month 1 byte, 1-12
* 3 day 1 byte, 1-31 * 3 day 1 byte, 1-31
* 4 hour 1 byte, 0-23 * 4 hour 1 byte, 0-23
* 5 minute 1 byte, 0-59 * 5 minute 1 byte, 0-59
* 6 second 1 byte, 0-59 * 6 second 1 byte, 0-59
* 7 usecond 3 bytes, 0-999999 * 7 usecond 3 bytes, 0-999999
* 10 * 10
*/ */
...@@ -33,26 +33,26 @@ extern "C" { ...@@ -33,26 +33,26 @@ extern "C" {
typedef struct typedef struct
{ {
PyObject_HEAD PyObject_HEAD
long hashcode; /* -1 when unknown */ long hashcode; /* -1 when unknown */
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
int seconds; /* 0 <= seconds < 24*3600 is invariant */ int seconds; /* 0 <= seconds < 24*3600 is invariant */
int microseconds; /* 0 <= microseconds < 1000000 is invariant */ int microseconds; /* 0 <= microseconds < 1000000 is invariant */
} PyDateTime_Delta; } PyDateTime_Delta;
typedef struct typedef struct
{ {
PyObject_HEAD /* a pure abstract base clase */ PyObject_HEAD /* a pure abstract base clase */
} PyDateTime_TZInfo; } PyDateTime_TZInfo;
/* The datetime and time types have hashcodes, and an optional tzinfo member, /* The datetime and time types have hashcodes, and an optional tzinfo member,
* present if and only if hastzinfo is true. * present if and only if hastzinfo is true.
*/ */
#define _PyTZINFO_HEAD \ #define _PyTZINFO_HEAD \
PyObject_HEAD \ PyObject_HEAD \
long hashcode; \ long hashcode; \
char hastzinfo; /* boolean flag */ char hastzinfo; /* boolean flag */
/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something /* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
* convenient to cast to, when getting at the hastzinfo member of objects * convenient to cast to, when getting at the hastzinfo member of objects
...@@ -60,7 +60,7 @@ typedef struct ...@@ -60,7 +60,7 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
_PyTZINFO_HEAD _PyTZINFO_HEAD
} _PyDateTime_BaseTZInfo; } _PyDateTime_BaseTZInfo;
/* All time objects are of PyDateTime_TimeType, but that can be allocated /* All time objects are of PyDateTime_TimeType, but that can be allocated
...@@ -69,20 +69,20 @@ typedef struct ...@@ -69,20 +69,20 @@ typedef struct
* internal struct used to allocate the right amount of space for the * internal struct used to allocate the right amount of space for the
* "without" case. * "without" case.
*/ */
#define _PyDateTime_TIMEHEAD \ #define _PyDateTime_TIMEHEAD \
_PyTZINFO_HEAD \ _PyTZINFO_HEAD \
unsigned char data[_PyDateTime_TIME_DATASIZE]; unsigned char data[_PyDateTime_TIME_DATASIZE];
typedef struct typedef struct
{ {
_PyDateTime_TIMEHEAD _PyDateTime_TIMEHEAD
} _PyDateTime_BaseTime; /* hastzinfo false */ } _PyDateTime_BaseTime; /* hastzinfo false */
typedef struct typedef struct
{ {
_PyDateTime_TIMEHEAD _PyDateTime_TIMEHEAD
PyObject *tzinfo; PyObject *tzinfo;
} PyDateTime_Time; /* hastzinfo true */ } PyDateTime_Time; /* hastzinfo true */
/* All datetime objects are of PyDateTime_DateTimeType, but that can be /* All datetime objects are of PyDateTime_DateTimeType, but that can be
...@@ -92,48 +92,48 @@ typedef struct ...@@ -92,48 +92,48 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
_PyTZINFO_HEAD _PyTZINFO_HEAD
unsigned char data[_PyDateTime_DATE_DATASIZE]; unsigned char data[_PyDateTime_DATE_DATASIZE];
} PyDateTime_Date; } PyDateTime_Date;
#define _PyDateTime_DATETIMEHEAD \ #define _PyDateTime_DATETIMEHEAD \
_PyTZINFO_HEAD \ _PyTZINFO_HEAD \
unsigned char data[_PyDateTime_DATETIME_DATASIZE]; unsigned char data[_PyDateTime_DATETIME_DATASIZE];
typedef struct typedef struct
{ {
_PyDateTime_DATETIMEHEAD _PyDateTime_DATETIMEHEAD
} _PyDateTime_BaseDateTime; /* hastzinfo false */ } _PyDateTime_BaseDateTime; /* hastzinfo false */
typedef struct typedef struct
{ {
_PyDateTime_DATETIMEHEAD _PyDateTime_DATETIMEHEAD
PyObject *tzinfo; PyObject *tzinfo;
} PyDateTime_DateTime; /* hastzinfo true */ } PyDateTime_DateTime; /* hastzinfo true */
/* Apply for date and datetime instances. */ /* Apply for date and datetime instances. */
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ #define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
((PyDateTime_Date*)o)->data[1]) ((PyDateTime_Date*)o)->data[1])
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) #define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) #define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) #define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) #define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) #define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
#define PyDateTime_DATE_GET_MICROSECOND(o) \ #define PyDateTime_DATE_GET_MICROSECOND(o) \
((((PyDateTime_DateTime*)o)->data[7] << 16) | \ ((((PyDateTime_DateTime*)o)->data[7] << 16) | \
(((PyDateTime_DateTime*)o)->data[8] << 8) | \ (((PyDateTime_DateTime*)o)->data[8] << 8) | \
((PyDateTime_DateTime*)o)->data[9]) ((PyDateTime_DateTime*)o)->data[9])
/* Apply for time instances. */ /* Apply for time instances. */
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) #define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) #define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) #define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
#define PyDateTime_TIME_GET_MICROSECOND(o) \ #define PyDateTime_TIME_GET_MICROSECOND(o) \
((((PyDateTime_Time*)o)->data[3] << 16) | \ ((((PyDateTime_Time*)o)->data[3] << 16) | \
(((PyDateTime_Time*)o)->data[4] << 8) | \ (((PyDateTime_Time*)o)->data[4] << 8) | \
((PyDateTime_Time*)o)->data[5]) ((PyDateTime_Time*)o)->data[5])
/* Define structure for C API. */ /* Define structure for C API. */
...@@ -148,7 +148,7 @@ typedef struct { ...@@ -148,7 +148,7 @@ typedef struct {
/* constructors */ /* constructors */
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
PyObject*, PyTypeObject*); PyObject*, PyTypeObject*);
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
...@@ -185,7 +185,7 @@ typedef struct { ...@@ -185,7 +185,7 @@ typedef struct {
static PyDateTime_CAPI *PyDateTimeAPI = NULL; static PyDateTime_CAPI *PyDateTimeAPI = NULL;
#define PyDateTime_IMPORT \ #define PyDateTime_IMPORT \
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
/* Macros for type checking when not building the Python core. */ /* Macros for type checking when not building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) #define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
...@@ -205,30 +205,30 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL; ...@@ -205,30 +205,30 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
/* Macros for accessing constructors in a simplified fashion. */ /* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day) \ #define PyDate_FromDate(year, month, day) \
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ #define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \ PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
#define PyTime_FromTime(hour, minute, second, usecond) \ #define PyTime_FromTime(hour, minute, second, usecond) \
PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \ PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
Py_None, PyDateTimeAPI->TimeType) Py_None, PyDateTimeAPI->TimeType)
#define PyDelta_FromDSU(days, seconds, useconds) \ #define PyDelta_FromDSU(days, seconds, useconds) \
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
PyDateTimeAPI->DeltaType) PyDateTimeAPI->DeltaType)
/* Macros supporting the DB API. */ /* Macros supporting the DB API. */
#define PyDateTime_FromTimestamp(args) \ #define PyDateTime_FromTimestamp(args) \
PyDateTimeAPI->DateTime_FromTimestamp( \ PyDateTimeAPI->DateTime_FromTimestamp( \
(PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
#define PyDate_FromTimestamp(args) \ #define PyDate_FromTimestamp(args) \
PyDateTimeAPI->Date_FromTimestamp( \ PyDateTimeAPI->Date_FromTimestamp( \
(PyObject*) (PyDateTimeAPI->DateType), args) (PyObject*) (PyDateTimeAPI->DateType), args)
#endif /* Py_BUILD_CORE */ #endif /* Py_BUILD_CORE */
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -9,27 +9,27 @@ typedef PyObject *(*getter)(PyObject *, void *); ...@@ -9,27 +9,27 @@ typedef PyObject *(*getter)(PyObject *, void *);
typedef int (*setter)(PyObject *, PyObject *, void *); typedef int (*setter)(PyObject *, PyObject *, void *);
typedef struct PyGetSetDef { typedef struct PyGetSetDef {
char *name; char *name;
getter get; getter get;
setter set; setter set;
char *doc; char *doc;
void *closure; void *closure;
} PyGetSetDef; } PyGetSetDef;
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
void *wrapped); void *wrapped);
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
void *wrapped, PyObject *kwds); void *wrapped, PyObject *kwds);
struct wrapperbase { struct wrapperbase {
char *name; char *name;
int offset; int offset;
void *function; void *function;
wrapperfunc wrapper; wrapperfunc wrapper;
char *doc; char *doc;
int flags; int flags;
PyObject *name_strobj; PyObject *name_strobj;
}; };
/* Flags for above struct */ /* Flags for above struct */
...@@ -38,9 +38,9 @@ struct wrapperbase { ...@@ -38,9 +38,9 @@ struct wrapperbase {
/* Various kinds of descriptor objects */ /* Various kinds of descriptor objects */
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
PyTypeObject *d_type; PyTypeObject *d_type;
PyObject *d_name; PyObject *d_name;
} PyDescrObject; } PyDescrObject;
#define PyDescr_COMMON PyDescrObject d_common #define PyDescr_COMMON PyDescrObject d_common
...@@ -49,24 +49,24 @@ typedef struct { ...@@ -49,24 +49,24 @@ typedef struct {
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
typedef struct { typedef struct {
PyDescr_COMMON; PyDescr_COMMON;
PyMethodDef *d_method; PyMethodDef *d_method;
} PyMethodDescrObject; } PyMethodDescrObject;
typedef struct { typedef struct {
PyDescr_COMMON; PyDescr_COMMON;
struct PyMemberDef *d_member; struct PyMemberDef *d_member;
} PyMemberDescrObject; } PyMemberDescrObject;
typedef struct { typedef struct {
PyDescr_COMMON; PyDescr_COMMON;
PyGetSetDef *d_getset; PyGetSetDef *d_getset;
} PyGetSetDescrObject; } PyGetSetDescrObject;
typedef struct { typedef struct {
PyDescr_COMMON; PyDescr_COMMON;
struct wrapperbase *d_base; struct wrapperbase *d_base;
void *d_wrapped; /* This can be any function pointer */ void *d_wrapped; /* This can be any function pointer */
} PyWrapperDescrObject; } PyWrapperDescrObject;
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
...@@ -79,11 +79,11 @@ PyAPI_DATA(PyTypeObject) PyDictProxy_Type; ...@@ -79,11 +79,11 @@ PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
struct PyMemberDef *); struct PyMemberDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
struct PyGetSetDef *); struct PyGetSetDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
struct wrapperbase *, void *); struct wrapperbase *, void *);
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
......
...@@ -48,13 +48,13 @@ meaning otherwise. ...@@ -48,13 +48,13 @@ meaning otherwise.
#define PyDict_MINSIZE 8 #define PyDict_MINSIZE 8
typedef struct { typedef struct {
/* Cached hash code of me_key. Note that hash codes are C longs. /* Cached hash code of me_key. Note that hash codes are C longs.
* We have to use Py_ssize_t instead because dict_popitem() abuses * We have to use Py_ssize_t instead because dict_popitem() abuses
* me_hash to hold a search finger. * me_hash to hold a search finger.
*/ */
Py_ssize_t me_hash; Py_ssize_t me_hash;
PyObject *me_key; PyObject *me_key;
PyObject *me_value; PyObject *me_value;
} PyDictEntry; } PyDictEntry;
/* /*
...@@ -68,24 +68,24 @@ it's two-thirds full. ...@@ -68,24 +68,24 @@ it's two-thirds full.
*/ */
typedef struct _dictobject PyDictObject; typedef struct _dictobject PyDictObject;
struct _dictobject { struct _dictobject {
PyObject_HEAD PyObject_HEAD
Py_ssize_t ma_fill; /* # Active + # Dummy */ Py_ssize_t ma_fill; /* # Active + # Dummy */
Py_ssize_t ma_used; /* # Active */ Py_ssize_t ma_used; /* # Active */
/* The table contains ma_mask + 1 slots, and that's a power of 2. /* The table contains ma_mask + 1 slots, and that's a power of 2.
* We store the mask instead of the size because the mask is more * We store the mask instead of the size because the mask is more
* frequently needed. * frequently needed.
*/ */
Py_ssize_t ma_mask; Py_ssize_t ma_mask;
/* ma_table points to ma_smalltable for small tables, else to /* ma_table points to ma_smalltable for small tables, else to
* additional malloc'ed memory. ma_table is never NULL! This rule * additional malloc'ed memory. ma_table is never NULL! This rule
* saves repeated runtime null-tests in the workhorse getitem and * saves repeated runtime null-tests in the workhorse getitem and
* setitem calls. * setitem calls.
*/ */
PyDictEntry *ma_table; PyDictEntry *ma_table;
PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);
PyDictEntry ma_smalltable[PyDict_MINSIZE]; PyDictEntry ma_smalltable[PyDict_MINSIZE];
}; };
PyAPI_DATA(PyTypeObject) PyDict_Type; PyAPI_DATA(PyTypeObject) PyDict_Type;
...@@ -104,7 +104,7 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type; ...@@ -104,7 +104,7 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type;
#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) #define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)
/* This excludes Values, since they are not sets. */ /* This excludes Values, since they are not sets. */
# define PyDictViewSet_Check(op) \ # define PyDictViewSet_Check(op) \
(PyDictKeys_Check(op) || PyDictItems_Check(op)) (PyDictKeys_Check(op) || PyDictItems_Check(op))
PyAPI_FUNC(PyObject *) PyDict_New(void); PyAPI_FUNC(PyObject *) PyDict_New(void);
...@@ -114,9 +114,9 @@ PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); ...@@ -114,9 +114,9 @@ PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
PyAPI_FUNC(int) PyDict_Next( PyAPI_FUNC(int) PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
PyAPI_FUNC(int) _PyDict_Next( PyAPI_FUNC(int) _PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash); PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
...@@ -137,8 +137,8 @@ PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); ...@@ -137,8 +137,8 @@ PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
*/ */
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
PyObject *other, PyObject *other,
int override); int override);
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing /* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
iterable objects of length 2. If override is true, the last occurrence iterable objects of length 2. If override is true, the last occurrence
...@@ -146,8 +146,8 @@ PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, ...@@ -146,8 +146,8 @@ PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
*/ */
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
PyObject *seq2, PyObject *seq2,
int override); int override);
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,8 +8,8 @@ extern "C" { ...@@ -8,8 +8,8 @@ extern "C" {
/* PyException_HEAD defines the initial segment of every exception class. */ /* PyException_HEAD defines the initial segment of every exception class. */
#define PyException_HEAD PyObject_HEAD PyObject *dict;\ #define PyException_HEAD PyObject_HEAD PyObject *dict;\
PyObject *args; PyObject *traceback;\ PyObject *args; PyObject *traceback;\
PyObject *context; PyObject *cause; PyObject *context; PyObject *cause;
typedef struct { typedef struct {
PyException_HEAD PyException_HEAD
...@@ -92,15 +92,15 @@ PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *); ...@@ -92,15 +92,15 @@ PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
/* */ /* */
#define PyExceptionClass_Check(x) \ #define PyExceptionClass_Check(x) \
(PyType_Check((x)) && \ (PyType_Check((x)) && \
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)) PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
#define PyExceptionInstance_Check(x) \ #define PyExceptionInstance_Check(x) \
PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS) PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)
#define PyExceptionClass_Name(x) \ #define PyExceptionClass_Name(x) \
((char *)(((PyTypeObject*)(x))->tp_name)) ((char *)(((PyTypeObject*)(x))->tp_name))
#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type)) #define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
...@@ -175,30 +175,30 @@ PyAPI_FUNC(int) PyErr_BadArgument(void); ...@@ -175,30 +175,30 @@ PyAPI_FUNC(int) PyErr_BadArgument(void);
PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
PyObject *, PyObject *); PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
PyObject *, const char *); PyObject *, const char *);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
PyObject *, const Py_UNICODE *); PyObject *, const Py_UNICODE *);
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...); PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
int, const char *); int, const char *);
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
int, const char *); int, const char *);
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
int, const Py_UNICODE *); int, const Py_UNICODE *);
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
PyObject *,int, PyObject *); PyObject *,int, PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
PyObject *,int, const char *); PyObject *,int, const char *);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
PyObject *,int, const Py_UNICODE *); PyObject *,int, const Py_UNICODE *);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
...@@ -211,9 +211,9 @@ PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno); ...@@ -211,9 +211,9 @@ PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
/* Function to create a new exception */ /* Function to create a new exception */
PyAPI_FUNC(PyObject *) PyErr_NewException( PyAPI_FUNC(PyObject *) PyErr_NewException(
const char *name, PyObject *base, PyObject *dict); const char *name, PyObject *base, PyObject *dict);
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
const char *name, const char *doc, PyObject *base, PyObject *dict); const char *name, const char *doc, PyObject *base, PyObject *dict);
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
/* In sigcheck.c or signalmodule.c */ /* In sigcheck.c or signalmodule.c */
...@@ -232,15 +232,15 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); ...@@ -232,15 +232,15 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
/* create a UnicodeDecodeError object */ /* create a UnicodeDecodeError object */
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* create a UnicodeEncodeError object */ /* create a UnicodeEncodeError object */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* create a UnicodeTranslateError object */ /* create a UnicodeTranslateError object */
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* get the encoding attribute */ /* get the encoding attribute */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
...@@ -283,11 +283,11 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); ...@@ -283,11 +283,11 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
/* assign a new value to the reason attribute /* assign a new value to the reason attribute
return 0 on success, -1 on failure */ return 0 on success, -1 on failure */
PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
PyObject *, const char *); PyObject *, const char *);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
PyObject *, const char *); PyObject *, const char *);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
PyObject *, const char *); PyObject *, const char *);
/* These APIs aren't really part of the error implementation, but /* These APIs aren't really part of the error implementation, but
...@@ -306,9 +306,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( ...@@ -306,9 +306,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
#include <stdarg.h> #include <stdarg.h>
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
Py_GCC_ATTRIBUTE((format(printf, 3, 4))); Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
Py_GCC_ATTRIBUTE((format(printf, 3, 0))); Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This file moves some of the autoconf magic to compile-time * This file moves some of the autoconf magic to compile-time
* when building on MacOSX. This is needed for building 4-way * when building on MacOSX. This is needed for building 4-way
* universal binaries and for 64-bit universal binaries because * universal binaries and for 64-bit universal binaries because
* the values redefined below aren't configure-time constant but * the values redefined below aren't configure-time constant but
* only compile-time constant in these scenarios. * only compile-time constant in these scenarios.
*/ */
...@@ -36,40 +36,40 @@ ...@@ -36,40 +36,40 @@
# undef SIZEOF_LONG # undef SIZEOF_LONG
# ifdef __LP64__ # ifdef __LP64__
# define SIZEOF__BOOL 1 # define SIZEOF__BOOL 1
# define SIZEOF__BOOL 1 # define SIZEOF__BOOL 1
# define SIZEOF_LONG 8 # define SIZEOF_LONG 8
# define SIZEOF_PTHREAD_T 8 # define SIZEOF_PTHREAD_T 8
# define SIZEOF_SIZE_T 8 # define SIZEOF_SIZE_T 8
# define SIZEOF_TIME_T 8 # define SIZEOF_TIME_T 8
# define SIZEOF_VOID_P 8 # define SIZEOF_VOID_P 8
# define SIZEOF_UINTPTR_T 8 # define SIZEOF_UINTPTR_T 8
# define SIZEOF_PTHREAD_T 8 # define SIZEOF_PTHREAD_T 8
# else # else
# ifdef __ppc__ # ifdef __ppc__
# define SIZEOF__BOOL 4 # define SIZEOF__BOOL 4
# else # else
# define SIZEOF__BOOL 1 # define SIZEOF__BOOL 1
# endif # endif
# define SIZEOF_LONG 4 # define SIZEOF_LONG 4
# define SIZEOF_PTHREAD_T 4 # define SIZEOF_PTHREAD_T 4
# define SIZEOF_SIZE_T 4 # define SIZEOF_SIZE_T 4
# define SIZEOF_TIME_T 4 # define SIZEOF_TIME_T 4
# define SIZEOF_VOID_P 4 # define SIZEOF_VOID_P 4
# define SIZEOF_UINTPTR_T 4 # define SIZEOF_UINTPTR_T 4
# define SIZEOF_PTHREAD_T 4 # define SIZEOF_PTHREAD_T 4
# endif # endif
# if defined(__LP64__) # if defined(__LP64__)
/* MacOSX 10.4 (the first release to suppport 64-bit code /* MacOSX 10.4 (the first release to suppport 64-bit code
* at all) only supports 64-bit in the UNIX layer. * at all) only supports 64-bit in the UNIX layer.
* Therefore surpress the toolbox-glue in 64-bit mode. * Therefore surpress the toolbox-glue in 64-bit mode.
*/ */
/* In 64-bit mode setpgrp always has no argments, in 32-bit /* In 64-bit mode setpgrp always has no argments, in 32-bit
* mode that depends on the compilation environment * mode that depends on the compilation environment
*/ */
# undef SETPGRP_HAVE_ARG # undef SETPGRP_HAVE_ARG
# endif # endif
...@@ -84,17 +84,17 @@ ...@@ -84,17 +84,17 @@
# define HAVE_GCC_ASM_FOR_X87 # define HAVE_GCC_ASM_FOR_X87
#endif #endif
/* /*
* The definition in pyconfig.h is only valid on the OS release * The definition in pyconfig.h is only valid on the OS release
* where configure ran on and not necessarily for all systems where * where configure ran on and not necessarily for all systems where
* the executable can be used on. * the executable can be used on.
* *
* Specifically: OSX 10.4 has limited supported for '%zd', while * Specifically: OSX 10.4 has limited supported for '%zd', while
* 10.5 has full support for '%zd'. A binary built on 10.5 won't * 10.5 has full support for '%zd'. A binary built on 10.5 won't
* work properly on 10.4 unless we surpress the definition * work properly on 10.4 unless we surpress the definition
* of PY_FORMAT_SIZE_T * of PY_FORMAT_SIZE_T
*/ */
#undef PY_FORMAT_SIZE_T #undef PY_FORMAT_SIZE_T
#endif /* defined(_APPLE__) */ #endif /* defined(_APPLE__) */
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
#define PyCF_IGNORE_COOKIE 0x0800 #define PyCF_IGNORE_COOKIE 0x0800
typedef struct { typedef struct {
int cf_flags; /* bitmask of CO_xxx flags relevant to future */ int cf_flags; /* bitmask of CO_xxx flags relevant to future */
} PyCompilerFlags; } PyCompilerFlags;
PyAPI_FUNC(void) Py_SetProgramName(wchar_t *); PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
...@@ -40,33 +40,33 @@ PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFla ...@@ -40,33 +40,33 @@ PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFla
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *, PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
int, PyCompilerFlags *flags, int, PyCompilerFlags *flags,
PyArena *); PyArena *);
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *,
const char*, int, const char*, int,
char *, char *, char *, char *,
PyCompilerFlags *, int *, PyCompilerFlags *, int *,
PyArena *); PyArena *);
#define PyParser_SimpleParseString(S, B) \ #define PyParser_SimpleParseString(S, B) \
PyParser_SimpleParseStringFlags(S, B, 0) PyParser_SimpleParseStringFlags(S, B, 0)
#define PyParser_SimpleParseFile(FP, S, B) \ #define PyParser_SimpleParseFile(FP, S, B) \
PyParser_SimpleParseFileFlags(FP, S, B, 0) PyParser_SimpleParseFileFlags(FP, S, B, 0)
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
int); int);
PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
int, int); int, int);
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
PyObject *, PyCompilerFlags *); PyObject *, PyCompilerFlags *);
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
PyObject *, PyObject *, int, PyObject *, PyObject *, int,
PyCompilerFlags *); PyCompilerFlags *);
#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL) #define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
PyCompilerFlags *); PyCompilerFlags *);
PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
PyAPI_FUNC(void) PyErr_Print(void); PyAPI_FUNC(void) PyErr_Print(void);
...@@ -93,20 +93,20 @@ PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv); ...@@ -93,20 +93,20 @@ PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
#define PyRun_AnyFileEx(fp, name, closeit) \ #define PyRun_AnyFileEx(fp, name, closeit) \
PyRun_AnyFileExFlags(fp, name, closeit, NULL) PyRun_AnyFileExFlags(fp, name, closeit, NULL)
#define PyRun_AnyFileFlags(fp, name, flags) \ #define PyRun_AnyFileFlags(fp, name, flags) \
PyRun_AnyFileExFlags(fp, name, 0, flags) PyRun_AnyFileExFlags(fp, name, 0, flags)
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
#define PyRun_File(fp, p, s, g, l) \ #define PyRun_File(fp, p, s, g, l) \
PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
#define PyRun_FileEx(fp, p, s, g, l, c) \ #define PyRun_FileEx(fp, p, s, g, l, c) \
PyRun_FileExFlags(fp, p, s, g, l, c, NULL) PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
#define PyRun_FileFlags(fp, p, s, g, l, flags) \ #define PyRun_FileFlags(fp, p, s, g, l, flags) \
PyRun_FileExFlags(fp, p, s, g, l, 0, flags) PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
/* In getpath.c */ /* In getpath.c */
PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void); PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
......
...@@ -22,8 +22,8 @@ no meaning otherwise. ...@@ -22,8 +22,8 @@ no meaning otherwise.
#define PySet_MINSIZE 8 #define PySet_MINSIZE 8
typedef struct { typedef struct {
long hash; /* cached hash code for the entry key */ long hash; /* cached hash code for the entry key */
PyObject *key; PyObject *key;
} setentry; } setentry;
...@@ -33,27 +33,27 @@ This data structure is shared by set and frozenset objects. ...@@ -33,27 +33,27 @@ This data structure is shared by set and frozenset objects.
typedef struct _setobject PySetObject; typedef struct _setobject PySetObject;
struct _setobject { struct _setobject {
PyObject_HEAD PyObject_HEAD
Py_ssize_t fill; /* # Active + # Dummy */ Py_ssize_t fill; /* # Active + # Dummy */
Py_ssize_t used; /* # Active */ Py_ssize_t used; /* # Active */
/* The table contains mask + 1 slots, and that's a power of 2. /* The table contains mask + 1 slots, and that's a power of 2.
* We store the mask instead of the size because the mask is more * We store the mask instead of the size because the mask is more
* frequently needed. * frequently needed.
*/ */
Py_ssize_t mask; Py_ssize_t mask;
/* table points to smalltable for small tables, else to /* table points to smalltable for small tables, else to
* additional malloc'ed memory. table is never NULL! This rule * additional malloc'ed memory. table is never NULL! This rule
* saves repeated runtime null-tests. * saves repeated runtime null-tests.
*/ */
setentry *table; setentry *table;
setentry *(*lookup)(PySetObject *so, PyObject *key, long hash); setentry *(*lookup)(PySetObject *so, PyObject *key, long hash);
setentry smalltable[PySet_MINSIZE]; setentry smalltable[PySet_MINSIZE];
long hash; /* only used by frozenset objects */ long hash; /* only used by frozenset objects */
PyObject *weakreflist; /* List of weak references */ PyObject *weakreflist; /* List of weak references */
}; };
PyAPI_DATA(PyTypeObject) PySet_Type; PyAPI_DATA(PyTypeObject) PySet_Type;
...@@ -69,17 +69,17 @@ PyAPI_DATA(PyTypeObject) PySetIter_Type; ...@@ -69,17 +69,17 @@ PyAPI_DATA(PyTypeObject) PySetIter_Type;
#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) #define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type)
#define PyAnySet_CheckExact(ob) \ #define PyAnySet_CheckExact(ob) \
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type)
#define PyAnySet_Check(ob) \ #define PyAnySet_Check(ob) \
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
#define PySet_Check(ob) \ #define PySet_Check(ob) \
(Py_TYPE(ob) == &PySet_Type || \ (Py_TYPE(ob) == &PySet_Type || \
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
#define PyFrozenSet_Check(ob) \ #define PyFrozenSet_Check(ob) \
(Py_TYPE(ob) == &PyFrozenSet_Type || \ (Py_TYPE(ob) == &PyFrozenSet_Type || \
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
PyAPI_FUNC(PyObject *) PySet_New(PyObject *); PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
......
...@@ -8,35 +8,35 @@ extern "C" { ...@@ -8,35 +8,35 @@ extern "C" {
#endif #endif
typedef struct PyStructSequence_Field { typedef struct PyStructSequence_Field {
char *name; char *name;
char *doc; char *doc;
} PyStructSequence_Field; } PyStructSequence_Field;
typedef struct PyStructSequence_Desc { typedef struct PyStructSequence_Desc {
char *name; char *name;
char *doc; char *doc;
struct PyStructSequence_Field *fields; struct PyStructSequence_Field *fields;
int n_in_sequence; int n_in_sequence;
} PyStructSequence_Desc; } PyStructSequence_Desc;
extern char* PyStructSequence_UnnamedField; extern char* PyStructSequence_UnnamedField;
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc); PyStructSequence_Desc *desc);
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
typedef struct { typedef struct {
PyObject_VAR_HEAD PyObject_VAR_HEAD
PyObject *ob_item[1]; PyObject *ob_item[1];
} PyStructSequence; } PyStructSequence;
/* Macro, *only* to be used to fill in brand new objects */ /* Macro, *only* to be used to fill in brand new objects */
#define PyStructSequence_SET_ITEM(op, i, v) \ #define PyStructSequence_SET_ITEM(op, i, v) \
(((PyStructSequence *)(op))->ob_item[i] = v) (((PyStructSequence *)(op))->ob_item[i] = v)
#define PyStructSequence_GET_ITEM(op, i) \ #define PyStructSequence_GET_ITEM(op, i) \
(((PyStructSequence *)(op))->ob_item[i]) (((PyStructSequence *)(op))->ob_item[i])
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -15,40 +15,40 @@ typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } ...@@ -15,40 +15,40 @@ typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
struct _symtable_entry; struct _symtable_entry;
struct symtable { struct symtable {
const char *st_filename; /* name of file being compiled */ const char *st_filename; /* name of file being compiled */
struct _symtable_entry *st_cur; /* current symbol table entry */ struct _symtable_entry *st_cur; /* current symbol table entry */
struct _symtable_entry *st_top; /* symbol table entry for module */ struct _symtable_entry *st_top; /* symbol table entry for module */
PyObject *st_blocks; /* dict: map AST node addresses PyObject *st_blocks; /* dict: map AST node addresses
* to symbol table entries */ * to symbol table entries */
PyObject *st_stack; /* list: stack of namespace info */ PyObject *st_stack; /* list: stack of namespace info */
PyObject *st_global; /* borrowed ref to st_top->st_symbols */ PyObject *st_global; /* borrowed ref to st_top->st_symbols */
int st_nblocks; /* number of blocks used */ int st_nblocks; /* number of blocks used */
PyObject *st_private; /* name of current class or NULL */ PyObject *st_private; /* name of current class or NULL */
PyFutureFeatures *st_future; /* module's future features */ PyFutureFeatures *st_future; /* module's future features */
}; };
typedef struct _symtable_entry { typedef struct _symtable_entry {
PyObject_HEAD PyObject_HEAD
PyObject *ste_id; /* int: key in ste_table->st_blocks */ PyObject *ste_id; /* int: key in ste_table->st_blocks */
PyObject *ste_symbols; /* dict: variable names to flags */ PyObject *ste_symbols; /* dict: variable names to flags */
PyObject *ste_name; /* string: name of current block */ PyObject *ste_name; /* string: name of current block */
PyObject *ste_varnames; /* list of variable names */ PyObject *ste_varnames; /* list of variable names */
PyObject *ste_children; /* list of child blocks */ PyObject *ste_children; /* list of child blocks */
_Py_block_ty ste_type; /* module, class, or function */ _Py_block_ty ste_type; /* module, class, or function */
int ste_unoptimized; /* false if namespace is optimized */ int ste_unoptimized; /* false if namespace is optimized */
int ste_nested; /* true if block is nested */ int ste_nested; /* true if block is nested */
unsigned ste_free : 1; /* true if block has free variables */ unsigned ste_free : 1; /* true if block has free variables */
unsigned ste_child_free : 1; /* true if a child block has free vars, unsigned ste_child_free : 1; /* true if a child block has free vars,
including free refs to globals */ including free refs to globals */
unsigned ste_generator : 1; /* true if namespace is a generator */ unsigned ste_generator : 1; /* true if namespace is a generator */
unsigned ste_varargs : 1; /* true if block has varargs */ unsigned ste_varargs : 1; /* true if block has varargs */
unsigned ste_varkeywords : 1; /* true if block has varkeywords */ unsigned ste_varkeywords : 1; /* true if block has varkeywords */
unsigned ste_returns_value : 1; /* true if namespace uses return with unsigned ste_returns_value : 1; /* true if namespace uses return with
an argument */ an argument */
int ste_lineno; /* first line of block */ int ste_lineno; /* first line of block */
int ste_opt_lineno; /* lineno of last exec or import * */ int ste_opt_lineno; /* lineno of last exec or import * */
int ste_tmpname; /* counter for listcomp temp vars */ int ste_tmpname; /* counter for listcomp temp vars */
struct symtable *ste_table; struct symtable *ste_table;
} PySTEntryObject; } PySTEntryObject;
PyAPI_DATA(PyTypeObject) PySTEntry_Type; PyAPI_DATA(PyTypeObject) PySTEntry_Type;
...@@ -57,8 +57,8 @@ PyAPI_DATA(PyTypeObject) PySTEntry_Type; ...@@ -57,8 +57,8 @@ PyAPI_DATA(PyTypeObject) PySTEntry_Type;
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *,
PyFutureFeatures *); PyFutureFeatures *);
PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
PyAPI_FUNC(void) PySymtable_Free(struct symtable *); PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
...@@ -77,7 +77,7 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *); ...@@ -77,7 +77,7 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
table. GLOBAL is returned from PyST_GetScope() for either of them. table. GLOBAL is returned from PyST_GetScope() for either of them.
It is stored in ste_symbols at bits 12-15. It is stored in ste_symbols at bits 12-15.
*/ */
#define SCOPE_OFFSET 11 #define SCOPE_OFFSET 11
......
This diff is collapsed.
...@@ -39,8 +39,8 @@ extern char** environ; ...@@ -39,8 +39,8 @@ extern char** environ;
* In a regular framework the structure is: * In a regular framework the structure is:
* *
* Python.framework/Versions/2.7 * Python.framework/Versions/2.7
* /Python * /Python
* /Resources/Python.app/Contents/MacOS/Python * /Resources/Python.app/Contents/MacOS/Python
* *
* In a virtualenv style structure the expected * In a virtualenv style structure the expected
* structure is: * structure is:
...@@ -50,121 +50,121 @@ extern char** environ; ...@@ -50,121 +50,121 @@ extern char** environ;
* /.Python <- the dylib * /.Python <- the dylib
* /.Resources/Python.app/Contents/MacOS/Python * /.Resources/Python.app/Contents/MacOS/Python
* *
* NOTE: virtualenv's are not an officially supported * NOTE: virtualenv's are not an officially supported
* feature, support for that structure is provided as * feature, support for that structure is provided as
* a convenience. * a convenience.
*/ */
static char* get_python_path(void) static char* get_python_path(void)
{ {
size_t len; size_t len;
Dl_info info; Dl_info info;
char* end; char* end;
char* g_path; char* g_path;
if (dladdr(Py_Initialize, &info) == 0) { if (dladdr(Py_Initialize, &info) == 0) {
return NULL; return NULL;
} }
len = strlen(info.dli_fname); len = strlen(info.dli_fname);
g_path = malloc(len+60); g_path = malloc(len+60);
if (g_path == NULL) { if (g_path == NULL) {
return NULL; return NULL;
} }
strcpy(g_path, info.dli_fname); strcpy(g_path, info.dli_fname);
end = g_path + len - 1; end = g_path + len - 1;
while (end != g_path && *end != '/') { while (end != g_path && *end != '/') {
end --; end --;
} }
end++; end++;
if (*end == '.') { if (*end == '.') {
end++; end++;
} }
strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK); strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK);
return g_path; return g_path;
} }
#ifdef HAVE_SPAWN_H #ifdef HAVE_SPAWN_H
static void static void
setup_spawnattr(posix_spawnattr_t* spawnattr) setup_spawnattr(posix_spawnattr_t* spawnattr)
{ {
size_t ocount; size_t ocount;
size_t count; size_t count;
cpu_type_t cpu_types[1]; cpu_type_t cpu_types[1];
short flags = 0; short flags = 0;
#ifdef __LP64__ #ifdef __LP64__
int ch; int ch;
#endif #endif
if ((errno = posix_spawnattr_init(spawnattr)) != 0) { if ((errno = posix_spawnattr_init(spawnattr)) != 0) {
err(2, "posix_spawnattr_int"); err(2, "posix_spawnattr_int");
/* NOTREACHTED */ /* NOTREACHTED */
} }
count = 1; count = 1;
/* Run the real python executable using the same architure as this /* Run the real python executable using the same architure as this
* executable, this allows users to controle the architecture using * executable, this allows users to controle the architecture using
* "arch -ppc python" * "arch -ppc python"
*/ */
#if defined(__ppc64__) #if defined(__ppc64__)
cpu_types[0] = CPU_TYPE_POWERPC64; cpu_types[0] = CPU_TYPE_POWERPC64;
#elif defined(__x86_64__) #elif defined(__x86_64__)
cpu_types[0] = CPU_TYPE_X86_64; cpu_types[0] = CPU_TYPE_X86_64;
#elif defined(__ppc__) #elif defined(__ppc__)
cpu_types[0] = CPU_TYPE_POWERPC; cpu_types[0] = CPU_TYPE_POWERPC;
#elif defined(__i386__) #elif defined(__i386__)
cpu_types[0] = CPU_TYPE_X86; cpu_types[0] = CPU_TYPE_X86;
#else #else
# error "Unknown CPU" # error "Unknown CPU"
#endif #endif
if (posix_spawnattr_setbinpref_np(spawnattr, count, if (posix_spawnattr_setbinpref_np(spawnattr, count,
cpu_types, &ocount) == -1) { cpu_types, &ocount) == -1) {
err(1, "posix_spawnattr_setbinpref"); err(1, "posix_spawnattr_setbinpref");
/* NOTREACHTED */ /* NOTREACHTED */
} }
if (count != ocount) { if (count != ocount) {
fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n"); fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n");
exit(1); exit(1);
/* NOTREACHTED */ /* NOTREACHTED */
} }
/* /*
* Set flag that causes posix_spawn to behave like execv * Set flag that causes posix_spawn to behave like execv
*/ */
flags |= POSIX_SPAWN_SETEXEC; flags |= POSIX_SPAWN_SETEXEC;
if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) { if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) {
err(1, "posix_spawnattr_setflags"); err(1, "posix_spawnattr_setflags");
/* NOTREACHTED */ /* NOTREACHTED */
} }
} }
#endif #endif
int int
main(int argc, char **argv) { main(int argc, char **argv) {
char* exec_path = get_python_path(); char* exec_path = get_python_path();
#ifdef HAVE_SPAWN_H #ifdef HAVE_SPAWN_H
/* We're weak-linking to posix-spawnv to ensure that /* We're weak-linking to posix-spawnv to ensure that
* an executable build on 10.5 can work on 10.4. * an executable build on 10.5 can work on 10.4.
*/ */
if (posix_spawn != NULL) { if (posix_spawn != NULL) {
posix_spawnattr_t spawnattr = NULL; posix_spawnattr_t spawnattr = NULL;
setup_spawnattr(&spawnattr); setup_spawnattr(&spawnattr);
posix_spawn(NULL, exec_path, NULL, posix_spawn(NULL, exec_path, NULL,
&spawnattr, argv, environ); &spawnattr, argv, environ);
err(1, "posix_spawn: %s", exec_path); err(1, "posix_spawn: %s", exec_path);
} }
#endif #endif
execve(exec_path, argv, environ); execve(exec_path, argv, environ);
err(1, "execve: %s", argv[0]); err(1, "execve: %s", argv[0]);
/* NOTREACHED */ /* NOTREACHED */
} }
...@@ -21,28 +21,28 @@ ...@@ -21,28 +21,28 @@
Assuming the script is a Bourne shell script, the first line of the Assuming the script is a Bourne shell script, the first line of the
script should be script should be
#!/bin/sh - #!/bin/sh -
The - is important, don't omit it. If you're using esh, the first The - is important, don't omit it. If you're using esh, the first
line should be line should be
#!/usr/local/bin/esh -f #!/usr/local/bin/esh -f
and for ksh, the first line should be and for ksh, the first line should be
#!/usr/local/bin/ksh -p #!/usr/local/bin/ksh -p
The script should then set the variable IFS to the string The script should then set the variable IFS to the string
consisting of <space>, <tab>, and <newline>. After this (*not* consisting of <space>, <tab>, and <newline>. After this (*not*
before!), the PATH variable should be set to a reasonable value and before!), the PATH variable should be set to a reasonable value and
exported. Do not expect the PATH to have a reasonable value, so do exported. Do not expect the PATH to have a reasonable value, so do
not trust the old value of PATH. You should then set the umask of not trust the old value of PATH. You should then set the umask of
the program by calling the program by calling
umask 077 # or 022 if you want the files to be readable umask 077 # or 022 if you want the files to be readable
If you plan to change directories, you should either unset CDPATH If you plan to change directories, you should either unset CDPATH
or set it to a good value. Setting CDPATH to just ``.'' (dot) is a or set it to a good value. Setting CDPATH to just ``.'' (dot) is a
good idea. good idea.
If, for some reason, you want to use csh, the first line should be If, for some reason, you want to use csh, the first line should be
#!/bin/csh -fb #!/bin/csh -fb
You should then set the path variable to something reasonable, You should then set the path variable to something reasonable,
without trusting the inherited path. Here too, you should set the without trusting the inherited path. Here too, you should set the
umask using the command umask using the command
umask 077 # or 022 if you want the files to be readable umask 077 # or 022 if you want the files to be readable
*/ */
#include <unistd.h> #include <unistd.h>
...@@ -54,14 +54,14 @@ ...@@ -54,14 +54,14 @@
/* CONFIGURATION SECTION */ /* CONFIGURATION SECTION */
#ifndef FULL_PATH /* so that this can be specified from the Makefile */ #ifndef FULL_PATH /* so that this can be specified from the Makefile */
/* Uncomment the following line: /* Uncomment the following line:
#define FULL_PATH "/full/path/of/script" #define FULL_PATH "/full/path/of/script"
* Then comment out the #error line. */ * Then comment out the #error line. */
#error "You must define FULL_PATH somewhere" #error "You must define FULL_PATH somewhere"
#endif #endif
#ifndef UMASK #ifndef UMASK
#define UMASK 077 #define UMASK 077
#endif #endif
/* END OF CONFIGURATION SECTION */ /* END OF CONFIGURATION SECTION */
...@@ -101,76 +101,76 @@ char def_ENV[] = "ENV=:"; ...@@ -101,76 +101,76 @@ char def_ENV[] = "ENV=:";
void void
clean_environ(void) clean_environ(void)
{ {
char **p; char **p;
extern char **environ; extern char **environ;
for (p = environ; *p; p++) { for (p = environ; *p; p++) {
if (strncmp(*p, "LD_", 3) == 0) if (strncmp(*p, "LD_", 3) == 0)
**p = 'X'; **p = 'X';
else if (strncmp(*p, "_RLD", 4) == 0) else if (strncmp(*p, "_RLD", 4) == 0)
**p = 'X'; **p = 'X';
else if (strncmp(*p, "PYTHON", 6) == 0) else if (strncmp(*p, "PYTHON", 6) == 0)
**p = 'X'; **p = 'X';
else if (strncmp(*p, "IFS=", 4) == 0) else if (strncmp(*p, "IFS=", 4) == 0)
*p = def_IFS; *p = def_IFS;
else if (strncmp(*p, "CDPATH=", 7) == 0) else if (strncmp(*p, "CDPATH=", 7) == 0)
*p = def_CDPATH; *p = def_CDPATH;
else if (strncmp(*p, "ENV=", 4) == 0) else if (strncmp(*p, "ENV=", 4) == 0)
*p = def_ENV; *p = def_ENV;
} }
putenv(def_PATH); putenv(def_PATH);
} }
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct stat statb; struct stat statb;
gid_t egid = getegid(); gid_t egid = getegid();
uid_t euid = geteuid(); uid_t euid = geteuid();
/* /*
Sanity check #1. Sanity check #1.
This check should be made compile-time, but that's not possible. This check should be made compile-time, but that's not possible.
If you're sure that you specified a full path name for FULL_PATH, If you're sure that you specified a full path name for FULL_PATH,
you can omit this check. you can omit this check.
*/ */
if (FULL_PATH[0] != '/') { if (FULL_PATH[0] != '/') {
fprintf(stderr, "%s: %s is not a full path name\n", argv[0], fprintf(stderr, "%s: %s is not a full path name\n", argv[0],
FULL_PATH); FULL_PATH);
fprintf(stderr, "You can only use this wrapper if you\n"); fprintf(stderr, "You can only use this wrapper if you\n");
fprintf(stderr, "compile it with an absolute path.\n"); fprintf(stderr, "compile it with an absolute path.\n");
exit(1); exit(1);
} }
/* /*
Sanity check #2. Sanity check #2.
Check that the owner of the script is equal to either the Check that the owner of the script is equal to either the
effective uid or the super user. effective uid or the super user.
*/ */
if (stat(FULL_PATH, &statb) < 0) { if (stat(FULL_PATH, &statb) < 0) {
perror("stat"); perror("stat");
exit(1); exit(1);
} }
if (statb.st_uid != 0 && statb.st_uid != euid) { if (statb.st_uid != 0 && statb.st_uid != euid) {
fprintf(stderr, "%s: %s has the wrong owner\n", argv[0], fprintf(stderr, "%s: %s has the wrong owner\n", argv[0],
FULL_PATH); FULL_PATH);
fprintf(stderr, "The script should be owned by root,\n"); fprintf(stderr, "The script should be owned by root,\n");
fprintf(stderr, "and shouldn't be writable by anyone.\n"); fprintf(stderr, "and shouldn't be writable by anyone.\n");
exit(1); exit(1);
} }
if (setregid(egid, egid) < 0) if (setregid(egid, egid) < 0)
perror("setregid"); perror("setregid");
if (setreuid(euid, euid) < 0) if (setreuid(euid, euid) < 0)
perror("setreuid"); perror("setreuid");
clean_environ(); clean_environ();
umask(UMASK); umask(UMASK);
while (**argv == '-') /* don't let argv[0] start with '-' */ while (**argv == '-') /* don't let argv[0] start with '-' */
(*argv)++; (*argv)++;
execv(FULL_PATH, argv); execv(FULL_PATH, argv);
fprintf(stderr, "%s: could not execute the script\n", argv[0]); fprintf(stderr, "%s: could not execute the script\n", argv[0]);
exit(1); exit(1);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -4,10 +4,10 @@ The Netherlands. ...@@ -4,10 +4,10 @@ The Netherlands.
All Rights Reserved All Rights Reserved
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission. distribution of the software without specific, written prior permission.
...@@ -34,9 +34,9 @@ convert_to_OSType(PyObject *v, OSType *pr) ...@@ -34,9 +34,9 @@ convert_to_OSType(PyObject *v, OSType *pr)
{ {
uint32_t tmp; uint32_t tmp;
if (!PyUnicode_Check(v) || PyUnicode_GetSize(v) != 4) { if (!PyUnicode_Check(v) || PyUnicode_GetSize(v) != 4) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"OSType arg must be string of 4 chars"); "OSType arg must be string of 4 chars");
return 0; return 0;
} }
memcpy((char *)&tmp, _PyUnicode_AsString(v), 4); memcpy((char *)&tmp, _PyUnicode_AsString(v), 4);
*pr = (OSType)ntohl(tmp); *pr = (OSType)ntohl(tmp);
...@@ -50,12 +50,12 @@ gestalt_gestalt(PyObject *self, PyObject *args) ...@@ -50,12 +50,12 @@ gestalt_gestalt(PyObject *self, PyObject *args)
OSType selector; OSType selector;
SInt32 response; SInt32 response;
if (!PyArg_ParseTuple(args, "O&", convert_to_OSType, &selector)) if (!PyArg_ParseTuple(args, "O&", convert_to_OSType, &selector))
return NULL; return NULL;
iErr = Gestalt(selector, &response); iErr = Gestalt(selector, &response);
if (iErr != 0) { if (iErr != 0) {
PyErr_SetString(PyExc_OSError, PyErr_SetString(PyExc_OSError,
"non-zero exit code!"); "non-zero exit code!");
return NULL; return NULL;
} }
return PyLong_FromLong(response); return PyLong_FromLong(response);
} }
...@@ -66,19 +66,19 @@ static struct PyMethodDef gestalt_methods[] = { ...@@ -66,19 +66,19 @@ static struct PyMethodDef gestalt_methods[] = {
}; };
static struct PyModuleDef gestaltmodule = { static struct PyModuleDef gestaltmodule = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
"_gestalt", "_gestalt",
NULL, NULL,
-1, -1,
gestalt_methods, gestalt_methods,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL NULL
}; };
PyMODINIT_FUNC PyMODINIT_FUNC
PyInit__gestalt(void) PyInit__gestalt(void)
{ {
return PyModule_Create(&gestaltmodule); return PyModule_Create(&gestaltmodule);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment