Skip to content

Commit

Permalink
pythongh-114628: Display csv.Error without context (python#115005)
Browse files Browse the repository at this point in the history
When cvs.Error is raised when TypeError is caught,
the TypeError display and 'During handling' note is just noise
with duplicate information.  Suppress with 'from None'.
  • Loading branch information
terryjreedy authored and aisk committed Feb 11, 2024
1 parent 6344424 commit ca51cb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/csv.py
Expand Up @@ -113,8 +113,8 @@ def _validate(self):
try:
_Dialect(self)
except TypeError as e:
# We do this for compatibility with py2.3
raise Error(str(e))
# Re-raise to get a traceback showing more user code.
raise Error(str(e)) from None

class excel(Dialect):
"""Describe the usual properties of Excel-generated CSV files."""
Expand Down
@@ -0,0 +1,2 @@
When csv.Error is raised when handling TypeError, do not print the TypeError
traceback.

0 comments on commit ca51cb6

Please sign in to comment.