]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Leave bytestring exception messages as bytestrings
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Jan 2019 17:03:40 +0000 (12:03 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Jan 2019 00:49:47 +0000 (19:49 -0500)
commitb5b28733c6037e23b5f5a4b3192b65963263fb81
tree7177aca26f74ba890e9ffe77aa03856790fc1376
parentb5083e5fdcbcb2348559c3cf85787fcb057e8a39
Leave bytestring exception messages as bytestrings

Fixed a regression introduced in version 1.2 where a refactor
of the :class:`.SQLAlchemyError` base exception class introduced an
inappropriate coercion of a plain string message into Unicode under
python 2k, which is not handled by the Python interpreter for characters
outside of the platform's encoding (typically ascii).  The
:class:`.SQLAlchemyError` class now passes a bytestring through under
Py2K for ``__str__()`` as is the behavior of exception objects in general
under Py2K, does a safe coercion to unicode utf-8 with
backslash fallback for ``__unicode__()``.  For Py3K the message is
typically unicode already, but if not is again safe-coerced with utf-8
with backslash fallback for the ``__str__()`` method.

Fixes: #4429
Change-Id: I2289da3f2c45c7d0041fa43d838958f7614defc3
(cherry picked from commit 2db54ee92ebd0970f52b271e152a6df9b563693f)
doc/build/changelog/unreleased_12/4429.rst [new file with mode: 0644]
lib/sqlalchemy/exc.py
lib/sqlalchemy/testing/suite/test_dialect.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/compat.py
test/base/test_utils.py
test/engine/test_execute.py