@@ -194,11 +194,11 @@ which comes after we have a look at what happens when things go wrong.
194
194
Handling Exceptions
195
195
===================
196
196
197
- *urlopen * raises :exc: `URLError ` when it cannot handle a response (though as
197
+ *urlopen * raises :exc: `~urllib.error. URLError ` when it cannot handle a response (though as
198
198
usual with Python APIs, built-in exceptions such as :exc: `ValueError `,
199
199
:exc: `TypeError ` etc. may also be raised).
200
200
201
- :exc: `HTTPError ` is the subclass of :exc: `URLError ` raised in the specific case of
201
+ :exc: `~urllib.error. HTTPError ` is the subclass of :exc: `~urllib.error. URLError ` raised in the specific case of
202
202
HTTP URLs.
203
203
204
204
The exception classes are exported from the :mod: `urllib.error ` module.
@@ -229,12 +229,12 @@ the status code indicates that the server is unable to fulfil the request. The
229
229
default handlers will handle some of these responses for you (for example, if
230
230
the response is a "redirection" that requests the client fetch the document from
231
231
a different URL, urllib will handle that for you). For those it can't handle,
232
- urlopen will raise an :exc: `HTTPError `. Typical errors include '404' (page not
232
+ urlopen will raise an :exc: `~urllib.error. HTTPError `. Typical errors include '404' (page not
233
233
found), '403' (request forbidden), and '401' (authentication required).
234
234
235
235
See section 10 of :rfc: `2616 ` for a reference on all the HTTP error codes.
236
236
237
- The :exc: `HTTPError ` instance raised will have an integer 'code' attribute, which
237
+ The :exc: `~urllib.error. HTTPError ` instance raised will have an integer 'code' attribute, which
238
238
corresponds to the error sent by the server.
239
239
240
240
Error Codes
@@ -317,7 +317,7 @@ dictionary is reproduced here for convenience ::
317
317
}
318
318
319
319
When an error is raised the server responds by returning an HTTP error code
320
- *and * an error page. You can use the :exc: `HTTPError ` instance as a response on the
320
+ *and * an error page. You can use the :exc: `~urllib.error. HTTPError ` instance as a response on the
321
321
page returned. This means that as well as the code attribute, it also has read,
322
322
geturl, and info, methods as returned by the ``urllib.response `` module::
323
323
@@ -338,7 +338,7 @@ geturl, and info, methods as returned by the ``urllib.response`` module::
338
338
Wrapping it Up
339
339
--------------
340
340
341
- So if you want to be prepared for :exc: `HTTPError ` *or * :exc: `URLError ` there are two
341
+ So if you want to be prepared for :exc: `~urllib.error. HTTPError ` *or * :exc: `~urllib.error. URLError ` there are two
342
342
basic approaches. I prefer the second approach.
343
343
344
344
Number 1
@@ -365,7 +365,7 @@ Number 1
365
365
.. note ::
366
366
367
367
The ``except HTTPError `` *must * come first, otherwise ``except URLError ``
368
- will *also * catch an :exc: `HTTPError `.
368
+ will *also * catch an :exc: `~urllib.error. HTTPError `.
369
369
370
370
Number 2
371
371
~~~~~~~~
@@ -391,7 +391,7 @@ Number 2
391
391
info and geturl
392
392
===============
393
393
394
- The response returned by urlopen (or the :exc: `HTTPError ` instance) has two
394
+ The response returned by urlopen (or the :exc: `~urllib.error. HTTPError ` instance) has two
395
395
useful methods :meth: `info ` and :meth: `geturl ` and is defined in the module
396
396
:mod: `urllib.response `..
397
397
0 commit comments