Regression in DBAPIException, __str__ fails when self.params is None

Issue #1425 resolved
Former user created an issue

Calling __str__() fails on a DBAPIException in which self.params is None. If the exception is passed to Python logging, it will write stack traces like this to stderr (past the logging handlers) because the errors come up asynchronously when emitting:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/__init__.py", line 744, in emit
    msg = self.format(record)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/__init__.py", line 630, in format
    return fmt.format(record)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/__init__.py", line 418, in format
    record.message = record.getMessage()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/__init__.py", line 288, in getMessage
    msg = msg % self.args
  File "/Users/gthb/extsvn/sqlalchemy-trunk/build/lib/sqlalchemy/exc.py", line 135, in __str__
    if len(self.params) > 10:
TypeError: object of type 'NoneType' has no len()

The error is introduced in 5963 ten days ago:

        if len(self.params) > 10:

... this bombs when self.params is None.

Comments (3)

  1. Former user Account Deleted

    Can't believe I neglected to svn up before creating a ticket — sorry about the noise!

  2. Log in to comment