Staging
v0.5.1
https://github.com/python/cpython
Revision 3008bc0f4abb3f71433b1fcd97cc801da0a866cc authored by Brett Cannon on 12 August 2015, 01:01:31 UTC, committed by Brett Cannon on 12 August 2015, 01:01:31 UTC
ImportError if __name__ is not defined on a package.

Thanks to Armin Rigo for the bug report and diagnosing the cause.
1 parent bb8a52a
Raw File
Tip revision: 3008bc0f4abb3f71433b1fcd97cc801da0a866cc authored by Brett Cannon on 12 August 2015, 01:01:31 UTC
Issue #24492: make sure that ``from ... import ...` raises an
Tip revision: 3008bc0
example.c
#include "Python.h"

static PyObject *
ex_foo(PyObject *self, PyObject *args)
{
    printf("Hello, world\n");
    Py_INCREF(Py_None);
    return Py_None;
}

static PyMethodDef example_methods[] = {
    {"foo", ex_foo, METH_VARARGS, "foo() doc string"},
    {NULL, NULL}
};

static struct PyModuleDef examplemodule = {
    PyModuleDef_HEAD_INIT,
    "example",
    "example module doc string",
    -1,
    example_methods,
    NULL,
    NULL,
    NULL,
    NULL
};

PyMODINIT_FUNC
PyInit_example(void)
{
    return PyModule_Create(&examplemodule);
}
back to top