diff options
| author | Nate Clark <natec425@gmail.com> | 2019-02-20 12:58:18 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-02-20 18:56:47 -0500 |
| commit | 8f318692d4443300c90c7be9dc44ae3c8707f818 (patch) | |
| tree | 3b935eedfd1c31ae4c69c4996f3bae5adec2bd71 /lib/sqlalchemy/util | |
| parent | d879bed8786b6387b470c148b412731456793653 (diff) | |
| download | sqlalchemy-8f318692d4443300c90c7be9dc44ae3c8707f818.tar.gz | |
Include newlines in StatementError formatting
Revised the formatting for :class:`.StatementError` when stringified. Each
error detail is broken up over multiple newlines instead of spaced out on a
single line. Additionally, the SQL representation now stringifies the SQL
statement rather than using ``repr()``, so that newlines are rendered as is.
Pull request courtesy Nate Clark.
Fixes: #4500
Closes: #4501
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4501
Pull-request-sha: 60cc0ee68dc96b8f483a60d37bcb26b6c6d53efe
Change-Id: I79d8418b7495e5691c9a56f41e79495c26a967ff
Diffstat (limited to 'lib/sqlalchemy/util')
| -rw-r--r-- | lib/sqlalchemy/util/compat.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index ff644cd36..c12f2d379 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -227,6 +227,15 @@ else: # error callback" return repr(text)[1:-1].decode() + def safe_bytestring(text): + # py2k only + if not isinstance(text, string_types): + return unicode(text).encode("ascii", errors="backslashreplace") + elif isinstance(text, unicode): + return text.encode("ascii", errors="backslashreplace") + else: + return text + # not as nice as that of Py3K, but at least preserves # the code line where the issue occurred exec( |
