]> granicus.if.org Git - python/commitdiff
Fix signed/unsigned wng. Unfortunately, (unsigned char) << int
authorTim Peters <tim.peters@gmail.com>
Fri, 5 Jan 2001 00:54:29 +0000 (00:54 +0000)
committerTim Peters <tim.peters@gmail.com>
Fri, 5 Jan 2001 00:54:29 +0000 (00:54 +0000)
has type int in C.

Python/pythonrun.c

index 45d21dd772090b7b0f26a2fdf283cbb5ac7d4d24..4dc2ddd8b718d4a43c4d05ccfd7e2edcdeaf4369 100644 (file)
@@ -570,8 +570,8 @@ maybe_pyc_file(FILE *fp, char* filename, char* ext, int closeit)
                   be read as they are on disk. */
                unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF;
                unsigned char buf[2];
-               if (fread(buf, 1, 2, fp) == 2 
-                   && (buf[1]<<8 | buf[0]) == halfmagic)
+               if (fread(buf, 1, 2, fp) == 2
+                   && ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic)
                        return 1;
                fseek(fp, 0, SEEK_SET);
        }