Brett Cannon wrote:
On Fri, Feb 20, 2009 at 12:31, Daniel Stutzbach <[email protected] <mailto:[email protected]>> wrote:On Fri, Feb 20, 2009 at 1:44 PM, Brett Cannon <[email protected] <mailto:[email protected]>> wrote: Now, from what I can tell, Antoine is suggesting having _pyio and a _io and then io is simply: try: from _io import * except ImportError: from _pyio import * That works for testing as you can then have test classes have an attribute for the module to use and then create two subclasses which set what module to use (kind of like how test_warnings currently does it). But this only really works for complete module replacements, not modules like pickle where only key portions have been rewritten (which happens more often than the complete rewrite). A slight change would make it work for modules where only key functions have been rewritten. For example, pickle.py could read: from _pypickle import * try: from _pickle import * except ImportError: passTrue, although that still suffers from the problem of overwriting things like __name__, __file__, etc.
What do you mean overwriting __name__ and __file__? Doing import * in a pure Python file doesn't override these.
Michael
-Brett ------------------------------------------------------------------------ _______________________________________________ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog _______________________________________________ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
