[Python-Dev] [Python-checkins] cpython: fix doc typo for library/test.rst (original) (raw)

Eli Bendersky eliben at gmail.com
Wed Jul 27 20:04:10 CEST 2011


Actually I think this is no longer true. import_fresh_module raises an ImportError if name can't be imported, or returns None if the fresh module is not found.

Its use case is to enable or block accelerations for modules that optionally provide one. All the modules that currently use importfreshmodule are (afaik) always available (json, warnings, heapq), so raising SkipTest when the module is missing is not useful now. It returns None in the case an acceleration is missing, so e.g. in "cjson = importfreshmodule('json', fresh=['json'])" cjson will be None and it will be possible to do things like @skipUnless(cjson, 'requires json'). Here raising an ImportError will defeat (part of) the purpose of the function, i.e. avoiding: try: import json except ImportError: json = None and raising a SkipTest when the accelerations are missing is not an option if there are other tests (e.g. the tests for the Python implementation). These changes come from http://hg.python.org/cpython/**rev/c1a12a308c5b<http://hg.python.org/cpython/rev/c1a12a308c5b>. Before the change importfreshmodule was still returning the module (e.g. json) even when the acceleration (fresh=['json']) was missing, and the C tests were run twice using the same pure-python module used for the Py ones. The typo and the wrong doc is also on 2.7. Ezio, thanks. I opened issue 12645 to track this.

Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20110727/09c84edd/attachment.html>



More information about the Python-Dev mailing list