#6412 -  Check for file permissions for proper error messages

(https://code.djangoproject.com/ticket/6412)

Rebased previous patch to master and added ``isfile()`` check.