Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MAINT: Chain some exceptions. #16418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4 numpy/core/_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
def _kind_name(dtype):
try:
return _kind_to_stem[dtype.kind]
except KeyError:
except KeyError as e:
raise RuntimeError(
"internal dtype error, unknown kind {!r}"
.format(dtype.kind)
)
) from None


def __str__(dtype):
Expand Down
4 changes: 2 additions & 2 deletions 4 numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,9 @@ def put(a, ind, v, mode='raise'):
"""
try:
put = a.put
except AttributeError:
except AttributeError as e:
raise TypeError("argument 1 must be numpy.ndarray, "
"not {name}".format(name=type(a).__name__))
"not {name}".format(name=type(a).__name__)) from e

return put(ind, v, mode=mode)

Expand Down
8 changes: 4 additions & 4 deletions 8 numpy/core/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ def __getattribute__(self, attr):
fielddict = ndarray.__getattribute__(self, 'dtype').fields
try:
res = fielddict[attr][:2]
except (TypeError, KeyError):
raise AttributeError("recarray has no attribute %s" % attr)
except (TypeError, KeyError) as e:
raise AttributeError("recarray has no attribute %s" % attr) from e
obj = self.getfield(*res)

# At this point obj will always be a recarray, since (see
Expand Down Expand Up @@ -509,8 +509,8 @@ def __setattr__(self, attr, val):
return ret
try:
res = fielddict[attr][:2]
except (TypeError, KeyError):
raise AttributeError("record array has no attribute %s" % attr)
except (TypeError, KeyError) as e:
raise AttributeError("record array has no attribute %s" % attr) from e
zaak71 marked this conversation as resolved.
Show resolved Hide resolved
return self.setfield(val, *res)

def __getitem__(self, indx):
Expand Down
8 changes: 4 additions & 4 deletions 8 numpy/ctypeslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def ndpointer(dtype=None, ndim=None, shape=None, flags=None):
if num is None:
try:
flags = [x.strip().upper() for x in flags]
except Exception:
raise TypeError("invalid flags specification")
except Exception as e:
raise TypeError("invalid flags specification") from e
num = _num_fromflags(flags)

# normalize shape to an Optional[tuple]
Expand Down Expand Up @@ -377,10 +377,10 @@ def _ctype_from_dtype_scalar(dtype):
dtype_native = dtype.newbyteorder('=')
try:
ctype = _scalar_type_map[dtype_native]
except KeyError:
except KeyError as e:
raise NotImplementedError(
"Converting {!r} to a ctypes type".format(dtype)
)
) from None

if dtype_with_endian.byteorder == '>':
ctype = ctype.__ctype_be__
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.