Changeset 422

Show
Ignore:
Timestamp:
Sun Feb 17 19:23:43 2008
Author:
giovannibajo
Message:

Merge of the startup_crash branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/source/common/launch.c

    r330 r422  
    172 172  
    173 173  
    174   int testTempPath(char *buff)  
      174 #ifdef WIN32  
      175  
      176 int getTempPath(char *buff)  
    175 177 {  
    176           char base[16];  
    177           int n;  
      178     int i;  
      179     char *ret;  
      180     char prefix[16];  
      181  
      182     GetTempPath(MAX_PATH, buff);  
      183     sprintf(prefix, "_MEI%d", getpid());  
      184  
      185     // Windows does not have a race-free function to create a temporary  
      186     // directory. Thus, we rely on _tempnam, and simply try several times  
      187     // to avoid stupid race conditions.  
      188     for (i=0;i<5;i++) {  
      189         ret = _tempnam(buff, prefix);  
      190         if (mkdir(ret) == 0) {  
      191             strcpy(buff, ret);  
      192             strcat(buff, "\\");  
      193             free(ret);  
      194             return 1;  
      195         }  
      196         free(ret);  
      197     }  
      198     return 0;  
      199 }  
    178 200  
    179           n = strlen(buff);  
    180           if ( buff[n-1] == '/' || buff[n-1] == '\\' )  
    181                   sprintf(base, "_MEI%d", getpid());  
    182           else  
    183                   sprintf(base, "%s_MEI%d", SEP, getpid());  
    184           strcat(buff, base);  
    185   #ifdef WIN32  
    186           if (mkdir(buff) == 0) {  
    187 201 #else  
    188           if (mkdir(buff, 0700) == 0) {  
    189   #endif  
    190                   strcat(buff, SEP);  
    191                   return 1;  
    192           }  
    193           return 0;  
      202  
      203 int testTempPath(char *buff)  
      204 {  
      205         strcat(buff, "/_MEIXXXXXX");  
      206     if (mkdtemp(buff))  
      207     {  
      208         strcat(buff, "/");  
      209         return 1;  
      210     }  
      211     return 0;     
    194 212 }  
    195 213  
    196   void getTempPath(char *buff)  
      214 int getTempPath(char *buff)  
    196 214 {  
    197   #ifdef WIN32  
    198           GetTempPath(MAX_PATH, buff);  
    199           testTempPath(buff);  
    200   #else  
    201 215         static const char *envname[] = {  
    202 216                 "TMPDIR", "TEMP", "TMP", 0  
     
    213 227                         strcpy(buff, p);  
    214 228                         if (testTempPath(buff))  
    215                                   return;  
      229                                 return 1;  
    215 229                 }  
    216 230         }  
     
    219 233                 strcpy(buff, dirname[i]);  
    220 234                 if (testTempPath(buff))  
    221                           return;  
      235                         return 1;  
    221 235         }  
    222           buff[0] = '\0';  
    223   #endif  
      236     return 0;  
    224 237 }  
      238  
      239 #endif  
      240  
    225 241 /*  
    226 242  * Set up paths required by rest of this module  
     
    804 820         strcpy(fnm, path);  
    805 821         strcat(fnm, name);  
    806           if (stat(fnm, &sbuf) == -1) {  
    807                   VS("%s\n", fnm);  
    808                   return fopen(fnm, "wb");  
    809           }  
    810           return NULL;  
      822         if (stat(fnm, &sbuf) == 0) {  
      823                 OTHERERROR("WARNING: file already exists but should not: %s\n", fnm);  
      824     }  
      825         return fopen(fnm, "wb");  
    811 826 }  
    812 827 /*  
     
    824 839  
    825 840         if (!f_workpath) {  
    826                   getTempPath(f_temppath);  
      841                 if (!getTempPath(f_temppath))  
      842                 {  
      843             FATALERROR("INTERNAL ERROR: cannot create temporary directory!\n");  
      844             return -1;  
      845                 }  
    827 846 #ifdef WIN32  
    828 847                 strcpy(f_temppathraw, f_temppath);  
     
    833 852                 f_workpath = f_temppath;  
    834 853         }  
      854          
    835 855         out = openTarget(f_workpath, ptoc->name);  
    836 856  
    837 857         if (out == NULL)  {  
    838 858                 FATALERROR("%s could not be extracted!\n", ptoc->name);  
      859                 return -1;  
    839 860         }  
    840 861         else {  
     
    1068 1089         if ( finfo.attrib & _A_SUBDIR )  
    1069 1090                 clear(fnm);  
    1070           else  
    1071                   remove(fnm);  
      1091         else if (remove(fnm)) {  
      1092         /* HACK: Possible concurrency issue... spin a little while */  
      1093         Sleep(100);  
      1094         remove(fnm);  
      1095     }  
    1072 1096 }  
    1073 1097 void clear(const char *dir)  
  • trunk/doc/CHANGES.txt

    r420 r422  
    30 30    inside a package, the module is now removed from the parent's  
    31 31    namespace (to match the behaviour of Python itself).  
    32      
      32  + Fix random race-condition at startup of one-file packages, that was  
      33    causing this exception to be generated: "PYZ entry 'encodings' (0j)  
      34    is not a valid code object".  
      35  
    33 36 PyInstaller 1.3  
    34 37 ---------------  
  • trunk/archive.py

    r43 r422  
    276 276 class DummyZlib:  
    277 277     def decompress(self, data):  
    278           return data  
      278         raise RuntimeError, "zlib required but cannot be imported"  
    278 278     def compress(self, data, lvl):  
    279           return data  
      279         raise RuntimeError, "zlib required but cannot be imported"  
    279 279  
    280 280 import iu