]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-114628: Display csv.Error without context (#115005)
authorTerry Jan Reedy <tjreedy@udel.edu>
Mon, 5 Feb 2024 01:57:54 +0000 (20:57 -0500)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2024 01:57:54 +0000 (20:57 -0500)
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'.

Lib/csv.py
Misc/NEWS.d/next/Library/2024-02-04-13-17-33.gh-issue-114628.WJpqqS.rst [new file with mode: 0644]

index a079279b8b8cbce8dd39164ce33349c2f4990c90..75e35b23236795fac0e1b9405f170f7e7faea0c6 100644 (file)
@@ -113,8 +113,8 @@ class Dialect:
         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."""
diff --git a/Misc/NEWS.d/next/Library/2024-02-04-13-17-33.gh-issue-114628.WJpqqS.rst b/Misc/NEWS.d/next/Library/2024-02-04-13-17-33.gh-issue-114628.WJpqqS.rst
new file mode 100644 (file)
index 0000000..8138adc
--- /dev/null
@@ -0,0 +1,2 @@
+When csv.Error is raised when handling TypeError, do not print the TypeError
+traceback.