Commit 0b86507
committed
Fix pickling of httpclient.HTTPError subclasses and web.HTTPError
The `args` member variable is set by `BaseException.__new__` and used
by `BaseException.__reduce__` for pickling. To avoid interfering with
it, we need to avoid calling `BaseException.__init__` from classes
that have subclasses with incompatible constructors, and rename our
own `tornado.web.HTTPError.args` member.
>>> pickle.loads(pickle.dumps(tornado.simple_httpclient.HTTPTimeoutError("message")))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: HTTPTimeoutError.__init__() takes 2 positional arguments but 4 were given
>>> str(pickle.loads(pickle.dumps(tornado.web.HTTPError(500, "%s", "foo"))))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/anders/python/tornado/tornado/web.py", line 2488, in __str__
return message + " (" + (self.log_message % self.args) + ")"
~~~~~~~~~~~~~~~~~^~~~~~~~~~~
TypeError: not enough arguments for format string
Signed-off-by: Anders Kaseorg <andersk@mit.edu>1 parent 5e4fff4 commit 0b86507
2 files changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | 720 | | |
722 | 721 | | |
723 | 722 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2520 | 2520 | | |
2521 | 2521 | | |
2522 | 2522 | | |
2523 | | - | |
| 2523 | + | |
2524 | 2524 | | |
2525 | 2525 | | |
2526 | 2526 | | |
2527 | 2527 | | |
2528 | 2528 | | |
2529 | 2529 | | |
2530 | 2530 | | |
2531 | | - | |
| 2531 | + | |
2532 | 2532 | | |
2533 | 2533 | | |
2534 | 2534 | | |
2535 | 2535 | | |
2536 | | - | |
2537 | | - | |
| 2536 | + | |
| 2537 | + | |
2538 | 2538 | | |
2539 | 2539 | | |
2540 | 2540 | | |
| |||
0 commit comments