Author anjos
Recipients anjos
Date 2017-04-26.08:53:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493196813.64.0.567701209744.issue30167@psf.upfronthosting.co.za>
In-reply-to
Content
Apparently, "import site; site.main()" does not seem to work anymore on Python 3.6 and superior.

The reason is a change on the behavior of "os.path.abspath(None)". Before Python 3.6, it used to report an AttributeError which is properly caught inside "site.abs_paths" (see: https://github.com/python/cpython/blob/master/Lib/site.py#L99), making it ignore __main__, one of sys.modules, which has __file__ and __cached__ set to None.

With Python 3.6 and superior, os.path.abspath(None) reports a TypeError, which makes calling "site.main()" raise an exception and stop.

How to reproduce: On python 3.6 or superior, do "import site; site.main()".

Expected behavior: Exception is properly caught and treated inside "site.abs_paths", ignoring modules in which __file__ and/or __cached__ are set to None.
History
Date User Action Args
2017-04-26 08:53:33anjossetrecipients: + anjos
2017-04-26 08:53:33anjossetmessageid: <1493196813.64.0.567701209744.issue30167@psf.upfronthosting.co.za>
2017-04-26 08:53:33anjoslinkissue30167 messages
2017-04-26 08:53:33anjoscreate