Skip to content

Commit 0ee5b7f

Browse files
authored
Merge pull request #486 from seeM/fix-http-exceptions
fix: error in IPython while handling `HTTP4xxClientError`
2 parents f7e81b8 + 8fdfd81 commit 0ee5b7f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

fastcore/net.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def urlopener():
9191

9292
for code,msg in _httperrors:
9393
nm = f'HTTP{code}{msg.replace(" ","")}Error'
94-
cls = get_class(nm, 'url', 'hdrs', 'fp', sup=HTTP4xxClientError, msg=msg, code=code)
94+
def _init(self, url, hdrs, fp, msg=msg, code=code): HTTP4xxClientError.__init__(self, url, code, msg, hdrs, fp)
95+
cls = type(nm, (HTTP4xxClientError,), {'__init__':_init})
9596
globals()[nm] = ExceptionsHTTP[code] = cls
9697

9798
# %% ../nbs/03b_net.ipynb 16

nbs/03b_net.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"text/markdown": [
185185
"---\n",
186186
"\n",
187-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L63){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
187+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L64){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
188188
"\n",
189189
"#### HTTP4xxClientError\n",
190190
"\n",
@@ -195,7 +195,7 @@
195195
"text/plain": [
196196
"---\n",
197197
"\n",
198-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L63){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
198+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L64){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
199199
"\n",
200200
"#### HTTP4xxClientError\n",
201201
"\n",
@@ -223,7 +223,7 @@
223223
"text/markdown": [
224224
"---\n",
225225
"\n",
226-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L68){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
226+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L69){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
227227
"\n",
228228
"#### HTTP5xxServerError\n",
229229
"\n",
@@ -234,7 +234,7 @@
234234
"text/plain": [
235235
"---\n",
236236
"\n",
237-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L68){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
237+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L69){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
238238
"\n",
239239
"#### HTTP5xxServerError\n",
240240
"\n",
@@ -286,7 +286,8 @@
286286
"\n",
287287
"for code,msg in _httperrors:\n",
288288
" nm = f'HTTP{code}{msg.replace(\" \",\"\")}Error'\n",
289-
" cls = get_class(nm, 'url', 'hdrs', 'fp', sup=HTTP4xxClientError, msg=msg, code=code)\n",
289+
" def _init(self, url, hdrs, fp, msg=msg, code=code): HTTP4xxClientError.__init__(self, url, code, msg, hdrs, fp)\n",
290+
" cls = type(nm, (HTTP4xxClientError,), {'__init__':_init})\n",
290291
" globals()[nm] = ExceptionsHTTP[code] = cls"
291292
]
292293
},

0 commit comments

Comments
 (0)