Merge lp:~jelmer/brz/move-errors-urlutils into lp:brz
- move-errors-urlutils
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Merged at revision: | 6738 |
Proposed branch: | lp:~jelmer/brz/move-errors-urlutils |
Merge into: | lp:brz |
Diff against target: |
972 lines (+148/-133) 23 files modified
breezy/branch.py (+3/-3) breezy/builtins.py (+1/-1) breezy/bzr/bzrdir.py (+1/-1) breezy/bzr/smart/server.py (+1/-1) breezy/controldir.py (+1/-1) breezy/errors.py (+0/-26) breezy/info.py (+1/-1) breezy/plugins/launchpad/cmds.py (+1/-1) breezy/plugins/launchpad/lp_directory.py (+8/-5) breezy/plugins/launchpad/lp_registration.py (+10/-5) breezy/plugins/launchpad/test_lp_directory.py (+8/-8) breezy/plugins/launchpad/test_lp_service.py (+6/-2) breezy/tests/per_branch/test_parent.py (+1/-1) breezy/tests/per_transport.py (+1/-2) breezy/tests/test_errors.py (+1/-1) breezy/tests/test_http.py (+4/-3) breezy/tests/test_smart.py (+1/-1) breezy/tests/test_transport.py (+4/-4) breezy/tests/test_urlutils.py (+40/-37) breezy/transport/__init__.py (+3/-3) breezy/transport/gio_transport.py (+2/-2) breezy/transport/http/_urllib2_wrappers.py (+3/-3) breezy/urlutils.py (+47/-21) |
To merge this branch: | bzr merge lp:~jelmer/brz/move-errors-urlutils |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email: mp+327487@code.launchpad.net |
Commit message
Move urlutils errors from breezy.errors to breezy.urlutils.
Description of the change
Move urlutils errors from breezy.errors to breezy.urlutils.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'breezy/branch.py' |
2 | --- breezy/branch.py 2017-06-11 18:41:26 +0000 |
3 | +++ breezy/branch.py 2017-07-15 15:47:32 +0000 |
4 | @@ -800,7 +800,7 @@ |
5 | try: |
6 | url = url.encode('ascii') |
7 | except UnicodeEncodeError: |
8 | - raise errors.InvalidURL(url, |
9 | + raise urlutils.InvalidURL(url, |
10 | "Urls must be 7-bit ascii, " |
11 | "use breezy.urlutils.escape") |
12 | url = urlutils.relative_url(self.base, url) |
13 | @@ -1112,7 +1112,7 @@ |
14 | parent = urlutils.local_path_to_url(parent.decode('utf8')) |
15 | try: |
16 | return urlutils.join(self.base[:-1], parent) |
17 | - except errors.InvalidURLJoin as e: |
18 | + except urlutils.InvalidURLJoin as e: |
19 | raise errors.InaccessibleParent(parent, self.user_url) |
20 | |
21 | def _get_parent_location(self): |
22 | @@ -2259,7 +2259,7 @@ |
23 | try: |
24 | relpath = self.source.user_transport.relpath(normalized) |
25 | source_is_master = (relpath == '') |
26 | - except (errors.PathNotChild, errors.InvalidURL): |
27 | + except (errors.PathNotChild, urlutils.InvalidURL): |
28 | source_is_master = False |
29 | if not local and bound_location and not source_is_master: |
30 | # not pulling from master, so we need to update master. |
31 | |
32 | === modified file 'breezy/builtins.py' |
33 | --- breezy/builtins.py 2017-07-12 21:40:01 +0000 |
34 | +++ breezy/builtins.py 2017-07-15 15:47:32 +0000 |
35 | @@ -2144,7 +2144,7 @@ |
36 | url = repository.controldir.root_transport.external_url() |
37 | try: |
38 | url = urlutils.local_path_from_url(url) |
39 | - except errors.InvalidURL: |
40 | + except urlutils.InvalidURL: |
41 | pass |
42 | self.outf.write(gettext("Using shared repository: %s\n") % url) |
43 | |
44 | |
45 | === modified file 'breezy/bzr/bzrdir.py' |
46 | --- breezy/bzr/bzrdir.py 2017-06-14 22:34:05 +0000 |
47 | +++ breezy/bzr/bzrdir.py 2017-07-15 15:47:32 +0000 |
48 | @@ -1843,7 +1843,7 @@ |
49 | stack_on = urlutils.rebase_url(self._stack_on, |
50 | self._stack_on_pwd, |
51 | branch.user_url) |
52 | - except errors.InvalidRebaseURLs: |
53 | + except urlutils.InvalidRebaseURLs: |
54 | stack_on = self._get_full_stack_on() |
55 | try: |
56 | branch.set_stacked_on_url(stack_on) |
57 | |
58 | === modified file 'breezy/bzr/smart/server.py' |
59 | --- breezy/bzr/smart/server.py 2017-06-11 20:15:04 +0000 |
60 | +++ breezy/bzr/smart/server.py 2017-07-15 15:47:32 +0000 |
61 | @@ -372,7 +372,7 @@ |
62 | base_url = base_url[len('readonly+'):] |
63 | try: |
64 | return urlutils.local_path_from_url(base_url) |
65 | - except errors.InvalidURL: |
66 | + except urlutils.InvalidURL: |
67 | return None |
68 | |
69 | |
70 | |
71 | === modified file 'breezy/controldir.py' |
72 | --- breezy/controldir.py 2017-06-13 00:24:42 +0000 |
73 | +++ breezy/controldir.py 2017-07-15 15:47:32 +0000 |
74 | @@ -760,7 +760,7 @@ |
75 | pass |
76 | try: |
77 | new_t = a_transport.clone('..') |
78 | - except errors.InvalidURLJoin: |
79 | + except urlutils.InvalidURLJoin: |
80 | # reached the root, whatever that may be |
81 | raise errors.NotBranchError(path=url) |
82 | if new_t.base == a_transport.base: |
83 | |
84 | === modified file 'breezy/errors.py' |
85 | --- breezy/errors.py 2017-07-12 21:40:01 +0000 |
86 | +++ breezy/errors.py 2017-07-15 15:47:32 +0000 |
87 | @@ -511,32 +511,6 @@ |
88 | _fmt = 'Permission denied: "%(path)s"%(extra)s' |
89 | |
90 | |
91 | -class InvalidURL(PathError): |
92 | - |
93 | - _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s' |
94 | - |
95 | - |
96 | -class InvalidURLJoin(PathError): |
97 | - |
98 | - _fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r" |
99 | - |
100 | - def __init__(self, reason, base, join_args): |
101 | - self.reason = reason |
102 | - self.base = base |
103 | - self.join_args = join_args |
104 | - PathError.__init__(self, base, reason) |
105 | - |
106 | - |
107 | -class InvalidRebaseURLs(PathError): |
108 | - |
109 | - _fmt = "URLs differ by more than path: %(from_)r and %(to)r" |
110 | - |
111 | - def __init__(self, from_, to): |
112 | - self.from_ = from_ |
113 | - self.to = to |
114 | - PathError.__init__(self, from_, 'URLs differ by more than path.') |
115 | - |
116 | - |
117 | class UnavailableRepresentation(InternalBzrError): |
118 | |
119 | _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which " |
120 | |
121 | === modified file 'breezy/info.py' |
122 | --- breezy/info.py 2017-06-10 16:40:42 +0000 |
123 | +++ breezy/info.py 2017-07-15 15:47:32 +0000 |
124 | @@ -60,7 +60,7 @@ |
125 | return |
126 | try: |
127 | path = urlutils.local_path_from_url(url) |
128 | - except errors.InvalidURL: |
129 | + except urlutils.InvalidURL: |
130 | self.locs.append((label, url)) |
131 | else: |
132 | self.add_path(label, path) |
133 | |
134 | === modified file 'breezy/plugins/launchpad/cmds.py' |
135 | --- breezy/plugins/launchpad/cmds.py 2017-06-02 01:01:21 +0000 |
136 | +++ breezy/plugins/launchpad/cmds.py 2017-07-15 15:47:32 +0000 |
137 | @@ -28,7 +28,6 @@ |
138 | ) |
139 | from ...errors import ( |
140 | BzrCommandError, |
141 | - InvalidURL, |
142 | NotBranchError, |
143 | ) |
144 | from ...i18n import gettext |
145 | @@ -65,6 +64,7 @@ |
146 | |
147 | def _get_web_url(self, service, location): |
148 | from .lp_registration import ( |
149 | + InvalidURL, |
150 | NotLaunchpadBranch) |
151 | for branch_url in self._possible_locations(location): |
152 | try: |
153 | |
154 | === modified file 'breezy/plugins/launchpad/lp_directory.py' |
155 | --- breezy/plugins/launchpad/lp_directory.py 2017-05-22 00:56:52 +0000 |
156 | +++ breezy/plugins/launchpad/lp_directory.py 2017-07-15 15:47:32 +0000 |
157 | @@ -30,7 +30,10 @@ |
158 | from ...i18n import gettext |
159 | |
160 | from .lp_registration import ( |
161 | - LaunchpadService, ResolveLaunchpadPathRequest) |
162 | + InvalidURL, |
163 | + LaunchpadService, |
164 | + ResolveLaunchpadPathRequest, |
165 | + ) |
166 | from .account import get_lp_login |
167 | |
168 | |
169 | @@ -99,7 +102,7 @@ |
170 | try: |
171 | result = resolve.submit(service) |
172 | except xmlrpclib.Fault as fault: |
173 | - raise errors.InvalidURL( |
174 | + raise InvalidURL( |
175 | path=url, extra=fault.faultString) |
176 | return result |
177 | |
178 | @@ -132,7 +135,7 @@ |
179 | else: |
180 | # There are either 0 or > 2 path parts, neither of which is |
181 | # supported for these schemes. |
182 | - raise errors.InvalidURL('Bad path: %s' % url) |
183 | + raise InvalidURL('Bad path: %s' % url) |
184 | # Expand any series shortcuts, but keep unknown series. |
185 | series = distro_series.get(series, series) |
186 | # Hack the url and let the following do the final resolution. |
187 | @@ -146,7 +149,7 @@ |
188 | def _expand_user(self, path, url, lp_login): |
189 | if path.startswith('~/'): |
190 | if lp_login is None: |
191 | - raise errors.InvalidURL(path=url, |
192 | + raise InvalidURL(path=url, |
193 | extra='Cannot resolve "~" to your username.' |
194 | ' See "bzr help launchpad-login"') |
195 | path = '~' + lp_login + path[1:] |
196 | @@ -199,7 +202,7 @@ |
197 | else: |
198 | break |
199 | else: |
200 | - raise errors.InvalidURL(path=url, extra='no supported schemes') |
201 | + raise InvalidURL(path=url, extra='no supported schemes') |
202 | return url |
203 | |
204 | |
205 | |
206 | === modified file 'breezy/plugins/launchpad/lp_registration.py' |
207 | --- breezy/plugins/launchpad/lp_registration.py 2017-06-05 20:48:31 +0000 |
208 | +++ breezy/plugins/launchpad/lp_registration.py 2017-07-15 15:47:32 +0000 |
209 | @@ -37,6 +37,12 @@ |
210 | export BRZ_LP_XMLRPC_URL=http://xmlrpc.staging.launchpad.net/bazaar/ |
211 | ''' |
212 | |
213 | + |
214 | +class InvalidURL(errors.PathError): |
215 | + |
216 | + _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s' |
217 | + |
218 | + |
219 | class InvalidLaunchpadInstance(errors.BzrError): |
220 | |
221 | _fmt = "%(lp_instance)s is not a valid Launchpad instance." |
222 | @@ -142,7 +148,7 @@ |
223 | if lp_instance == '': |
224 | lp_instance = None |
225 | elif lp_instance not in cls.LAUNCHPAD_INSTANCE: |
226 | - raise errors.InvalidURL(path=url) |
227 | + raise InvalidURL(url) |
228 | return cls(lp_instance=lp_instance, **kwargs) |
229 | |
230 | def get_proxy(self): |
231 | @@ -191,7 +197,7 @@ |
232 | try: |
233 | result = resolve.submit(self) |
234 | except xmlrpclib.Fault as fault: |
235 | - raise errors.InvalidURL(branch_url, str(fault)) |
236 | + raise InvalidURL(branch_url, str(fault)) |
237 | branch_url = result['urls'][0] |
238 | path = urlsplit(branch_url)[2] |
239 | else: |
240 | @@ -205,7 +211,7 @@ |
241 | def get_web_url_from_branch_url(self, branch_url, _request_factory=None): |
242 | """Get the Launchpad web URL for the given branch URL. |
243 | |
244 | - :raise errors.InvalidURL: if 'branch_url' cannot be identified as a |
245 | + :raise InvalidURL: if 'branch_url' cannot be identified as a |
246 | Launchpad branch URL. |
247 | :return: The URL of the branch on Launchpad. |
248 | """ |
249 | @@ -245,8 +251,7 @@ |
250 | |
251 | def __init__(self, path): |
252 | if not path: |
253 | - raise errors.InvalidURL(path=path, |
254 | - extra="You must specify a project.") |
255 | + raise InvalidURL(url=path, extra="You must specify a project.") |
256 | self.path = path |
257 | |
258 | def _request_params(self): |
259 | |
260 | === modified file 'breezy/plugins/launchpad/test_lp_directory.py' |
261 | --- breezy/plugins/launchpad/test_lp_directory.py 2017-05-23 14:08:03 +0000 |
262 | +++ breezy/plugins/launchpad/test_lp_directory.py 2017-07-15 15:47:32 +0000 |
263 | @@ -129,7 +129,7 @@ |
264 | :seealso: http://pad.lv/843900 |
265 | """ |
266 | # This ought to be natty-updates. |
267 | - self.assertRaises(errors.InvalidURL, |
268 | + self.assertRaises(lp_registration.InvalidURL, |
269 | self.assertResolve, |
270 | '', |
271 | 'ubuntu:natty/updates/smartpm') |
272 | @@ -287,7 +287,7 @@ |
273 | self, 'apt', dict(urls=[ |
274 | 'bad-scheme://bazaar.launchpad.net/~apt/apt/devel'])) |
275 | directory = LaunchpadDirectory() |
276 | - self.assertRaises(errors.InvalidURL, |
277 | + self.assertRaises(lp_registration.InvalidURL, |
278 | directory._resolve, 'lp:///apt', factory) |
279 | |
280 | def test_directory_fault(self): |
281 | @@ -297,7 +297,7 @@ |
282 | raise xmlrpclib.Fault(42, 'something went wrong') |
283 | factory.submit = submit |
284 | directory = LaunchpadDirectory() |
285 | - self.assertRaises(errors.InvalidURL, |
286 | + self.assertRaises(lp_registration.InvalidURL, |
287 | directory._resolve, 'lp:///apt', factory) |
288 | |
289 | def test_skip_bzr_ssh_launchpad_net_when_anonymous(self): |
290 | @@ -350,7 +350,7 @@ |
291 | # TODO: check we get an error if the url is unreasonable |
292 | def test_error_for_bad_url(self): |
293 | directory = LaunchpadDirectory() |
294 | - self.assertRaises(errors.InvalidURL, |
295 | + self.assertRaises(lp_registration.InvalidURL, |
296 | directory._resolve, 'lp://ratotehunoahu') |
297 | |
298 | def test_resolve_tilde_to_user(self): |
299 | @@ -373,7 +373,7 @@ |
300 | 'bzr+ssh://bazaar.launchpad.net/~username/apt/test'])) |
301 | self.assertIs(None, get_lp_login()) |
302 | directory = LaunchpadDirectory() |
303 | - self.assertRaises(errors.InvalidURL, |
304 | + self.assertRaises(lp_registration.InvalidURL, |
305 | directory._resolve, 'lp:~/apt/test', factory) |
306 | |
307 | |
308 | @@ -545,15 +545,15 @@ |
309 | # Bogus distro. |
310 | |
311 | def test_bogus_distro(self): |
312 | - self.assertRaises(errors.InvalidURL, |
313 | + self.assertRaises(lp_registration.InvalidURL, |
314 | self.directory._resolve, 'gentoo:foo') |
315 | |
316 | def test_trick_bogus_distro_u(self): |
317 | - self.assertRaises(errors.InvalidURL, |
318 | + self.assertRaises(lp_registration.InvalidURL, |
319 | self.directory._resolve, 'utube:foo') |
320 | |
321 | def test_trick_bogus_distro_d(self): |
322 | - self.assertRaises(errors.InvalidURL, |
323 | + self.assertRaises(lp_registration.InvalidURL, |
324 | self.directory._resolve, 'debuntu:foo') |
325 | |
326 | def test_missing_ubuntu_distroseries_without_project(self): |
327 | |
328 | === modified file 'breezy/plugins/launchpad/test_lp_service.py' |
329 | --- breezy/plugins/launchpad/test_lp_service.py 2017-05-22 00:56:52 +0000 |
330 | +++ breezy/plugins/launchpad/test_lp_service.py 2017-07-15 15:47:32 +0000 |
331 | @@ -21,7 +21,11 @@ |
332 | |
333 | from ... import errors |
334 | from .lp_registration import ( |
335 | - InvalidLaunchpadInstance, LaunchpadService, NotLaunchpadBranch) |
336 | + InvalidURL, |
337 | + InvalidLaunchpadInstance, |
338 | + LaunchpadService, |
339 | + NotLaunchpadBranch, |
340 | + ) |
341 | from .test_lp_directory import FakeResolveFactory |
342 | from ...tests import TestCase |
343 | |
344 | @@ -156,7 +160,7 @@ |
345 | raise xmlrpclib.Fault(42, 'something went wrong') |
346 | factory.submit = submit |
347 | self.assertRaises( |
348 | - errors.InvalidURL, service.get_web_url_from_branch_url, 'lp:foo', |
349 | + InvalidURL, service.get_web_url_from_branch_url, 'lp:foo', |
350 | factory) |
351 | |
352 | def test_staging_url(self): |
353 | |
354 | === modified file 'breezy/tests/per_branch/test_parent.py' |
355 | --- breezy/tests/per_branch/test_parent.py 2017-06-10 00:17:06 +0000 |
356 | +++ breezy/tests/per_branch/test_parent.py 2017-07-15 15:47:32 +0000 |
357 | @@ -59,7 +59,7 @@ |
358 | self.assertEqual(path, b.get_parent()) |
359 | |
360 | |
361 | - self.assertRaises(breezy.errors.InvalidURL, b.set_parent, u'\xb5') |
362 | + self.assertRaises(urlutils.InvalidURL, b.set_parent, u'\xb5') |
363 | b.set_parent(urlutils.escape(u'\xb5')) |
364 | self.assertEqual('%C2%B5', b._get_parent_location()) |
365 | |
366 | |
367 | === modified file 'breezy/tests/per_transport.py' |
368 | --- breezy/tests/per_transport.py 2017-06-11 20:15:04 +0000 |
369 | +++ breezy/tests/per_transport.py 2017-07-15 15:47:32 +0000 |
370 | @@ -34,7 +34,6 @@ |
371 | ) |
372 | from ..errors import (ConnectionError, |
373 | FileExists, |
374 | - InvalidURL, |
375 | NoSuchFile, |
376 | PathError, |
377 | TransportNotPossible, |
378 | @@ -1554,7 +1553,7 @@ |
379 | |
380 | # A plain unicode string is not a valid url |
381 | for fname in files: |
382 | - self.assertRaises(InvalidURL, t.get, fname) |
383 | + self.assertRaises(urlutils.InvalidURL, t.get, fname) |
384 | |
385 | for fname in files: |
386 | fname_utf8 = fname.encode('utf-8') |
387 | |
388 | === modified file 'breezy/tests/test_errors.py' |
389 | --- breezy/tests/test_errors.py 2017-07-12 21:40:01 +0000 |
390 | +++ breezy/tests/test_errors.py 2017-07-15 15:47:32 +0000 |
391 | @@ -497,7 +497,7 @@ |
392 | |
393 | def test_invalid_url_join(self): |
394 | """Test the formatting of InvalidURLJoin.""" |
395 | - e = errors.InvalidURLJoin('Reason', 'base path', ('args',)) |
396 | + e = urlutils.InvalidURLJoin('Reason', 'base path', ('args',)) |
397 | self.assertEqual( |
398 | "Invalid URL join request: Reason: 'base path' + ('args',)", |
399 | str(e)) |
400 | |
401 | === modified file 'breezy/tests/test_http.py' |
402 | --- breezy/tests/test_http.py 2017-06-11 14:07:05 +0000 |
403 | +++ breezy/tests/test_http.py 2017-07-15 15:47:32 +0000 |
404 | @@ -41,6 +41,7 @@ |
405 | trace, |
406 | transport, |
407 | ui, |
408 | + urlutils, |
409 | ) |
410 | from ..bzr import ( |
411 | remote as _mod_remote, |
412 | @@ -381,7 +382,7 @@ |
413 | def test_invalid_http_urls(self): |
414 | """Trap invalid construction of urls""" |
415 | self._transport('http://example.com/bzr/bzr.dev/') |
416 | - self.assertRaises(errors.InvalidURL, |
417 | + self.assertRaises(urlutils.InvalidURL, |
418 | self._transport, |
419 | 'http://http://example.com/bzr/bzr.dev/') |
420 | |
421 | @@ -1144,7 +1145,7 @@ |
422 | def test_invalid_proxy(self): |
423 | """A proxy env variable without scheme""" |
424 | self.overrideEnv('http_proxy', 'host:1234') |
425 | - self.assertRaises(errors.InvalidURL, self._proxied_request) |
426 | + self.assertRaises(urlutils.InvalidURL, self._proxied_request) |
427 | |
428 | def test_evaluate_proxy_bypass_true(self): |
429 | """The host is not proxied""" |
430 | @@ -1242,7 +1243,7 @@ |
431 | |
432 | def test_http_proxy_without_scheme(self): |
433 | self.overrideEnv('http_proxy', self.server_host_port) |
434 | - self.assertRaises(errors.InvalidURL, self.assertProxied) |
435 | + self.assertRaises(urlutils.InvalidURL, self.assertProxied) |
436 | |
437 | |
438 | class TestRanges(http_utils.TestCaseWithWebserver): |
439 | |
440 | === modified file 'breezy/tests/test_smart.py' |
441 | --- breezy/tests/test_smart.py 2017-06-11 20:15:04 +0000 |
442 | +++ breezy/tests/test_smart.py 2017-07-15 15:47:32 +0000 |
443 | @@ -167,7 +167,7 @@ |
444 | request = smart_req.SmartServerRequest(transport, 'foo/') |
445 | self.assertEqual('./', request.translate_client_path('foo/')) |
446 | self.assertRaises( |
447 | - errors.InvalidURLJoin, request.translate_client_path, 'foo/..') |
448 | + urlutils.InvalidURLJoin, request.translate_client_path, 'foo/..') |
449 | self.assertRaises( |
450 | errors.PathNotChild, request.translate_client_path, '/') |
451 | self.assertRaises( |
452 | |
453 | === modified file 'breezy/tests/test_transport.py' |
454 | --- breezy/tests/test_transport.py 2017-06-04 18:09:30 +0000 |
455 | +++ breezy/tests/test_transport.py 2017-07-15 15:47:32 +0000 |
456 | @@ -411,7 +411,7 @@ |
457 | self.start_server(server) |
458 | t = transport.get_transport_from_url(server.get_url()) |
459 | self.assertRaises( |
460 | - errors.InvalidURLJoin, urlutils.join, t.base, '..') |
461 | + urlutils.InvalidURLJoin, urlutils.join, t.base, '..') |
462 | |
463 | |
464 | class TestChrootServer(tests.TestCase): |
465 | @@ -718,7 +718,7 @@ |
466 | class TestTransportFromUrl(tests.TestCaseInTempDir): |
467 | |
468 | def test_with_path(self): |
469 | - self.assertRaises(errors.InvalidURL, transport.get_transport_from_url, |
470 | + self.assertRaises(urlutils.InvalidURL, transport.get_transport_from_url, |
471 | self.test_dir) |
472 | |
473 | def test_with_url(self): |
474 | @@ -862,7 +862,7 @@ |
475 | self.assertEqual(t.base, 'http://ro%62ey@ex%41mple.com:2222/path/') |
476 | |
477 | def test_parse_invalid_url(self): |
478 | - self.assertRaises(errors.InvalidURL, |
479 | + self.assertRaises(urlutils.InvalidURL, |
480 | transport.ConnectedTransport, |
481 | 'sftp://lily.org:~janneke/public/bzr/gub') |
482 | |
483 | @@ -1129,7 +1129,7 @@ |
484 | self.assertEqual("http://bar", location_to_url("bar:")) |
485 | |
486 | def test_unicode_url(self): |
487 | - self.assertRaises(errors.InvalidURL, location_to_url, |
488 | + self.assertRaises(urlutils.InvalidURL, location_to_url, |
489 | "http://fo/\xc3\xaf".decode("utf-8")) |
490 | |
491 | def test_unicode_path(self): |
492 | |
493 | === modified file 'breezy/tests/test_urlutils.py' |
494 | --- breezy/tests/test_urlutils.py 2017-06-05 23:54:45 +0000 |
495 | +++ breezy/tests/test_urlutils.py 2017-07-15 15:47:32 +0000 |
496 | @@ -21,9 +21,6 @@ |
497 | |
498 | from .. import osutils, urlutils, win32utils |
499 | from ..errors import ( |
500 | - InvalidURL, |
501 | - InvalidURLJoin, |
502 | - InvalidRebaseURLs, |
503 | PathNotChild, |
504 | ) |
505 | from . import features, TestCaseInTempDir, TestCase, TestSkipped |
506 | @@ -36,7 +33,8 @@ |
507 | # Test breezy.urlutils.split() |
508 | basename = urlutils.basename |
509 | if sys.platform == 'win32': |
510 | - self.assertRaises(InvalidURL, basename, 'file:///path/to/foo') |
511 | + self.assertRaises(urlutils.InvalidURL, basename, |
512 | + 'file:///path/to/foo') |
513 | self.assertEqual('foo', basename('file:///C|/foo')) |
514 | self.assertEqual('foo', basename('file:///C:/foo')) |
515 | self.assertEqual('', basename('file:///C:/')) |
516 | @@ -126,8 +124,9 @@ |
517 | |
518 | # Normalize verifies URLs when they are not unicode |
519 | # (indicating they did not come from the user) |
520 | - self.assertRaises(InvalidURL, normalize_url, 'http://host/\xb5') |
521 | - self.assertRaises(InvalidURL, normalize_url, 'http://host/ ') |
522 | + self.assertRaises(urlutils.InvalidURL, normalize_url, |
523 | + 'http://host/\xb5') |
524 | + self.assertRaises(urlutils.InvalidURL, normalize_url, 'http://host/ ') |
525 | |
526 | def test_url_scheme_re(self): |
527 | # Test paths that may be URLs |
528 | @@ -170,7 +169,8 @@ |
529 | # Test breezy.urlutils.dirname() |
530 | dirname = urlutils.dirname |
531 | if sys.platform == 'win32': |
532 | - self.assertRaises(InvalidURL, dirname, 'file:///path/to/foo') |
533 | + self.assertRaises(urlutils.InvalidURL, dirname, |
534 | + 'file:///path/to/foo') |
535 | self.assertEqual('file:///C|/', dirname('file:///C|/foo')) |
536 | self.assertEqual('file:///C|/', dirname('file:///C|/')) |
537 | else: |
538 | @@ -253,12 +253,12 @@ |
539 | # Invalid joinings |
540 | # Cannot go above root |
541 | # Implicitly at root: |
542 | - self.assertRaises(InvalidURLJoin, urlutils.join, |
543 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.join, |
544 | 'http://foo', '../baz') |
545 | - self.assertRaises(InvalidURLJoin, urlutils.join, |
546 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.join, |
547 | 'http://foo', '/..') |
548 | # Joining from a path explicitly under the root. |
549 | - self.assertRaises(InvalidURLJoin, urlutils.join, |
550 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.join, |
551 | 'http://foo/a', '../../b') |
552 | |
553 | def test_joinpath(self): |
554 | @@ -290,9 +290,12 @@ |
555 | |
556 | # Invalid joinings |
557 | # Cannot go above root |
558 | - self.assertRaises(InvalidURLJoin, urlutils.joinpath, '/', '../baz') |
559 | - self.assertRaises(InvalidURLJoin, urlutils.joinpath, '/', '..') |
560 | - self.assertRaises(InvalidURLJoin, urlutils.joinpath, '/', '/..') |
561 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.joinpath, '/', |
562 | + '../baz') |
563 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.joinpath, '/', |
564 | + '..') |
565 | + self.assertRaises(urlutils.InvalidURLJoin, urlutils.joinpath, '/', |
566 | + '/..') |
567 | |
568 | def test_join_segment_parameters_raw(self): |
569 | join_segment_parameters_raw = urlutils.join_segment_parameters_raw |
570 | @@ -300,7 +303,7 @@ |
571 | join_segment_parameters_raw("/somedir/path")) |
572 | self.assertEqual("/somedir/path,rawdata", |
573 | join_segment_parameters_raw("/somedir/path", "rawdata")) |
574 | - self.assertRaises(InvalidURLJoin, |
575 | + self.assertRaises(urlutils.InvalidURLJoin, |
576 | join_segment_parameters_raw, "/somedir/path", |
577 | "rawdata1,rawdata2,rawdata3") |
578 | self.assertEqual("/somedir/path,bla,bar", |
579 | @@ -317,10 +320,10 @@ |
580 | join_segment_parameters("/somedir/path", {})) |
581 | self.assertEqual("/somedir/path,key1=val1", |
582 | join_segment_parameters("/somedir/path", {"key1": "val1"})) |
583 | - self.assertRaises(InvalidURLJoin, |
584 | + self.assertRaises(urlutils.InvalidURLJoin, |
585 | join_segment_parameters, "/somedir/path", |
586 | {"branch": "brr,brr,brr"}) |
587 | - self.assertRaises(InvalidURLJoin, |
588 | + self.assertRaises(urlutils.InvalidURLJoin, |
589 | join_segment_parameters, "/somedir/path", {"key1=val1": "val2"}) |
590 | self.assertEqual("/somedir/path,key1=val1,key2=val2", |
591 | join_segment_parameters("/somedir/path", { |
592 | @@ -380,9 +383,9 @@ |
593 | self.assertEqual(u'/path/to/r\xe4ksm\xf6rg\xe5s', |
594 | from_url('file://localhost/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s')) |
595 | |
596 | - self.assertRaises(InvalidURL, from_url, '/path/to/foo') |
597 | + self.assertRaises(urlutils.InvalidURL, from_url, '/path/to/foo') |
598 | self.assertRaises( |
599 | - InvalidURL, from_url, |
600 | + urlutils.InvalidURL, from_url, |
601 | 'file://remotehost/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s') |
602 | |
603 | def test_win32_local_path_to_url(self): |
604 | @@ -438,11 +441,11 @@ |
605 | self.assertEqual('C:/path/to/foo', |
606 | from_url('file:///C|/path/to/foo,branch=foo')) |
607 | |
608 | - self.assertRaises(InvalidURL, from_url, 'file:///C:') |
609 | - self.assertRaises(InvalidURL, from_url, 'file:///c') |
610 | - self.assertRaises(InvalidURL, from_url, '/path/to/foo') |
611 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file:///C:') |
612 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file:///c') |
613 | + self.assertRaises(urlutils.InvalidURL, from_url, '/path/to/foo') |
614 | # Not a valid _win32 url, no drive letter |
615 | - self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo') |
616 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file:///path/to/foo') |
617 | |
618 | def test_win32_unc_path_from_url(self): |
619 | from_url = urlutils._win32_local_path_from_url |
620 | @@ -452,29 +455,29 @@ |
621 | # despite IE allows 2, 4, 5 and 6 slashes in URL to another machine |
622 | # we want to use only 2 slashes |
623 | # Firefox understand only 5 slashes in URL, but it's ugly |
624 | - self.assertRaises(InvalidURL, from_url, 'file:////HOST/path') |
625 | - self.assertRaises(InvalidURL, from_url, 'file://///HOST/path') |
626 | - self.assertRaises(InvalidURL, from_url, 'file://////HOST/path') |
627 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file:////HOST/path') |
628 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file://///HOST/path') |
629 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file://////HOST/path') |
630 | # check for file://C:/ instead of file:///C:/ |
631 | - self.assertRaises(InvalidURL, from_url, 'file://C:/path') |
632 | + self.assertRaises(urlutils.InvalidURL, from_url, 'file://C:/path') |
633 | |
634 | def test_win32_extract_drive_letter(self): |
635 | extract = urlutils._win32_extract_drive_letter |
636 | self.assertEqual(('file:///C:', '/foo'), extract('file://', '/C:/foo')) |
637 | self.assertEqual(('file:///d|', '/path'), extract('file://', '/d|/path')) |
638 | - self.assertRaises(InvalidURL, extract, 'file://', '/path') |
639 | + self.assertRaises(urlutils.InvalidURL, extract, 'file://', '/path') |
640 | # Root drives without slash treated as invalid, see bug #841322 |
641 | self.assertEqual(('file:///C:', '/'), extract('file://', '/C:/')) |
642 | - self.assertRaises(InvalidURL, extract, 'file://', '/C:') |
643 | + self.assertRaises(urlutils.InvalidURL, extract, 'file://', '/C:') |
644 | # Invalid without drive separator or following forward slash |
645 | - self.assertRaises(InvalidURL, extract, 'file://', '/C') |
646 | - self.assertRaises(InvalidURL, extract, 'file://', '/C:ool') |
647 | + self.assertRaises(urlutils.InvalidURL, extract, 'file://', '/C') |
648 | + self.assertRaises(urlutils.InvalidURL, extract, 'file://', '/C:ool') |
649 | |
650 | def test_split(self): |
651 | # Test breezy.urlutils.split() |
652 | split = urlutils.split |
653 | if sys.platform == 'win32': |
654 | - self.assertRaises(InvalidURL, split, 'file:///path/to/foo') |
655 | + self.assertRaises(urlutils.InvalidURL, split, 'file:///path/to/foo') |
656 | self.assertEqual(('file:///C|/', 'foo'), split('file:///C|/foo')) |
657 | self.assertEqual(('file:///C:/', ''), split('file:///C:/')) |
658 | else: |
659 | @@ -656,9 +659,9 @@ |
660 | self.assertEqual('%', urlutils.unescape('%25')) |
661 | self.assertEqual(u'\xe5', urlutils.unescape('%C3%A5')) |
662 | |
663 | - self.assertRaises(InvalidURL, urlutils.unescape, u'\xe5') |
664 | - self.assertRaises(InvalidURL, urlutils.unescape, '\xe5') |
665 | - self.assertRaises(InvalidURL, urlutils.unescape, '%E5') |
666 | + self.assertRaises(urlutils.InvalidURL, urlutils.unescape, u'\xe5') |
667 | + self.assertRaises(urlutils.InvalidURL, urlutils.unescape, '\xe5') |
668 | + self.assertRaises(urlutils.InvalidURL, urlutils.unescape, '%E5') |
669 | |
670 | def test_escape_unescape(self): |
671 | self.assertEqual(u'\xe5', urlutils.unescape(urlutils.escape(u'\xe5'))) |
672 | @@ -782,19 +785,19 @@ |
673 | self.assertEqual('/foo', result) |
674 | |
675 | def test_different_ports(self): |
676 | - e = self.assertRaises(InvalidRebaseURLs, urlutils.rebase_url, |
677 | + e = self.assertRaises(urlutils.InvalidRebaseURLs, urlutils.rebase_url, |
678 | 'foo', 'http://bar:80', 'http://bar:81') |
679 | self.assertEqual(str(e), "URLs differ by more than path:" |
680 | " 'http://bar:80' and 'http://bar:81'") |
681 | |
682 | def test_different_hosts(self): |
683 | - e = self.assertRaises(InvalidRebaseURLs, urlutils.rebase_url, |
684 | + e = self.assertRaises(urlutils.InvalidRebaseURLs, urlutils.rebase_url, |
685 | 'foo', 'http://bar', 'http://baz') |
686 | self.assertEqual(str(e), "URLs differ by more than path: 'http://bar'" |
687 | " and 'http://baz'") |
688 | |
689 | def test_different_protocol(self): |
690 | - e = self.assertRaises(InvalidRebaseURLs, urlutils.rebase_url, |
691 | + e = self.assertRaises(urlutils.InvalidRebaseURLs, urlutils.rebase_url, |
692 | 'foo', 'http://bar', 'ftp://bar') |
693 | self.assertEqual(str(e), "URLs differ by more than path: 'http://bar'" |
694 | " and 'ftp://bar'") |
695 | |
696 | === modified file 'breezy/transport/__init__.py' |
697 | --- breezy/transport/__init__.py 2017-06-11 20:15:04 +0000 |
698 | +++ breezy/transport/__init__.py 2017-07-15 15:47:32 +0000 |
699 | @@ -1537,7 +1537,7 @@ |
700 | """ |
701 | try: |
702 | parsed_url = self._split_url(other_base) |
703 | - except errors.InvalidURL: |
704 | + except urlutils.InvalidURL: |
705 | # No hope in trying to reuse an existing transport for an invalid |
706 | # URL |
707 | return None |
708 | @@ -1591,7 +1591,7 @@ |
709 | location = location.encode('ascii') |
710 | except UnicodeError: |
711 | if urlutils.is_url(location): |
712 | - raise errors.InvalidURL(path=location, |
713 | + raise urlutils.InvalidURL(path=location, |
714 | extra='URLs must be properly escaped') |
715 | location = urlutils.local_path_to_url(location) |
716 | if PY3: |
717 | @@ -1647,7 +1647,7 @@ |
718 | possible_transports.append(transport) |
719 | return transport |
720 | if not urlutils.is_url(url): |
721 | - raise errors.InvalidURL(path=url) |
722 | + raise urlutils.InvalidURL(path=url) |
723 | raise errors.UnsupportedProtocol(url, last_err) |
724 | |
725 | |
726 | |
727 | === modified file 'breezy/transport/gio_transport.py' |
728 | --- breezy/transport/gio_transport.py 2017-05-30 19:16:23 +0000 |
729 | +++ breezy/transport/gio_transport.py 2017-07-15 15:47:32 +0000 |
730 | @@ -129,7 +129,7 @@ |
731 | #so a hardcoded list it is then. |
732 | gio_backends = ['dav', 'file', 'ftp', 'obex', 'sftp', 'ssh', 'smb'] |
733 | if scheme not in gio_backends: |
734 | - raise errors.InvalidURL(base, |
735 | + raise urlutils.InvalidURL(base, |
736 | extra="GIO support is only available for " + \ |
737 | ', '.join(gio_backends)) |
738 | |
739 | @@ -145,7 +145,7 @@ |
740 | def _relpath_to_url(self, relpath): |
741 | full_url = urlutils.join(self.url, relpath) |
742 | if isinstance(full_url, unicode): |
743 | - raise errors.InvalidURL(full_url) |
744 | + raise urlutils.InvalidURL(full_url) |
745 | return full_url |
746 | |
747 | def _get_GIO(self, relpath): |
748 | |
749 | === modified file 'breezy/transport/http/_urllib2_wrappers.py' |
750 | --- breezy/transport/http/_urllib2_wrappers.py 2017-06-05 20:48:31 +0000 |
751 | +++ breezy/transport/http/_urllib2_wrappers.py 2017-07-15 15:47:32 +0000 |
752 | @@ -586,7 +586,7 @@ |
753 | if not host: |
754 | # Just a bit of paranoia here, this should have been |
755 | # handled in the higher levels |
756 | - raise errors.InvalidURL(request.get_full_url(), 'no host given.') |
757 | + raise urlutils.InvalidURL(request.get_full_url(), 'no host given.') |
758 | |
759 | # We create a connection (but it will not connect until the first |
760 | # request is made) |
761 | @@ -597,7 +597,7 @@ |
762 | ca_certs=self.ca_certs) |
763 | except httplib.InvalidURL as exception: |
764 | # There is only one occurrence of InvalidURL in httplib |
765 | - raise errors.InvalidURL(request.get_full_url(), |
766 | + raise urlutils.InvalidURL(request.get_full_url(), |
767 | extra='nonnumeric port') |
768 | |
769 | return connection |
770 | @@ -1127,7 +1127,7 @@ |
771 | |
772 | parsed_url = transport.ConnectedTransport._split_url(proxy) |
773 | if not parsed_url.host: |
774 | - raise errors.InvalidURL(proxy, 'No host component') |
775 | + raise urlutils.InvalidURL(proxy, 'No host component') |
776 | |
777 | if request.proxy_auth == {}: |
778 | # No proxy auth parameter are available, we are handling the first |
779 | |
780 | === modified file 'breezy/urlutils.py' |
781 | --- breezy/urlutils.py 2017-06-10 01:57:00 +0000 |
782 | +++ breezy/urlutils.py 2017-07-15 15:47:32 +0000 |
783 | @@ -27,14 +27,14 @@ |
784 | except ImportError: |
785 | from urllib import parse as urlparse |
786 | |
787 | +from . import ( |
788 | + errors, |
789 | + osutils, |
790 | + ) |
791 | + |
792 | from .lazy_import import lazy_import |
793 | lazy_import(globals(), """ |
794 | from posixpath import split as _posix_split |
795 | - |
796 | -from breezy import ( |
797 | - errors, |
798 | - osutils, |
799 | - ) |
800 | """) |
801 | |
802 | from .sixish import ( |
803 | @@ -43,6 +43,32 @@ |
804 | ) |
805 | |
806 | |
807 | +class InvalidURL(errors.PathError): |
808 | + |
809 | + _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s' |
810 | + |
811 | + |
812 | +class InvalidURLJoin(errors.PathError): |
813 | + |
814 | + _fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r" |
815 | + |
816 | + def __init__(self, reason, base, join_args): |
817 | + self.reason = reason |
818 | + self.base = base |
819 | + self.join_args = join_args |
820 | + errors.PathError.__init__(self, base, reason) |
821 | + |
822 | + |
823 | +class InvalidRebaseURLs(errors.PathError): |
824 | + |
825 | + _fmt = "URLs differ by more than path: %(from_)r and %(to)r" |
826 | + |
827 | + def __init__(self, from_, to): |
828 | + self.from_ = from_ |
829 | + self.to = to |
830 | + errors.PathError.__init__(self, from_, 'URLs differ by more than path.') |
831 | + |
832 | + |
833 | def basename(url, exclude_trailing_slash=True): |
834 | """Return the last component of a URL. |
835 | |
836 | @@ -231,7 +257,7 @@ |
837 | continue |
838 | elif chunk == '..': |
839 | if path == ['']: |
840 | - raise errors.InvalidURLJoin('Cannot go above root', |
841 | + raise InvalidURLJoin('Cannot go above root', |
842 | base, args) |
843 | path.pop() |
844 | else: |
845 | @@ -250,7 +276,7 @@ |
846 | if url.startswith(file_localhost_prefix): |
847 | path = url[len(file_localhost_prefix) - 1:] |
848 | elif not url.startswith('file:///'): |
849 | - raise errors.InvalidURL( |
850 | + raise InvalidURL( |
851 | url, 'local urls must start with file:/// or file://localhost/') |
852 | else: |
853 | path = url[len('file://'):] |
854 | @@ -271,7 +297,7 @@ |
855 | def _win32_local_path_from_url(url): |
856 | """Convert a url like file:///C:/path/to/foo into C:/path/to/foo""" |
857 | if not url.startswith('file://'): |
858 | - raise errors.InvalidURL(url, 'local urls must start with file:///, ' |
859 | + raise InvalidURL(url, 'local urls must start with file:///, ' |
860 | 'UNC path urls must start with file://') |
861 | url = split_segment_parameters_raw(url)[0] |
862 | # We strip off all 3 slashes |
863 | @@ -280,7 +306,7 @@ |
864 | if not win32_url.startswith('///'): |
865 | if (win32_url[2] == '/' |
866 | or win32_url[3] in '|:'): |
867 | - raise errors.InvalidURL(url, 'Win32 UNC path urls' |
868 | + raise InvalidURL(url, 'Win32 UNC path urls' |
869 | ' have form file://HOST/path') |
870 | return unescape(win32_url) |
871 | |
872 | @@ -294,7 +320,7 @@ |
873 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') |
874 | or win32_url[4] not in '|:' |
875 | or win32_url[5] != '/'): |
876 | - raise errors.InvalidURL(url, 'Win32 file urls start with' |
877 | + raise InvalidURL(url, 'Win32 file urls start with' |
878 | ' file:///x:/, where x is a valid drive letter') |
879 | return win32_url[3].upper() + u':' + unescape(win32_url[5:]) |
880 | |
881 | @@ -377,7 +403,7 @@ |
882 | if not isinstance(url, text_type): |
883 | for c in url: |
884 | if c not in _url_safe_characters: |
885 | - raise errors.InvalidURL(url, 'URLs can only contain specific' |
886 | + raise InvalidURL(url, 'URLs can only contain specific' |
887 | ' safe characters (not %r)' % c) |
888 | path = _url_hex_escapes_re.sub(_unescape_safe_chars, path) |
889 | return str(prefix + ''.join(path)) |
890 | @@ -452,7 +478,7 @@ |
891 | # Strip off the drive letter |
892 | # path is currently /C:/foo |
893 | if len(path) < 4 or path[2] not in ':|' or path[3] != '/': |
894 | - raise errors.InvalidURL(url_base + path, |
895 | + raise InvalidURL(url_base + path, |
896 | 'win32 file:/// paths need a drive letter') |
897 | url_base += path[0:3] # file:// + /C: |
898 | path = path[3:] # /foo |
899 | @@ -544,7 +570,7 @@ |
900 | if not isinstance(subsegment, str): |
901 | raise TypeError("Subsegment %r is not a bytestring" % subsegment) |
902 | if "," in subsegment: |
903 | - raise errors.InvalidURLJoin(", exists in subsegments", |
904 | + raise InvalidURLJoin(", exists in subsegments", |
905 | base, subsegments) |
906 | return ",".join((base,) + subsegments) |
907 | |
908 | @@ -568,7 +594,7 @@ |
909 | raise TypeError("parameter value %r for %s is not a bytestring" % |
910 | (key, value)) |
911 | if "=" in key: |
912 | - raise errors.InvalidURLJoin("= exists in parameter key", url, |
913 | + raise InvalidURLJoin("= exists in parameter key", url, |
914 | parameters) |
915 | new_parameters[key] = value |
916 | return join_segment_parameters_raw(base, |
917 | @@ -640,7 +666,7 @@ |
918 | try: |
919 | url = url.encode("ascii") |
920 | except UnicodeError as e: |
921 | - raise errors.InvalidURL(url, 'URL was not a plain ASCII url: %s' % (e,)) |
922 | + raise InvalidURL(url, 'URL was not a plain ASCII url: %s' % (e,)) |
923 | if PY3: |
924 | unquoted = urlparse.unquote_to_bytes(url) |
925 | else: |
926 | @@ -648,7 +674,7 @@ |
927 | try: |
928 | unicode_path = unquoted.decode('utf-8') |
929 | except UnicodeError as e: |
930 | - raise errors.InvalidURL(url, 'Unable to encode the URL as utf-8: %s' % (e,)) |
931 | + raise InvalidURL(url, 'Unable to encode the URL as utf-8: %s' % (e,)) |
932 | return unicode_path |
933 | |
934 | |
935 | @@ -778,7 +804,7 @@ |
936 | old_parsed = urlparse.urlparse(old_base) |
937 | new_parsed = urlparse.urlparse(new_base) |
938 | if (old_parsed[:2]) != (new_parsed[:2]): |
939 | - raise errors.InvalidRebaseURLs(old_base, new_base) |
940 | + raise InvalidRebaseURLs(old_base, new_base) |
941 | return determine_relative_path(new_parsed[2], |
942 | join(old_parsed[2], url)) |
943 | |
944 | @@ -846,7 +872,7 @@ |
945 | """ |
946 | # GZ 2017-06-09: Actually validate ascii-ness |
947 | if not isinstance(url, str): |
948 | - raise errors.InvalidURL('should be ascii:\n%r' % url) |
949 | + raise InvalidURL('should be ascii:\n%r' % url) |
950 | (scheme, netloc, path, params, |
951 | query, fragment) = urlparse.urlparse(url, allow_fragments=False) |
952 | user = password = host = port = None |
953 | @@ -863,8 +889,8 @@ |
954 | try: |
955 | port = int(port) |
956 | except ValueError: |
957 | - raise errors.InvalidURL('invalid port number %s in url:\n%s' % |
958 | - (port, url)) |
959 | + raise InvalidURL('invalid port number %s in url:\n%s' % |
960 | + (port, url)) |
961 | if host != "" and host[0] == '[' and host[-1] == ']': #IPv6 |
962 | host = host[1:-1] |
963 | |
964 | @@ -905,7 +931,7 @@ |
965 | :return: urlencoded string for final path. |
966 | """ |
967 | if not isinstance(relpath, str): |
968 | - raise errors.InvalidURL(relpath) |
969 | + raise InvalidURL(relpath) |
970 | relpath = _url_hex_escapes_re.sub(_unescape_safe_chars, relpath) |
971 | if relpath.startswith('/'): |
972 | base_parts = [] |
Hm, InvalidURL may be generic enough that it should actually be in a base level package, but urlutils is in practice imported all the time anyway, and there are some bigger changes to make on this front regardless.