[New-bugs-announce] [issue6074] .pyc files created readonly if .py file is readonly, python won't overwrite

Peter Simanyi report at bugs.python.org
Thu May 21 00:04:23 CEST 2009


New submission from Peter Simanyi <psimanyi at namcobandaigames.com>:

Some source code control tools, like Perforce, by default sync files readonly, and it's useful to 
leave them readonly so that you can mark files changed by making them writeable even if they're not 
checked out (e.g. working offline).

When python implicitly compiles a .py file that's readonly, it will create a .pyc file that's 
readonly. This would be fine, except that when the .py file changes, python *silently* refuses to 
overwrite a .pyc file that's readonly, even if the directory is completely writable by the user 
executing Python.

The attached script shows this behavior. Running "python -v" will produce the following line 
showing this:

  import b # from c:\Documents and Settings\psimanyi\tmp\b.py
  # can't create c:\Documents and Settings\psimanyi\tmp\b.pyc

And because I hoped this was a Windows-only problem, I tested on OSX (Leopard) and Ubuntu (9.10 
alpha): it occurs on all three platforms.

Thanks!

--------------------------------

I fixed showpycreadonly.sh after attaching it, so to be sure you have the current version, it 
follows:

rm -f [ab].py{,c}

echo 'import b' > a.py
echo 'print "b"' > b.py
ls -l b.py
python a.py
ls -l b.pyc
rm b.pyc
chmod -w b.py
python a.py
ls -l b.pyc
touch b.py
python -v a.py 2>&1 | grep b.py

----------
components: Interpreter Core
files: showpycreadonly.sh
messages: 88138
nosy: pdsimanyi
severity: normal
status: open
title: .pyc files created readonly if .py file is readonly, python won't overwrite
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file14025/showpycreadonly.sh

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6074>
_______________________________________


More information about the New-bugs-announce mailing list