summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-12-18 13:39:16 (GMT)
committerGuido van Rossum <guido@python.org>1991-12-18 13:39:16 (GMT)
commit97dddba1bbb91dcf538cfae1ea5b0bf16fc0468c (patch)
tree58dfd18d1623fab12a568c31a9bccbb1465e608d
parent7030d0a1597556aa20b715351ad61ed96e98ce7c (diff)
downloadcpython-97dddba1bbb91dcf538cfae1ea5b0bf16fc0468c.zip
cpython-97dddba1bbb91dcf538cfae1ea5b0bf16fc0468c.tar.gz
cpython-97dddba1bbb91dcf538cfae1ea5b0bf16fc0468c.tar.bz2
Better check to avoid executables.
-rwxr-xr-xTools/scripts/xxci.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py
index 253ad2d..ef4ff11 100755
--- a/Tools/scripts/xxci.py
+++ b/Tools/scripts/xxci.py
@@ -11,6 +11,8 @@ import stat
import path
import commands
+EXECMAGIC = '\001\140\000\010'
+
MAXSIZE = 200*1024 # Files this big must be binaries and are skipped.
def getargs():
@@ -30,7 +32,8 @@ def getargs():
badnames = ['tags', 'TAGS', 'xyzzy', 'nohup.out', 'core']
badprefixes = ['.', ',', '@', '#', 'o.']
badsuffixes = \
- ['~', '.a', '.o', '.old', '.bak', '.orig', '.new', '.prev', '.not']
+ ['~', '.a', '.o', '.old', '.bak', '.orig', '.new', '.prev', '.not', \
+ '.pyc', '.elc']
# XXX Should generalize even more to use fnmatch!
def skipfile(file):
@@ -43,7 +46,14 @@ def skipfile(file):
st = posix.stat(file)
except posix.error:
return 1 # Doesn't exist -- skip it
- return st[stat.ST_SIZE] >= MAXSIZE
+ if st[stat.ST_SIZE] >= MAXSIZE: return 1
+ # Skip executables
+ try:
+ data = open(file, 'r').read(len(EXECMAGIC))
+ if data = EXECMAGIC: return 1
+ except:
+ pass
+ return 0
def badprefix(file):
for bad in badprefixes: