Django

Code

Ticket #8455: issue-8455.errno2.diff

File issue-8455.errno2.diff, 1.0 kB (added by carljm, 5 months ago)

os.errno is Python 2.5 only, use top-level errno instead

  • django/core/files/storage.py

    old new  
    11import os 
     2import errno 
    23import urlparse 
    34 
    45from django.conf import settings 
     
    161162                    finally: 
    162163                        locks.unlock(fd) 
    163164                        os.close(fd) 
    164             except OSError: 
    165                 # Ooops, we need a new file name. 
    166                 name = self.get_available_name(name) 
    167                 full_path = self.path(name) 
     165            except OSError, e: 
     166                if e.errno == errno.EEXIST: 
     167                    # Ooops, we need a new file name. 
     168                    name = self.get_available_name(name) 
     169                    full_path = self.path(name) 
     170                else: 
     171                    raise 
    168172            else: 
    169173                # OK, the file save worked. Break out of the loop. 
    170174                break