Xavier de Gaye added the comment:
The following patch fixes the problem when applied applied on top of PR 6730:
diff --git a/Lib/bdb.py b/Lib/bdb.py
index c6a10359ac..07231ec588 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -582,7 +582,7 @@ class Bdb:
cmd = compile(cmd, "", "exec")
New submission from Xavier de Gaye :
This issue is a companion to issue 13044.
Running with Python 3.6.5 the following code fails with NameError:
1 class C:
2 def __del__(self):
3 print('deleted')
4
5 c = C()
6 x = 1
$ python -m pdb bar.py
> ./bar.py(1)()
-> class C:
(Pdb) break 6