Ticket #1389: 1389-include-source-frame-2.darcs.patch

File 1389-include-source-frame-2.darcs.patch, 13.9 KB (added by zooko, at 2011-04-10T15:00:57Z)
Line 
13 patches for repository /Users/zooko/playground/tahoe-lafs/pristine:
2
3Fri Apr  8 18:44:33 MDT 2011  david-sarah@jacaranda.org
4  * allmydata/__init__.py: preserve the message of ImportErrors in the package versions string. fixes #1389
5
6Sun Apr 10 06:01:30 MDT 2011  zooko@zooko.com
7  * tests: add test for including ImportError message in the summary of dependencies
8  refs. #1389
9
10Sun Apr 10 08:59:55 MDT 2011  zooko@zooko.com
11  * packaging: show the file, line number, function, and line of code that raised ImportError
12  ref #1389
13
14New patches:
15
16[allmydata/__init__.py: preserve the message of ImportErrors in the package versions string. fixes #1389
17david-sarah@jacaranda.org**20110409004433
18 Ignore-this: caff24ad49573d66bc61d0a397b51afe
19] {
20hunk ./src/allmydata/__init__.py 189
21             try:
22                 __import__(modulename)
23                 module = sys.modules[modulename]
24-            except ImportError:
25-                packages.append( (pkgname, (None, None, modulename)) )
26+            except ImportError, e:
27+                packages.append( (pkgname, (None, None, "%s because of: %s" % (modulename, str(e)))) )
28             else:
29                 if 'sqlite' in pkgname:
30                     packages.append( (pkgname, (get_version(module, 'version'), package_dir(module.__file__),
31hunk ./src/allmydata/__init__.py 221
32         return
33     (actual, location, comment) = vers_and_locs[name]
34     if actual is None:
35-        # comment is the module name
36-        raise ImportError("could not import %r for requirement %r" % (comment, req))
37+        # comment is the module name and message of the original ImportError
38+        raise ImportError("for requirement %r, could not import %s" % (req, comment))
39     if actual == 'unknown':
40         return
41     actualver = normalized_version(actual, what="actual version %r of %s from %r" % (actual, name, location))
42}
43[tests: add test for including ImportError message in the summary of dependencies
44zooko@zooko.com**20110410120130
45 Ignore-this: 581b37aaba6ee00fea8d0beea45d556c
46 refs. #1389
47] {
48addfile ./src/allmydata/test/test_package_initialization.py
49hunk ./src/allmydata/test/test_package_initialization.py 1
50+
51+from twisted.trial import unittest
52+
53+import allmydata
54+
55+import sys
56+
57+class T(unittest.TestCase):
58+    def test_report_import_error(self):
59+        try:
60+            real_import_func = __builtins__['__import__']
61+
62+            def raiseIE(name, *args):
63+                if name == "foolscap":
64+                    raise ImportError("wheeeyo foolscap cant be imported")
65+                else:
66+                    return real_import_func(name, *args)
67+
68+            __builtins__['__import__'] = raiseIE
69+            vers_and_locs =  allmydata.get_package_versions_and_locations()
70+            for (pkgname, stuff) in vers_and_locs:
71+                if pkgname == 'foolscap':
72+                    self.failUnless('wheeeyo' in stuff[2], stuff)
73+        finally:
74+            __builtins__['__import__'] = real_import_func
75}
76[packaging: show the file, line number, function, and line of code that raised ImportError
77zooko@zooko.com**20110410145955
78 Ignore-this: 82e0c1261a5b03c136241660a52b9a0b
79 ref #1389
80] {
81hunk ./src/allmydata/__init__.py 35
82 # http://allmydata.org/trac/tahoe/wiki/Versioning
83 __full_version__ = __appname__ + '/' + str(__version__)
84 
85-import os, platform, re, subprocess, sys
86+import os, platform, re, subprocess, sys, traceback
87 _distributor_id_cmdline_re = re.compile("(?:Distributor ID:)\s*(.*)", re.I)
88 _release_cmdline_re = re.compile("(?:Release:)\s*(.*)", re.I)
89 
90hunk ./src/allmydata/__init__.py 140
91     try:
92         return verlib.NormalizedVersion(verlib.suggest_normalized_version(verstr))
93     except (StandardError, verlib.IrrationalVersionError):
94-        cls, value, traceback = sys.exc_info()
95+        cls, value, trace = sys.exc_info()
96         raise PackagingError, ("could not parse %s due to %s: %s"
97hunk ./src/allmydata/__init__.py 142
98-                               % (what or repr(verstr), cls.__name__, value)), traceback
99+                               % (what or repr(verstr), cls.__name__, value)), trace
100 
101 
102 def get_package_versions_and_locations():
103hunk ./src/allmydata/__init__.py 189
104             try:
105                 __import__(modulename)
106                 module = sys.modules[modulename]
107-            except ImportError, e:
108-                packages.append( (pkgname, (None, None, "%s because of: %s" % (modulename, str(e)))) )
109+            except ImportError:
110+                etype, emsg, etrace = sys.exc_info()
111+                tracestr = traceback.extract_tb(etrace)[-1]
112+                packages.append( (pkgname, (None, None, tracestr)) )
113             else:
114                 if 'sqlite' in pkgname:
115                     packages.append( (pkgname, (get_version(module, 'version'), package_dir(module.__file__),
116hunk ./src/allmydata/__init__.py 224
117     (actual, location, comment) = vers_and_locs[name]
118     if actual is None:
119         # comment is the module name and message of the original ImportError
120-        raise ImportError("for requirement %r, could not import %s" % (req, comment))
121+        raise ImportError("for requirement %r: %s" % (req, comment))
122     if actual == 'unknown':
123         return
124     actualver = normalized_version(actual, what="actual version %r of %s from %r" % (actual, name, location))
125hunk ./src/allmydata/test/test_package_initialization.py 6
126 
127 import allmydata
128 
129-import sys
130+import mock
131+
132+real_import_func = __builtins__['__import__']
133 
134 class T(unittest.TestCase):
135hunk ./src/allmydata/test/test_package_initialization.py 11
136-    def test_report_import_error(self):
137-        try:
138-            real_import_func = __builtins__['__import__']
139+    @mock.patch('__builtin__.__import__')
140+    def test_report_import_error(self, mockimport):
141+        def raiseIE_from_this_particular_func(name, *args):
142+            if name == "foolscap":
143+                raise ImportError("wheeeyo foolscap cant be imported")
144+            else:
145+                return real_import_func(name, *args)
146 
147hunk ./src/allmydata/test/test_package_initialization.py 19
148-            def raiseIE(name, *args):
149-                if name == "foolscap":
150-                    raise ImportError("wheeeyo foolscap cant be imported")
151-                else:
152-                    return real_import_func(name, *args)
153+        mockimport.side_effect = raiseIE_from_this_particular_func
154 
155hunk ./src/allmydata/test/test_package_initialization.py 21
156-            __builtins__['__import__'] = raiseIE
157-            vers_and_locs =  allmydata.get_package_versions_and_locations()
158-            for (pkgname, stuff) in vers_and_locs:
159-                if pkgname == 'foolscap':
160-                    self.failUnless('wheeeyo' in stuff[2], stuff)
161-        finally:
162-            __builtins__['__import__'] = real_import_func
163+        vers_and_locs =  allmydata.get_package_versions_and_locations()
164+        for (pkgname, stuff) in vers_and_locs:
165+            if pkgname == 'foolscap':
166+                self.failUnless('wheeeyo' in str(stuff[2]), stuff)
167+                self.failUnless('raiseIE_from_this_particular_func' in stuff[2], stuff)
168}
169
170Context:
171
172[remove unused variable detected by pyflakes
173zooko@zooko.com**20110407172231
174 Ignore-this: 7344652d5e0720af822070d91f03daf9
175]
176[allmydata/__init__.py: Nicer reporting of unparseable version numbers in dependencies. fixes #1388
177david-sarah@jacaranda.org**20110401202750
178 Ignore-this: 9c6bd599259d2405e1caadbb3e0d8c7f
179]
180[update FTP-and-SFTP.rst: the necessary patch is included in Twisted-10.1
181Brian Warner <warner@lothar.com>**20110325232511
182 Ignore-this: d5307faa6900f143193bfbe14e0f01a
183]
184[control.py: remove all uses of s.get_serverid()
185warner@lothar.com**20110227011203
186 Ignore-this: f80a787953bd7fa3d40e828bde00e855
187]
188[web: remove some uses of s.get_serverid(), not all
189warner@lothar.com**20110227011159
190 Ignore-this: a9347d9cf6436537a47edc6efde9f8be
191]
192[immutable/downloader/fetcher.py: remove all get_serverid() calls
193warner@lothar.com**20110227011156
194 Ignore-this: fb5ef018ade1749348b546ec24f7f09a
195]
196[immutable/downloader/fetcher.py: fix diversity bug in server-response handling
197warner@lothar.com**20110227011153
198 Ignore-this: bcd62232c9159371ae8a16ff63d22c1b
199 
200 When blocks terminate (either COMPLETE or CORRUPT/DEAD/BADSEGNUM), the
201 _shares_from_server dict was being popped incorrectly (using shnum as the
202 index instead of serverid). I'm still thinking through the consequences of
203 this bug. It was probably benign and really hard to detect. I think it would
204 cause us to incorrectly believe that we're pulling too many shares from a
205 server, and thus prefer a different server rather than asking for a second
206 share from the first server. The diversity code is intended to spread out the
207 number of shares simultaneously being requested from each server, but with
208 this bug, it might be spreading out the total number of shares requested at
209 all, not just simultaneously. (note that SegmentFetcher is scoped to a single
210 segment, so the effect doesn't last very long).
211]
212[immutable/downloader/share.py: reduce get_serverid(), one left, update ext deps
213warner@lothar.com**20110227011150
214 Ignore-this: d8d56dd8e7b280792b40105e13664554
215 
216 test_download.py: create+check MyShare instances better, make sure they share
217 Server objects, now that finder.py cares
218]
219[immutable/downloader/finder.py: reduce use of get_serverid(), one left
220warner@lothar.com**20110227011146
221 Ignore-this: 5785be173b491ae8a78faf5142892020
222]
223[immutable/offloaded.py: reduce use of get_serverid() a bit more
224warner@lothar.com**20110227011142
225 Ignore-this: b48acc1b2ae1b311da7f3ba4ffba38f
226]
227[immutable/upload.py: reduce use of get_serverid()
228warner@lothar.com**20110227011138
229 Ignore-this: ffdd7ff32bca890782119a6e9f1495f6
230]
231[immutable/checker.py: remove some uses of s.get_serverid(), not all
232warner@lothar.com**20110227011134
233 Ignore-this: e480a37efa9e94e8016d826c492f626e
234]
235[add remaining get_* methods to storage_client.Server, NoNetworkServer, and
236warner@lothar.com**20110227011132
237 Ignore-this: 6078279ddf42b179996a4b53bee8c421
238 MockIServer stubs
239]
240[upload.py: rearrange _make_trackers a bit, no behavior changes
241warner@lothar.com**20110227011128
242 Ignore-this: 296d4819e2af452b107177aef6ebb40f
243]
244[happinessutil.py: finally rename merge_peers to merge_servers
245warner@lothar.com**20110227011124
246 Ignore-this: c8cd381fea1dd888899cb71e4f86de6e
247]
248[test_upload.py: factor out FakeServerTracker
249warner@lothar.com**20110227011120
250 Ignore-this: 6c182cba90e908221099472cc159325b
251]
252[test_upload.py: server-vs-tracker cleanup
253warner@lothar.com**20110227011115
254 Ignore-this: 2915133be1a3ba456e8603885437e03
255]
256[happinessutil.py: server-vs-tracker cleanup
257warner@lothar.com**20110227011111
258 Ignore-this: b856c84033562d7d718cae7cb01085a9
259]
260[upload.py: more tracker-vs-server cleanup
261warner@lothar.com**20110227011107
262 Ignore-this: bb75ed2afef55e47c085b35def2de315
263]
264[upload.py: fix var names to avoid confusion between 'trackers' and 'servers'
265warner@lothar.com**20110227011103
266 Ignore-this: 5d5e3415b7d2732d92f42413c25d205d
267]
268[refactor: s/peer/server/ in immutable/upload, happinessutil.py, test_upload
269warner@lothar.com**20110227011100
270 Ignore-this: 7ea858755cbe5896ac212a925840fe68
271 
272 No behavioral changes, just updating variable/method names and log messages.
273 The effects outside these three files should be minimal: some exception
274 messages changed (to say "server" instead of "peer"), and some internal class
275 names were changed. A few things still use "peer" to minimize external
276 changes, like UploadResults.timings["peer_selection"] and
277 happinessutil.merge_peers, which can be changed later.
278]
279[storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers
280warner@lothar.com**20110227011056
281 Ignore-this: efad933e78179d3d5fdcd6d1ef2b19cc
282]
283[test_client.py, upload.py:: remove KiB/MiB/etc constants, and other dead code
284warner@lothar.com**20110227011051
285 Ignore-this: dc83c5794c2afc4f81e592f689c0dc2d
286]
287[test: increase timeout on a network test because Francois's ARM machine hit that timeout
288zooko@zooko.com**20110317165909
289 Ignore-this: 380c345cdcbd196268ca5b65664ac85b
290 I'm skeptical that the test was proceeding correctly but ran out of time. It seems more likely that it had gotten hung. But if we raise the timeout to an even more extravagant number then we can be even more certain that the test was never going to finish.
291]
292[docs/configuration.rst: add a "Frontend Configuration" section
293Brian Warner <warner@lothar.com>**20110222014323
294 Ignore-this: 657018aa501fe4f0efef9851628444ca
295 
296 this points to docs/frontends/*.rst, which were previously underlinked
297]
298[web/filenode.py: avoid calling req.finish() on closed HTTP connections. Closes #1366
299"Brian Warner <warner@lothar.com>"**20110221061544
300 Ignore-this: 799d4de19933f2309b3c0c19a63bb888
301]
302[Add unit tests for cross_check_pkg_resources_versus_import, and a regression test for ref #1355. This requires a little refactoring to make it testable.
303david-sarah@jacaranda.org**20110221015817
304 Ignore-this: 51d181698f8c20d3aca58b057e9c475a
305]
306[allmydata/__init__.py: .name was used in place of the correct .__name__ when printing an exception. Also, robustify string formatting by using %r instead of %s in some places. fixes #1355.
307david-sarah@jacaranda.org**20110221020125
308 Ignore-this: b0744ed58f161bf188e037bad077fc48
309]
310[Refactor StorageFarmBroker handling of servers
311Brian Warner <warner@lothar.com>**20110221015804
312 Ignore-this: 842144ed92f5717699b8f580eab32a51
313 
314 Pass around IServer instance instead of (peerid, rref) tuple. Replace
315 "descriptor" with "server". Other replacements:
316 
317  get_all_servers -> get_connected_servers/get_known_servers
318  get_servers_for_index -> get_servers_for_psi (now returns IServers)
319 
320 This change still needs to be pushed further down: lots of code is now
321 getting the IServer and then distributing (peerid, rref) internally.
322 Instead, it ought to distribute the IServer internally and delay
323 extracting a serverid or rref until the last moment.
324 
325 no_network.py was updated to retain parallelism.
326]
327[TAG allmydata-tahoe-1.8.2
328warner@lothar.com**20110131020101]
329Patch bundle hash:
3301defb3d6084354432cfb9c285aac4fce702727f9