<br><br><div><span class="gmail_quote">On 1/3/07, <b class="gmail_sendername">Josiah Carlson</b> <<a href="mailto:jcarlson@uci.edu">jcarlson@uci.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>"Guido van Rossum" <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>> On 1/3/07, Josiah Carlson <<a href="mailto:jcarlson@uci.edu">jcarlson@uci.edu</a>> wrote:<br>> > -1 .  The only thing that possibly should be fixed is that modules
<br>> > should only be inserted into sys.modules after they have been imported<br>> > completely and correctly.<br>><br>> I agree, but there's the wrinkle that during recursive imports you<br>> want partially-imported modules to be importable. I believe we once
<br>> agreed on a solution but I don't recall what it was. Does anybody<br>> remember?<br><br>I don't remember what was agreed upon, but what about something like...<br><br>    try:<br>        newmodule = ...
<br>        sys.modules[name] = newmodule<br>        handle_the_import(newmodule, ...)<br>    except:<br>        del sys.modules[name]<br>        raise</blockquote><div><br><br>My re-implementation does exactly that (I just sometimes postpone the module creation to the top of the handle_the_import function).
<br><br>-Brett<br></div></div><br>