fix #4150: pdb's up command didn't work for generators in post-mortem
diff --git a/Lib/bdb.py b/Lib/bdb.py
index d74415b..5288cc0 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -320,6 +320,8 @@
         while t is not None:
             stack.append((t.tb_frame, t.tb_lineno))
             t = t.tb_next
+        if f is None:
+            i = max(0, len(stack) - 1)
         return stack, i
 
     #