Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:06:23+00:00 2026-06-16T05:06:23+00:00

I have been playing around with post-mortem debugging and am having some problems. Consider

  • 0

I have been playing around with post-mortem debugging and am having some problems. Consider the following python script called example.py:

k = 0
print 1. / k
print 'continue ...'

I can run this with:

> python -m pdb example.py

and then step to line 2 print 1. / k and then set k = 1 and then continue with the pdb command c.

Now if I do this with post-mortem debugging I am unable to continue program execution. I run with:

> python -i example.py

and then after I am dropped into the shell I do a:

import pdb
pdb.pm()

I am then able to change the value of k as before, but I am unable to continue with any program execution. Pdb just simply exits.

I was unable to find anywhere that it explicitly states that you cannot step through a program in post-mortem. It appears to be the case. So then I would like to understand the value of post-mortem debugging. Is the only value to examine the state of the code when the error occurred?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:06:24+00:00Added an answer on June 16, 2026 at 5:06 am

    A post-mortem is invoked when an exception has been thrown.

    At that point, the stack is no longer ‘active’ and you cannot step through the code anymore. After all, an exception has just been thrown, signalling that the code path can no longer continue. What would you expect result to be if you had the expression result = 1. / k for example?

    A literal Post-Mortem is used to see, after the patient has died (post mortem, in latin), what the cause of death was. A pdb post-mortem is no different. You get to see what the state of the program was at the moment of death, but you do not get to re-animate the deceased.

    In other words, the purpose of a Post Mortem is to understand why the program has failed, by examining, in detail, what the program state was at the moment of failure.

    The term has not been explicitly documented in the pdb manual probably because the term “Post Mortem” is thought to be in common use. The Wikipedia article on debugging mentions it in passing, and Python is not the only language that offers the technique; Windows debuggers offer the feature as well, R does so too, as do others.

    If you were hoping to ‘re-animate’ the corpse from the traceback, know that there are huge hurdles to overcome. While the traceback of an exception does include references to the global and local namespace of each frame in the stack, a live stack contains a lot more state that’s not included in the traceback, state that can’t be re-constructed. This includes closure cells attached to nested functions (especially when the parent function from which the closure originated is not itself part of the traceback), or the internal bookkeeping needed to handle try..except, try..finally or with blocks, or the iterator object used by an active for or async for loop.

    To those that were hoping otherwise, I say this: The program is passed on! This program is no more! It has ceased to be! ‘t’s expired and gone to meet ‘is maker! ‘t’s a stiff! Bereft of life, ‘t rests in peace! If you hadn’t nailed it to a traceback ‘t’d be pushing up the daisies! It’s evaluation loop bookkeeping is now ‘istory! ‘t’s off the twig! It’s kicked the bucket, ‘t’s shuffled off its mortal coil, run down the curtain and joined the bleedin’ choir invisible!! THIS IS AN EX-PROGRAM.

    (With apologies to John Cleese and Michael Palin).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been playing around with some debugging and wrote some C code that
I have been playing around with writing some simple card games in Python for
I have been playing around with Google Apps Script today and I am trying
I have been playing around with NSURLConnection. Now I'm trying to grab some data
I have been playing around with Python and math lately, and I ran in
I have been playing around with Threads and Tasks (.net 4) and noticed some
I have been playing around with Python's FTP library and am starting to think
I have been playing around with jqgrid, and have the following question. To get
First post time, I've been playing around with MVC abit... I have a view
A friend and I have been playing around with pygame some and came across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.