mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-5001, bpo-31169: Fix two uninformative asserts in multiprocessing/managers.py (#3078)
* Make error message more informative Replace assertions in error-reporting code with more-informative version that doesn't cause confusion over where and what the error is. * Additional clarification + get travis to check * Change from SystemError to TypeError As suggested in PR comment by @pitrou, changing from SystemError; TypeError appears appropriate. * NEWS file installation; ACKS addition (will do my best to justify it by additional work)
This commit is contained in:
parent
e664d7f89d
commit
48d9823a0e
3 changed files with 20 additions and 7 deletions
|
@ -84,14 +84,17 @@ def dispatch(c, id, methodname, args=(), kwds={}):
|
|||
def convert_to_error(kind, result):
|
||||
if kind == '#ERROR':
|
||||
return result
|
||||
elif kind == '#TRACEBACK':
|
||||
assert type(result) is str
|
||||
return RemoteError(result)
|
||||
elif kind == '#UNSERIALIZABLE':
|
||||
assert type(result) is str
|
||||
return RemoteError('Unserializable message: %s\n' % result)
|
||||
elif kind in ('#TRACEBACK', '#UNSERIALIZABLE'):
|
||||
if not isinstance(result, str):
|
||||
raise TypeError(
|
||||
"Result {0!r} (kind '{1}') type is {2}, not str".format(
|
||||
result, kind, type(result)))
|
||||
if kind == '#UNSERIALIZABLE':
|
||||
return RemoteError('Unserializable message: %s\n' % result)
|
||||
else:
|
||||
return RemoteError(result)
|
||||
else:
|
||||
return ValueError('Unrecognized message type')
|
||||
return ValueError('Unrecognized message type {!r}'.format(kind))
|
||||
|
||||
class RemoteError(Exception):
|
||||
def __str__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue