[Python-Dev] PEP 3147, __pycache__ directories and umask
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 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?)
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