Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3031 Modified Files: Tag: release23-maint tarfile.py Log Message: [Patch #1043972, for bug #1017553] filemode() returns an incorrect value for the mode 07111 Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.8.12.4 retrieving revision 1.8.12.5 diff -u -d -r1.8.12.4 -r1.8.12.5 --- tarfile.py 25 Aug 2004 10:53:30 -0000 1.8.12.4 +++ tarfile.py 20 Oct 2004 11:49:28 -0000 1.8.12.5 @@ -174,39 +174,46 @@ return filemode_table = ( - (S_IFLNK, "l", - S_IFREG, "-", - S_IFBLK, "b", - S_IFDIR, "d", - S_IFCHR, "c", - S_IFIFO, "p"), - (TUREAD, "r"), - (TUWRITE, "w"), - (TUEXEC, "x", TSUID, "S", TUEXEC|TSUID, "s"), - (TGREAD, "r"), - (TGWRITE, "w"), - (TGEXEC, "x", TSGID, "S", TGEXEC|TSGID, "s"), - (TOREAD, "r"), - (TOWRITE, "w"), - (TOEXEC, "x", TSVTX, "T", TOEXEC|TSVTX, "t")) + ((S_IFLNK, "l"), + (S_IFREG, "-"), + (S_IFBLK, "b"), + (S_IFDIR, "d"), + (S_IFCHR, "c"), + (S_IFIFO, "p")), + + ((TUREAD, "r"),), + ((TUWRITE, "w"),), + ((TUEXEC|TSUID, "s"), + (TSUID, "S"), + (TUEXEC, "x")), + + ((TGREAD, "r"),), + ((TGWRITE, "w"),), + ((TGEXEC|TSGID, "s"), + (TSGID, "S"), + (TGEXEC, "x")), + + ((TOREAD, "r"),), + ((TOWRITE, "w"),), + ((TOEXEC|TSVTX, "t"), + (TSVTX, "T"), + (TOEXEC, "x")) +) def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ - s = "" - for t in filemode_table: - while True: - if mode & t[0] == t[0]: - s += t[1] - elif len(t) > 2: - t = t[2:] - continue - else: - s += "-" - break - return s + perm = [] + for table in filemode_table: + for bit, char in table: + if mode & bit == bit: + perm.append(char) + break + else: + perm.append("-") + return "".join(perm) if os.sep != "/": normpath = lambda path: os.path.normpath(path).replace(os.sep, "/")