diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-31 15:22:00 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-31 15:22:00 -0400 |
| commit | 3c60d3b1ca492ba77d64111f0378892acaadf36b (patch) | |
| tree | 5e2df552a7142cd3bb2ef9e5236db85e5c2859f4 /lib/sqlalchemy/sql | |
| parent | 903b0a42e71c81ff99494352760c0f92fa7a486d (diff) | |
| download | sqlalchemy-3c60d3b1ca492ba77d64111f0378892acaadf36b.tar.gz | |
- A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string. This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.
fixes #3178
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 12 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index c8e815d24..8225a3533 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -1124,8 +1124,12 @@ class Column(SchemaItem, ColumnClause): else: if getattr(self.type, '_warn_on_bytestring', False): if isinstance(self.default, util.binary_type): - util.warn("Unicode column received non-unicode " - "default value.") + util.warn( + "Unicode column '%s' has non-unicode " + "default value %r specified." % ( + self.key, + self.default + )) args.append(ColumnDefault(self.default)) if self.server_default is not None: diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index a7f25bbfa..4de4885c6 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -180,8 +180,10 @@ class String(Concatenable, TypeEngine): if self._warn_on_bytestring: def process(value): if isinstance(value, util.binary_type): - util.warn("Unicode type received non-unicode" - "bind param value.") + util.warn_limited( + "Unicode type received non-unicode " + "bind param value %r.", + util.ellipses_string(value)) return value return process else: @@ -194,8 +196,10 @@ class String(Concatenable, TypeEngine): if isinstance(value, util.text_type): return encoder(value, self.unicode_error)[0] elif warn_on_bytestring and value is not None: - util.warn("Unicode type received non-unicode bind " - "param value") + util.warn_limited( + "Unicode type received non-unicode bind " + "param value %r.", + util.ellipses_string(value)) return value return process else: |
