Title: absolute imports for logging
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: dries_desmet, mgerstel, vinay.sajip
Priority: normal Keywords: patch

Created on 2017-01-23 13:25 by mgerstel, last changed 2017-02-07 18:34 by vinay.sajip. This issue is now closed.

File name Uploaded Description Edit
0001-absolute-import.patch mgerstel, 2017-01-23 13:25 proposed patch
Messages (4)
msg286083 - (view) Author: Markus Gerstel (mgerstel) * Date: 2017-01-23 13:25
Running 'import logging' causes at minimum 46 failing 'open' and 12 failing 'stat' calls because python looks for packages inside python/Lib/logging which will never be there, in particular: sys, os, time, cStringIO, traceback, warnings, weakref, collections, codecs, thread, threading, atexit.

The impact of this is limited when python is installed locally, but noticeable when run on a networked file system.

How to reproduce: 
$ strace python -c "import logging;" 2>&1 | grep ENOENT | grep "\/logging\/"

How to fix:
Add 'from __future__ import absolute_import' to all files in the logging directory.
A relevant patch is attached.
msg286095 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2017-01-23 16:30
There's nothing particular about logging here, is there? Any of the 2.7 stdlib modules will exhibit similar behaviour, since that __future__ import is not in general defined in the stdlib modules, other than in the test suite.
msg286097 - (view) Author: Markus Gerstel (mgerstel) * Date: 2017-01-23 16:47
Yes, this is indeed the same for other stdlib modules, too. Logging is just the first one that came to attention in our investigations.

I haven't prepared any other patches yet though, because your answer could easily be "No, we cannot consider these changes under any circumstances for 2.7 because $reason".
msg286103 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2017-01-23 17:26
> No, we cannot consider these changes under any circumstances for 2.7 because ...

Well, it would change import behaviour in a backwards-incompatible way, wouldn't it?
Date User Action Args
2017-02-07 18:34:32vinay.sajipsetstatus: open -> closed
resolution: not a bug
stage: resolved
2017-01-23 17:26:46vinay.sajipsetmessages: + msg286103
2017-01-23 16:47:54mgerstelsetmessages: + msg286097
2017-01-23 16:30:08vinay.sajipsetmessages: + msg286095
2017-01-23 15:10:59mgerstelsetnosy: + vinay.sajip
2017-01-23 15:06:51dries_desmetsetnosy: + dries_desmet
2017-01-23 13:25:03mgerstelcreate