On 23Mar2010 11:40, I wrote:
| | * Raise an exception or refuse to create __pycache__ if it's not writable
| |   (again, by whom?)
| 
| -3
| Bleah. My python program won't run because an obscure (to the user)
| directory had unusual permissions?

Clarification: I'm -3 on the exception. Silent failure to make the
__pycache__ would do, and may be better than silently making a useless
(unwritable) one.  

How about:

  made_it = False
  ok = False
  try:
    if not isdir(__pycache__dir):
      mkdir(__pycache__dir)
      made_it = True
    write pyc content ...
    ok = True
  except OSError, IOerror etc:
    if not ok:
      os.remove pyc content file
      if made_it:
        rmdir(__pycache__dir) but be quiet if this fails,
          eg if it is not empty because another process or thread
             added stuff

So silent tidyup attempt on failure, but no escaping exception.

Cheers,
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The govt MUST regulate the Net NOW! We can't have average people saying
what's on their minds!  - ezwri...@netcom.com
_______________________________________________
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

Reply via email to