Walter Dörwald avatar Walter Dörwald committed 6771e18

Fix pprint to be able to handle objects that don't have a __repr__
attribute. Fixes SF bug #1065456.

Comments (0)

Files changed (1)

         write = stream.write
 
         if sepLines:
-            r = typ.__repr__
+            r = getattr(typ, "__repr__", None)
             if issubclass(typ, dict) and r is dict.__repr__:
                 write('{')
                 if self._indent_per_level > 1:
                 write(qget(char, repr(char)[1:-1]))
         return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
 
-    r = typ.__repr__
+    r = getattr(typ, "__repr__", None)
     if issubclass(typ, dict) and r is dict.__repr__:
         if not object:
             return "{}", True, False
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.