~ubuntu-branches/ubuntu/lucid/python2.6/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/issue8140.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-31 18:52:32 UTC
  • Revision ID: james.westby@ubuntu.com-20100331185232-lqvp3f7b7zj9vkns
Tags: 2.6.5-1ubuntu3
* debian/patches/issue8140.dpatch: Incomplete patch; regenerate.
* debian/patches/issue8032.dpatch: Update to v4:
  - Add support for PySetObject (set/frozenset).
  - Add support for PyBaseExceptionObject (BaseException).
  - Fix a signed vs unsigned char issue that led to exceptions
    in gdb for PyStringObject instances.
  - Handle the case of loops in the object reference graph.
  - Unit tests for all of the above.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
esac
24
24
exit 0
25
25
 
26
 
--- Lib/compileall.py~  2010-03-15 19:23:42.189842057 +0100
27
 
+++ Lib/compileall.py   2010-03-15 19:24:46.549844869 +0100
28
 
@@ -164,12 +164,14 @@
 
26
--- Lib/compileall.py.orig      2010-03-20 15:18:22.457061066 +0100
 
27
+++ Lib/compileall.py   2010-03-31 18:51:32.497377764 +0200
 
28
@@ -16,7 +16,7 @@
 
29
 import sys
 
30
 import py_compile
 
31
 
 
32
-__all__ = ["compile_dir","compile_path"]
 
33
+__all__ = ["compile_dir","compile_file","compile_path"]
 
34
 
 
35
 def compile_dir(dir, maxlevels=10, ddir=None,
 
36
                 force=0, rx=None, quiet=0):
 
37
@@ -47,35 +47,9 @@
 
38
             dfile = os.path.join(ddir, name)
 
39
         else:
 
40
             dfile = None
 
41
-        if rx is not None:
 
42
-            mo = rx.search(fullname)
 
43
-            if mo:
 
44
-                continue
 
45
-        if os.path.isfile(fullname):
 
46
-            head, tail = name[:-3], name[-3:]
 
47
-            if tail == '.py':
 
48
-                cfile = fullname + (__debug__ and 'c' or 'o')
 
49
-                ftime = os.stat(fullname).st_mtime
 
50
-                try: ctime = os.stat(cfile).st_mtime
 
51
-                except os.error: ctime = 0
 
52
-                if (ctime > ftime) and not force: continue
 
53
-                if not quiet:
 
54
-                    print 'Compiling', fullname, '...'
 
55
-                try:
 
56
-                    ok = py_compile.compile(fullname, None, dfile, True)
 
57
-                except KeyboardInterrupt:
 
58
-                    raise KeyboardInterrupt
 
59
-                except py_compile.PyCompileError,err:
 
60
-                    if quiet:
 
61
-                        print 'Compiling', fullname, '...'
 
62
-                    print err.msg
 
63
-                    success = 0
 
64
-                except IOError, e:
 
65
-                    print "Sorry", e
 
66
-                    success = 0
 
67
-                else:
 
68
-                    if ok == 0:
 
69
-                        success = 0
 
70
+        if not os.path.isdir(fullname):
 
71
+            if not compile_file(fullname, ddir, force, rx, quiet):
 
72
+                success = 0
 
73
         elif maxlevels > 0 and \
 
74
              name != os.curdir and name != os.pardir and \
 
75
              os.path.isdir(fullname) and \
 
76
@@ -84,6 +58,53 @@
 
77
                 success = 0
 
78
     return success
 
79
 
 
80
+def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
 
81
+    """Byte-compile file.
 
82
+    file:      the file to byte-compile
 
83
+    ddir:      if given, purported directory name (this is the
 
84
+               directory name that will show up in error messages)
 
85
+    force:     if 1, force compilation, even if timestamps are up-to-date
 
86
+    quiet:     if 1, be quiet during compilation
 
87
+
 
88
+    """
 
89
+
 
90
+    success = 1
 
91
+    name = os.path.basename(fullname)
 
92
+    if ddir is not None:
 
93
+        dfile = os.path.join(ddir, name)
 
94
+    else:
 
95
+        dfile = None
 
96
+    if rx is not None:
 
97
+        mo = rx.search(fullname)
 
98
+        if mo:
 
99
+            return success
 
