[Python-Dev] Re:import.c

Phillip J. Eby pje at telecommunity.com
Sat May 29 16:01:59 EDT 2004


At 09:46 PM 5/29/04 +0200, Wiktor Sadowski wrote:
>----------------------------------------------------------------------------
>--------
>in import_from (ceval.c):
>if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
>      if(!PyModule_GetState(v))
>  /*raise the error and warn against circular import*/
>      else
>        /*default error*/
>----------------------------------------------------------------------------
>--------
>the same in PyGeneric_GetAttr (object.c):
>/* before raising an error*/
>if(PyModule_Check(obj) && !PyModule_GetState(obj))
>     /*add a circular import warning to the error string*/
>else
>   /*default error*/
>----------------------------------------------------------------------------
>--------

IMO, if this approach is used, the module type should instead get a custom 
tp_getattro method that checks the flag, rather than scattering this logic 
across unrelated functions.





More information about the Python-Dev mailing list