Author vstinner
Recipients brett.cannon, eric.smith, vstinner
Date 2016-03-11.17:55:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Longer extract of setup_tests(), with the long comment:

    # Some times __path__ and __file__ are not absolute (e.g. while running from
    # Lib/) and, if we change the CWD to run the tests in a temporary dir, some
    # imports might fail.  This affects only the modules imported before os.chdir().
    # These modules are searched first in sys.path[0] (so '' -- the CWD) and if
    # they are found in the CWD their __file__ and __path__ will be relative (this
    # happens before the chdir).  All the modules imported after the chdir, are
    # not found in the CWD, and since the other paths in sys.path[1:] are absolute
    # ( absolutize them), the __file__ and __path__ will be absolute too.
    # Therefore it is necessary to absolutize manually the __file__ and __path__ of
    # the packages to prevent later imports to fail when the CWD is different.
    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__)
Date User Action Args
2016-03-11 17:55:49vstinnersetrecipients: + vstinner, brett.cannon, eric.smith
2016-03-11 17:55:49vstinnersetmessageid: <>
2016-03-11 17:55:49vstinnerlinkissue26538 messages
2016-03-11 17:55:49vstinnercreate