[PEAK] Packaging peak apps

Phillip J. Eby pje at telecommunity.com
Thu Sep 16 17:57:35 EDT 2004


At 04:31 PM 9/16/04 -0500, Stephen Haberman wrote:


> > Hi Stephen.  I don't understand why 'path' has to be non-null.  Not only
>that, but if it *is* null and the module has no __path__, your patch is
>still going to pass in a null path.  So I'm confused.  How did you discover
>the problem?
>
>
>Good point. I discovered the problem by originally not having that path code
>in the subname == NULL case and having it fail on a line somewhere in
>find_module.
>
>Yeah, this line (1154):
>
>         if (path == NULL || !PyList_Check(path)) {
>                 PyErr_SetString(PyExc_ImportError,
>                                 "sys.path must be a list of directory
>names");
>                 return NULL;
>         }
>
>I was getting an "ImportError: sys.path must be..." exception with my
>original patch. Scratching my head and looking at what the subname != NULL
>case did with its path variable, I tried doing the same in the subname ==
>NULL case, assigning path to m.__path__, and it magically worked.

That's downright weird.  The line above appears *after* a block that does 
'path = PySys_GetObject("path")', if path is null!  There shouldn't be a 
way to get there unless sys.path isn't a list, or is itself null.



> > Similarly, I'm confused as to why 'mod=reload(mod)' would be necessary
>now, but wasn't before.  There have been no changes that I see in
>test_importhooks that would cause that.  What was your testing methodology
>for this?
>
>My methodology was that my original patch had just 'reload(mod)' and, though
>it worked great before,

That's the part I don't get; test_importhooks hasn't changed lately, and 
the code I'm looking at should *never* have worked, because it always 
created a new module.



>now it was failing, saying that the new function,
>get_foo, could not be found, and, here's where my methodology gets fancy, I
>guessed that 'mod=reload(mod)' would work, and it did.

Aha...  did your old test actually add a new attribute?  I don't remember.



>So, with those two things in mind, I think my patches will just have to be a
>starting point for someone who really knows what they're doing to finish and
>fully implement them correctly.

Ouch.  I was hoping that you were the one.  I guess now it's up to me.





More information about the PEAK mailing list