Re: _namemapper: check error from PyImport_ImportModule
"R. Tyler Ballance" <[email protected]>
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <20090607200417.GC15900@starfruit> |
On Sun, Jun 07, 2009 at 04:03:03PM -0300, Bogdano Arendartchuk wrote: > 2009/6/7 R. Tyler Ballance <[email protected]>: > > > > Interesting, do you have a test case that causes the import of `pprint` > > to raise an exception like this? > > Notice myimport lacks the 'level' parameter: > > import __builtin__ > real_import = __builtin__.__import__ > def myimport(name, g=None, l=None, fl=[]): > return real_import(name, g, l, fl) > __builtin__.__import__ = myimport > import Cheetah._namemapper One more thing, this doesn't reproduce the error for me, since the 'level' parameter is only passed in 2.6+ when using relative or absolute imports. If I run this test on my Python 2.4 sandbox I get no issues whatsoever. Do you have an actual full reproduction case? :/ Cheers > > > > > I would also say that using PyErr_Occurred() and making sure the > > exception propagated further up is a better idea than just returning (or > > just calling Py_FatalError()) > > > > Please don't call Py_FatalError() for it, it would not give the chance > to the interpreter to handle the pending exception from __import__ and > would make debugging harder (as it was in my case). When using the > patch, the following traceback is shown: > > Traceback (most recent call last): > File "crash.py", line 6, in <module> > import Cheetah._namemapper > File "crash.py", line 4, in myimport > return real_import(name, g, l, fl) > TypeError: myimport() takes at most 4 arguments (5 given) -- -R. Tyler Ballance Slide, Inc. ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkosHUEACgkQFCbH3D9R4W+p5gCeIu2ANOFjUCtbKRLH753xPmwt JOMAnjo/xqQfIHR0lsRJGYh43YBblSSr =QP89 -----END PGP SIGNATURE-----