[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 175ebc60d52f2e88cf5cba5224c15074d2623c10 by Miss Islington (bot) 
in branch '3.9':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180) (GH-26651)
https://github.com/python/cpython/commit/175ebc60d52f2e88cf5cba5224c15074d2623c10


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset e3bc32fc1ad5537b476b34062b07a040533c913a by Miss Islington (bot) 
in branch '3.10':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180) (GH-26650)
https://github.com/python/cpython/commit/e3bc32fc1ad5537b476b34062b07a040533c913a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 6544b2532df82d137b71323445a07a6e29bcdec0 by Daniel Hahler in 
branch 'main':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180)
https://github.com/python/cpython/commit/6544b2532df82d137b71323445a07a6e29bcdec0


--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25237
pull_request: https://github.com/python/cpython/pull/26651

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +25236
pull_request: https://github.com/python/cpython/pull/26650

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11 -Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2020-01-25 Thread daniel hahler


Change by daniel hahler :


--
keywords: +patch
pull_requests: +17564
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18180

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2019-05-24 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

This part of the code is already used in three places and your patch would add 
two occurrences of of it, I think it would be great to put the part that print 
the exception in a private method, to avoid duplicating it all over the place.

Doing this seems small enough to me that I think it could be done in the same 
PR to avoid the overhead of having two separates PRs.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2019-05-24 Thread daniel hahler


daniel hahler  added the comment:

Thanks for the feedback.

What do you think of refactoring the common block (also used in other places) 
into a method?

+except:
+exc_info = sys.exc_info()[:2]
+self.error(traceback.format_exception_only(*exc_info)[-1].strip())

This could/should be done separately probably then, just want your opinion on 
it.  This would also allow to customize/override it in a single place then 
(e.g. with pdbpp I am displaying tracebacks for errors, which is done via 
error() currently then).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2019-05-24 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi Daniel, this is indeed unexpected, I don't see how to have a better patch 
since the fact that _getval() raise an exception is used in do_source() and 
do_whatis().

Could you convert your patch as a PR and add a test?

--
nosy: +remi.lapeyre

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2019-05-23 Thread daniel hahler


New submission from daniel hahler :

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
```

--
components: Library (Lib)
messages: 343306
nosy: blueyed
priority: normal
severity: normal
status: open
title: pdb: do_p and do_pp swallow exceptions from __repr__
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com