Skip to content

Commit c9b4479

Browse files
committed
gh-145966: Address review feedback: fix PEP-7 alignment, simplify NEWS, fix blank lines
1 parent 6f3ae87 commit c9b4479

3 files changed

Lines changed: 14 additions & 17 deletions

File tree

Lib/test/test_csv.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,6 @@ class mydialect(csv.Dialect):
12801280
self.assertRaises(ValueError, create_invalid, field_name, " ",
12811281
skipinitialspace=True)
12821282

1283-
12841283
def test_dialect_getattr_non_attribute_error_propagates(self):
12851284
# gh-145966: non-AttributeError exceptions raised by __getattr__
12861285
# during dialect attribute lookup must propagate, not be silenced.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
Fixed ``DIALECT_GETATTR`` macro in :mod:`csv` to only clear
2-
:exc:`AttributeError` exceptions. Previously, all exceptions (including
3-
:exc:`MemoryError` and :exc:`KeyboardInterrupt`) were silently suppressed
4-
when looking up dialect attributes.
1+
Non-:exc:`AttributeError` exceptions raised during dialect attribute lookup
2+
in :mod:`csv` are no longer silently suppressed.

Modules/_csv.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,18 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
497497
Py_XINCREF(skipinitialspace);
498498
Py_XINCREF(strict);
499499
if (dialect != NULL) {
500-
#define DIALECT_GETATTR(v, n) \
501-
do { \
502-
if (v == NULL) { \
503-
v = PyObject_GetAttrString(dialect, n); \
504-
if (v == NULL) { \
505-
if (PyErr_ExceptionMatches( \
506-
PyExc_AttributeError)) \
507-
PyErr_Clear(); \
508-
else \
509-
goto err; \
510-
} \
511-
} \
500+
#define DIALECT_GETATTR(v, n) \
501+
do { \
502+
if (v == NULL) { \
503+
v = PyObject_GetAttrString(dialect, n); \
504+
if (v == NULL) { \
505+
if (PyErr_ExceptionMatches( \
506+
PyExc_AttributeError)) \
507+
PyErr_Clear(); \
508+
else \
509+
goto err; \
510+
} \
511+
} \
512512
} while (0)
513513
DIALECT_GETATTR(delimiter, "delimiter");
514514
DIALECT_GETATTR(doublequote, "doublequote");

0 commit comments

Comments
 (0)