[Python-Dev] PEP 3147, pycache directories and umask (original) (raw)

Brett Cannon brett at python.org
Mon Mar 22 22:28:26 CET 2010


On Mon, Mar 22, 2010 at 06:56, Barry Warsaw <barry at python.org> wrote:

I have a pretty good start on PEP 3147 implementation [1], but I've encountered a situation that I'd like to get some feedback on.  Here's the test case illustrating the problem.  From testimport.py:

 def testwritabledirectory(self):  # The umask is not conducive to creating a writable pycache  # directory.  with umask(0o222):  import(TESTFN)  self.assertTrue(os.path.exists('pycache'))  self.assertTrue(os.path.exists(os.path.join(  'pycache', '{}.{}.pyc'.format(TESTFN, self.tag)))) The pycache directory does not exist before the import, and the import machinery creates the directory, but the umask leaves the directory unwritable by anybody.  So of course when the import machinery goes to write the .pyc file inside pycache, it fails.  This does not cause an ImportError though, just like if today the package directory were unwritable. This might be different than today's situation though because once the unwritable pycache directory is created, nothing is going to change that without explicit user interaction, and that might be difficult after the fact. I'm not sure what the right answer is.  Some possible choices: * Tough luck * Force the umask so that the directory is writable, but then the question is,  by whom?  ugo+w or something less? * Copy the permissions from the parent directory and ignore umask * Raise an exception or refuse to create pycache if it's not writable  (again, by whom?)

I say tough luck. At the moment if you can't write a .pyc it is a silent failure; don't see the difference as significant enough to warrant changing the practice.

-Brett

Or maybe you have a better idea?  What's the equivalent situation on Windows and how would things work there? -Barry [1] https://edge.launchpad.net/~barry/python/pep3147 P.S. I'm down to only 8 unit test failures.


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/brett%40python.org



More information about the Python-Dev mailing list