Bug of the Day: :issue:`19449` ============================== Something I forgot to mention in yesterday's introduction to this series is that one of my goals is to commit patches that have been produced by people who don't themselves have commit privileges. Today's bug is the first of that sort. :issue:`19449` is pretty straightforward: the code for generating the error message in :class:`csv.DictWriter` fails with an :exc:`TypeError` if the dictionary passed to the :meth:`~csv.csvwriter.writerow` method contains any unknown keys that are not strings. Since :mod:`csv` otherwise copes with non-string keys just fine (by calling ``str`` on them), the error handling code just needs to do something similar. In both the initial patch suggested by the bug reporter Thomas Grahn and the expanded patch-with-test provided by Vajrasky Kok, this is accomplished by calling ``repr`` on the "wrong keys" as we collect them. We use ``repr`` rather than ``str`` because it is an error message, making it easier to identify the types of the incorrect keys. Thanks to Thomas for reporting the bug and providing a fix, and to Vajrasky for providing the patch with a test.