[Numpy-svn] r3808 - in trunk/numpy/core: include/numpy src
numpy-svn at scipy.org
numpy-svn at scipy.org
Wed May 23 14:47:15 EDT 2007
Author: oliphant
Date: 2007-05-23 13:47:08 -0500 (Wed, 23 May 2007)
New Revision: 3808
Modified:
trunk/numpy/core/include/numpy/ndarrayobject.h
trunk/numpy/core/src/arraymethods.c
trunk/numpy/core/src/arrayobject.c
trunk/numpy/core/src/multiarraymodule.c
trunk/numpy/core/src/scalartypes.inc.src
Log:
Fix so that _internal.py gets imported when it is needed. Perhaps this will fix the problem with multiple-interpreters not working correctly.
Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h 2007-05-23 18:12:52 UTC (rev 3807)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h 2007-05-23 18:47:08 UTC (rev 3808)
@@ -1230,6 +1230,13 @@
#define fortran fortran_ /* For some compilers */
+/* Array Flags Object */
+typedef struct PyArrayFlagsObject {
+ PyObject_HEAD
+ PyObject *arr;
+ int flags;
+} PyArrayFlagsObject;
+
/* Mirrors buffer object to ptr */
typedef struct {
Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c 2007-05-23 18:12:52 UTC (rev 3807)
+++ trunk/numpy/core/src/arraymethods.c 2007-05-23 18:47:08 UTC (rev 3808)
@@ -872,12 +872,15 @@
if (order == Py_None) order = NULL;
if (order != NULL) {
PyObject *new_name;
+ PyObject *_numpy_internal;
saved = self->descr;
if (saved->names == NULL) {
PyErr_SetString(PyExc_ValueError, "Cannot specify " \
"order when the array has no fields.");
return NULL;
}
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
new_name = PyObject_CallMethod(_numpy_internal, "_newnames",
"OO", saved, order);
if (new_name == NULL) return NULL;
@@ -914,12 +917,15 @@
if (order == Py_None) order = NULL;
if (order != NULL) {
PyObject *new_name;
+ PyObject *_numpy_internal;
saved = self->descr;
if (saved->names == NULL) {
PyErr_SetString(PyExc_ValueError, "Cannot specify " \
"order when the array has no fields.");
return NULL;
}
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
new_name = PyObject_CallMethod(_numpy_internal, "_newnames",
"OO", saved, order);
if (new_name == NULL) return NULL;
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2007-05-23 18:12:52 UTC (rev 3807)
+++ trunk/numpy/core/src/arrayobject.c 2007-05-23 18:47:08 UTC (rev 3808)
@@ -6131,6 +6131,9 @@
static PyObject *
array_ctypes_get(PyArrayObject *self)
{
+ PyObject *_numpy_internal;
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
return PyObject_CallMethod(_numpy_internal, "_ctypes",
"ON", self,
PyLong_FromVoidPtr(self->data));
@@ -10844,6 +10847,7 @@
arraydescr_protocol_descr_get(PyArray_Descr *self)
{
PyObject *dobj, *res;
+ PyObject *_numpy_internal;
if (self->names == NULL) {
/* get default */
@@ -10858,6 +10862,8 @@
return res;
}
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
return PyObject_CallMethod(_numpy_internal, "_array_descr",
"O", self);
}
@@ -11637,12 +11643,6 @@
/** Array Flags Object **/
-typedef struct PyArrayFlagsObject {
- PyObject_HEAD
- PyObject *arr;
- int flags;
-} PyArrayFlagsObject;
-
/*OBJECT_API
Get New ArrayFlagsObject
*/
Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c 2007-05-23 18:12:52 UTC (rev 3807)
+++ trunk/numpy/core/src/multiarraymodule.c 2007-05-23 18:47:08 UTC (rev 3808)
@@ -23,9 +23,9 @@
#include "numpy/arrayobject.h"
#define PyAO PyArrayObject
+
static PyObject *typeDict=NULL; /* Must be explicitly loaded */
-static PyObject *_numpy_internal=NULL; /* A Python module for callbacks */
static PyArray_Descr *
_arraydescr_fromobj(PyObject *obj)
@@ -4859,8 +4859,11 @@
{
PyObject *listobj;
PyArray_Descr *res;
+ PyObject *_numpy_internal;
if (!PyString_Check(obj)) return NULL;
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
listobj = PyObject_CallMethod(_numpy_internal, "_commastring",
"O", obj);
if (!listobj) return NULL;
@@ -4926,6 +4929,9 @@
static PyArray_Descr *
_use_fields_dict(PyObject *obj, int align)
{
+ PyObject *_numpy_internal;
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
return (PyArray_Descr *)PyObject_CallMethod(_numpy_internal,
"_usefields",
"Oi", obj, align);
@@ -7583,10 +7589,8 @@
set_flaginfo(d);
if (set_typeinfo(d) != 0) goto err;
+ return;
- _numpy_internal = PyImport_ImportModule("numpy.core._internal");
- if (_numpy_internal != NULL) return;
-
err:
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src 2007-05-23 18:12:52 UTC (rev 3807)
+++ trunk/numpy/core/src/scalartypes.inc.src 2007-05-23 18:47:08 UTC (rev 3808)
@@ -740,8 +740,12 @@
static PyObject *
voidtype_flags_get(PyVoidScalarObject *self)
{
- return PyObject_CallMethod(_numpy_internal, "flagsobj", "Oii",
- self, self->flags, 1);
+ PyObject *flagobj;
+ flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0);
+ if (flagobj == NULL) return NULL;
+ ((PyArrayFlagsObject *)flagobj)->arr = NULL;
+ ((PyArrayFlagsObject *)flagobj)->flags = self->flags;
+ return flagobj;
}
static PyObject *
@@ -2657,11 +2661,15 @@
{
PyObject *tup;
PyObject *ret;
+ PyObject *_numpy_internal;
+
if (!PyDict_Check(fields)) {
PyErr_SetString(PyExc_TypeError,
"Fields must be a dictionary");
return NULL;
}
+ _numpy_internal = PyImport_ImportModule("numpy.core._internal");
+ if (_numpy_internal == NULL) return NULL;
tup = PyObject_CallMethod(_numpy_internal, "_makenames_list", "O", fields);
if (tup == NULL) return NULL;
ret = PyTuple_GET_ITEM(tup, 0);
More information about the Numpy-svn
mailing list