]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed `__repr__()` on mapper property constructs
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 11 Apr 2013 23:37:56 +0000 (19:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 11 Apr 2013 23:37:56 +0000 (19:37 -0400)
to work before the object is initialized, so
that Sphinx builds with recent Sphinx versions
can read them.

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/orm/interfaces.py

index 8df055e10f66ed8f5c869269b1433fef60c649e7..13c044351c8e7ef40a34feb7d30305e23512615a 100644 (file)
@@ -6,6 +6,14 @@
 .. changelog::
     :version: 0.8.1
 
+    .. change::
+      :tags: bug, orm
+
+      Fixed `__repr__()` on mapper property constructs
+      to work before the object is initialized, so
+      that Sphinx builds with recent Sphinx versions
+      can read them.
+
     .. change::
       :tags: bug, sql, postgresql
 
index 62cdb2710741e438dec0cab1e56c2e1e9ed41b32..70743624ce7a897d8f9b32d3df09b118322c5258 100644 (file)
@@ -289,7 +289,7 @@ class MapperProperty(_MappedAttribute, _InspectionAttr):
     def __repr__(self):
         return '<%s at 0x%x; %s>' % (
             self.__class__.__name__,
-            id(self), self.key)
+            id(self), getattr(self, 'key', 'no key'))
 
 class PropComparator(operators.ColumnOperators):
     """Defines boolean, comparison, and other operators for