homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brett.cannon, vstinner
Date 2016年03月11日.11:44:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457696667.94.0.108519122037.issue26538@psf.upfronthosting.co.za>
In-reply-to
Content
Extract of test.libregrtest.setup_tests():
 for module in sys.modules.values():
 if hasattr(module, '__path__'):
 module.__path__ = [os.path.abspath(path)
 for path in module.__path__]
 if hasattr(module, '__file__'):
 module.__file__ = os.path.abspath(module.__file__)
Because of this code, it's not possible to store test files outside Lib/test/. For the issue #26295 (test_regrtest), I would like to create a temporary directory and then a subdirectory test/ to create temporary test files.
Attached patch adds _NamespacePath.__setitem__() method and modify setup_tests() to keep the _NamespacePath type of module.__path__.
Maybe we should move this abspath() code somewhere in importlib. The site module already contains similar code, abs_paths() function:
 for m in set(sys.modules.values()):
 if (getattr(getattr(m, '__loader__', None), '__module__', None) not in
 ('_frozen_importlib', '_frozen_importlib_external')):
 continue # don't mess with a PEP 302-supplied __file__
 try:
 m.__file__ = os.path.abspath(m.__file__)
 except (AttributeError, OSError):
 pass
 try:
 m.__cached__ = os.path.abspath(m.__cached__)
 except (AttributeError, OSError):
 pass
Since this code looks to depend on the implementation of importlib (the __loader__ test), IMHO it makes sense to move the code directly somewhere in importlib.
History
Date User Action Args
2016年03月11日 11:44:27vstinnersetrecipients: + vstinner, brett.cannon
2016年03月11日 11:44:27vstinnersetmessageid: <1457696667.94.0.108519122037.issue26538@psf.upfronthosting.co.za>
2016年03月11日 11:44:27vstinnerlinkissue26538 messages
2016年03月11日 11:44:27vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /