[PEAK] Packaging peak apps

Stephen Haberman stephenh at chase3000.com
Thu Sep 16 18:43:37 EDT 2004

> 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.

Oh. You're right. Well, sheesh, turns out path was never null in the first
place. I did not initialize it to null and so it was just random junk, hence
it got by the null check but then caught by the PyList_Check.

I updated the sf bug with the patch that is now just about the loader

> >now it was failing, saying that the new function,
> >get_foo, could not be found, and, here's where my methodology gets fancy,
> >guessed that 'mod=reload(mod)' would work, and it did.
> Aha...  did your old test actually add a new attribute?  I don't remember.

Yes, it should have, as that was what I was trying to test. I am fairly
certain a) the test was adding .get_foo() and b) .get_foo() was successfully
being called with only "reload(mod)". This was back in April.

Granted, I could have been just wrong back then or remembering wrong now on
either a) or b).

Huh. I agree, its weird that supposedly that used to work. Here was the test
section of the original patch I submitted:

+        # Test reload
+        if not importer:
+            old_test_co = test_co
+            test_co = compile(test_src + "\ndef get_foo(): return 1",
"<???>", "exec")
+            TestImporter.modules = {
+                "hooktestmodule": (False, test_co),
+                "hooktestpackage": (True, test_co),
+                "hooktestpackage.sub": (True, test_co),
+                "hooktestpackage.sub.subber": (False, test_co),
+            }
+            reload(hooktestmodule)
+            self.assertEqual(hooktestmodule.get_name(), "hooktestmodule")
+            self.assertEqual(hooktestmodule.get_foo(), 1)

I'm not sure what the "if not importer" was for. It works just fine without
that check now so I took it out.

So. I dunno, maybe the "reload(hooktestmodule)" section was never even being
executed? That would have been stupid, but possible.

> >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
> >fully implement them correctly.
> Ouch.  I was hoping that you were the one.  I guess now it's up to me.

My apologies. Good luck. :-)

- Stephen

More information about the PEAK mailing list