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 test_import.py:
def test_writable_directory(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?) 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.
signature.asc
Description: PGP signature
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com