[Python-checkins] r52125 - python/branches/pep302_phase2/Python/import.c
brett.cannon
python-checkins at python.org
Wed Oct 4 01:24:41 CEST 2006
Author: brett.cannon
Date: Wed Oct 4 01:24:41 2006
New Revision: 52125
Modified:
python/branches/pep302_phase2/Python/import.c
Log:
Beginnings of built-in module importer.
Tests will come after next svnmerge thanks to rewriting test_imp to use
unittest.
Modified: python/branches/pep302_phase2/Python/import.c
==============================================================================
--- python/branches/pep302_phase2/Python/import.c (original)
+++ python/branches/pep302_phase2/Python/import.c Wed Oct 4 01:24:41 2006
@@ -3037,6 +3037,59 @@
PyType_GenericNew /* tp_new */
};
+typedef struct {
+ PyObject_HEAD
+} BuiltinImporterObject;
+
+
+static PyMethodDef builtinimporter_methods[] = {
+ {NULL}
+};
+
+static PyTypeObject BuiltinImporterType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "imp.BuiltinImporter", /* tp_name */
+ sizeof(BuiltinImporterObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
+ "Importer for built-in modules.", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ builtinimporter_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+};
PyMODINIT_FUNC
initimp(void)
@@ -3065,6 +3118,13 @@
if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure;
if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure;
+ if (PyType_Ready(&BuiltinImporterType) < 0)
+ goto failure;
+ Py_INCREF(&BuiltinImporterType);
+ if (PyModule_AddObject(m, "BuiltinImporter",
+ (PyObject *)&BuiltinImporterType) < 0)
+ goto failure;
+
Py_INCREF(&NullImporterType);
PyModule_AddObject(m, "NullImporter", (PyObject *)&NullImporterType);
failure:
More information about the Python-checkins
mailing list