100
+    if os.path.isfile(fullname):
 
101
+        head, tail = name[:-3], name[-3:]
 
102
+        if tail == '.py':
 
103
+            cfile = fullname + (__debug__ and 'c' or 'o')
 
104
+            ftime = os.stat(fullname).st_mtime
 
105
+            try: ctime = os.stat(cfile).st_mtime
 
106
+            except os.error: ctime = 0
 
107
+            if (ctime > ftime) and not force: return success
 
108
+            if not quiet:
 
109
+                print 'Compiling', fullname, '...'
 
110
+            try:
 
111
+                ok = py_compile.compile(fullname, None, dfile, True)
 
112
+            except KeyboardInterrupt:
 
113
+                raise KeyboardInterrupt
 
114
+            except py_compile.PyCompileError,err:
 
115
+                if quiet:
 
116
+                    print 'Compiling', fullname, '...'
 
117
+                print err.msg
 
118
+                success = 0
 
119
+            except IOError, e:
 
120
+                print "Sorry", e
 
121
+                success = 0
 
122
+            else:
 
123
+                if ok == 0:
 
124
+                    success = 0
 
125
+    return success
 
126
+
 
127
 def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
 
128
     """Byte-compile all module on sys.path.
 
129
 
 
130
@@ -104,15 +125,34 @@
 
131
                                               force, quiet=quiet)
 
132
     return success
 
133
 
 
134
+def expand_args(args, flist):
 
135
+    """read names in flist and append to args"""
 
136
+    expanded = args[:]
 
137
+    if flist:
 
138
+        try:
 
139
+            if flist == '-':
 
140
+                fd = sys.stdin
 
141
+            else:
 
142
+                fd = open(flist)
 
143
+            while 1:
 
144
+                line = fd.readline()
 
145
+                if not line:
 
146
+                    break
 
147
+                expanded.append(line[:-1])
 
148
+        except IOError:
 
149
+            print "Error reading file list %s" % flist
 
150
+            raise
 
151
+    return expanded
 
152
+
 
153
 def main():
 
154
     """Script main program."""
 
155
     import getopt
 
156
     try:
 
157
-        opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
 
158
+        opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:i:')
 
159
     except getopt.error, msg:
 
160
         print msg
 
161
         print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
 
162
-              "[-x regexp] [directory ...]"
 
163
+              "[-x regexp] [-i list] [directory|file ...]"
 
164
         print "-l: don't recurse down"
 
165
         print "-f: force rebuild even if timestamps are up-to-date"
 
166
         print "-q: quiet operation"
 
167
@@ -120,12 +160,14 @@
29
168
         print "   if no directory arguments, -l sys.path is assumed"
30
169
         print "-x regexp: skip files matching the regular expression regexp"
31
170
         print "   the regexp is searched for in the full path of the file"
40
179
     for o, a in opts:
41
180
         if o == '-l': maxlevels = 0
42
181
         if o == '-d': ddir = a
 
182
@@ -134,17 +176,28 @@
 
183
         if o == '-x':
 
184
             import re
 
185
             rx = re.compile(a)
 
186
+        if o == '-i': flist = a
 
187
     if ddir:
 
188
-        if len(args) != 1:
 
189
+        if len(args) != 1 and not os.path.isdir(args[0]):
 
190
             print "-d destdir require exactly one directory argument"
 
191
             sys.exit(2)
 
192
     success = 1
 
193
     try:
 
194
-        if args:
 
195
-            for dir in args:
 
196
-                if not compile_dir(dir, maxlevels, ddir,
 
197
-                                   force, rx, quiet):
 
198
-                    success = 0
 
199
+        if args or flist:
 
200
+            try:
 
201
+                if flist:
 
202
+                    args = expand_args(args, flist)
 
203
+            except IOError:
 
204
+                success = 0
 
205
+            if success:
 
206
+                for arg in args:
 
207
+                    if os.path.isdir(arg):
 
208
+                        if not compile_dir(arg, maxlevels, ddir,
 
209
+                                           force, rx, quiet):
 
210
+                            success = 0
 
211
+                    else:
 
212
+                        if not compile_file(arg, ddir, force, rx, quiet):
 
213
+                            success = 0
 
214
         else:
 
215
             success = compile_path()
 
216
     except KeyboardInterrupt: