@@ -113,10 +113,7 @@ static PyObject *
113113lazy_import_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
114114{
115115 PyTypeObject * base_tp = & PyLazyImport_Type ;
116- if (
117- (type == base_tp || type -> tp_init == base_tp -> tp_init )
118- && !_PyArg_NoKeywords ("lazy_import" , kwds )
119- ) {
116+ if (!_PyArg_NoKeywords ("lazy_import" , kwds )) {
120117 return NULL ;
121118 }
122119
@@ -126,9 +123,9 @@ lazy_import_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
126123 }
127124
128125 PyObject * builtins = PyTuple_GET_ITEM (args , 0 );
129- PyObject * from = PyTuple_GET_ITEM (args , 1 );
130- PyObject * attr = nargs == 3 ? PyTuple_GET_ITEM (args , 2 ) : NULL ;
131- return _PyLazyImport_New (builtins , from , attr );
126+ PyObject * name = PyTuple_GET_ITEM (args , 1 );
127+ PyObject * fromlist = nargs == 3 ? PyTuple_GET_ITEM (args , 2 ) : NULL ;
128+ return _PyLazyImport_New (builtins , name , fromlist );
132129}
133130
134131PyObject *
@@ -160,16 +157,17 @@ PyDoc_STRVAR(lazy_import_doc,
160157"\n"
161158"Represents a deferred import that will be resolved on first use.\n"
162159"\n"
163- "This type is used internally by the 'lazy import' statement.\n"
164- "Users should not typically create instances directly." );
160+ "Instances of this object accessed from the global scope will be\n"
161+ "automatically imported based upon their name and then replaced with\n"
162+ "the imported value." );
165163
166164PyTypeObject PyLazyImport_Type = {
167165 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
168166 .tp_name = "lazy_import" ,
169167 .tp_basicsize = sizeof (PyLazyImportObject ),
170168 .tp_dealloc = lazy_import_dealloc ,
171169 .tp_repr = lazy_import_repr ,
172- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE ,
170+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC ,
173171 .tp_doc = lazy_import_doc ,
174172 .tp_traverse = lazy_import_traverse ,
175173 .tp_clear = lazy_import_clear ,
0 commit comments