This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author blueyed
Recipients blueyed
Date 2019-05-23.16:02:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558627334.31.0.41290624509.issue37022@roundup.psfhosted.org>
In-reply-to
Content
Given:

```
class BadRepr:
    def __repr__(self):
        raise Exception('repr_exc')


obj = BadRepr()

__import__('pdb').set_trace()
```

```
(Pdb) p obj
(Pdb) pp obj
(Pdb)
```

Possible patch - clumsy due to `self._getval` both printing any error already, and raising the exception:

```
diff --git i/Lib/pdb.py w/Lib/pdb.py
index f5d33c27fc..59a419d961 100755
--- i/Lib/pdb.py
+++ w/Lib/pdb.py
@@ -1177,18 +1177,28 @@ def do_p(self, arg):
         Print the value of the expression.
         """
         try:
-            self.message(repr(self._getval(arg)))
+            val = self._getval(arg)
         except:
-            pass
+            return
+        try:
+            self.message(repr(val))
+        except:
+            exc_info = sys.exc_info()[:2]
+            self.error(traceback.format_exception_only(*exc_info)[-1].strip())

     def do_pp(self, arg):
         """pp expression
         Pretty-print the value of the expression.
         """
         try:
-            self.message(pprint.pformat(self._getval(arg)))
+            val = self._getval(arg)
         except:
-            pass
+            return
+        try:
+            self.message(pprint.pformat(val))
+        except:
+            exc_info = sys.exc_info()[:2]
+            self.error(traceback.format_exception_only(*exc_info)[-1].strip())

     complete_print = _complete_expression
     complete_p = _complete_expression
```
History
Date User Action Args
2019-05-23 16:02:14blueyedsetrecipients: + blueyed
2019-05-23 16:02:14blueyedsetmessageid: <1558627334.31.0.41290624509.issue37022@roundup.psfhosted.org>
2019-05-23 16:02:14blueyedlinkissue37022 messages
2019-05-23 16:02:13blueyedcreate