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

  • Home
  • SEARCH
  • 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 6054767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:11:24+00:00 2026-05-23T08:11:24+00:00

Possible Duplicate: Don't show Python raise-line in the exception stack Built in exceptions like

  • 0

Possible Duplicate:
Don't show Python raise-line in the exception stack

Built in exceptions like NameError etc. give me a traceback to the point in my code where the exception occurred. I’m working on a utility module and it bugs me that if code using my module raises and exception the last thing in the traceback before the exception is my raise WhateverError.

Is there any way to raise an exception in python and have the tracback stop one frame up ala the builtin exceptions (without writing c code)?

  • 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-05-23T08:11:24+00:00Added an answer on May 23, 2026 at 8:11 am

    Pure Python doesn’t provide a way to mutate existing traceback objects or create arbitrary traceback objects.

    >>> exc_info[2].tb_next = None
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: readonly attribute
    
    >>> types.TracebackType()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: cannot create 'traceback' instances
    

    Note that if it were possible to do this you wouldn’t just affect the default formatting of tracebacks, you’d also interfere with people’s ability to use pdb to post-mortem errors in your utility module.

    If the traceback is being logged or otherwise formatted by your utility module then you can just not include the frames you consider uninteresting in the output. For instance, the standard library’s unittest module does this when reporting errors that occur while running tests.

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

Sidebar

Related Questions

Possible Duplicate: curly braces in string I still don't know what it's called. Like:
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: private members in python I've got few variables I really want to
Possible Duplicate: How do you generate dynamic (parameterized) unit tests in Python? Is there
Possible Duplicate: Why don’t self-closing script tags work? I had this bit of javascript
Possible Duplicate: How does Facebook Sharer select Images? I have implemented the Facebook Like
Possible Duplicate: Where should I call Free() function? When I used valgrind --leak-check=full --show-reachable=yes
Possible Duplicate: Is there something wrong with joins that don't use the JOIN keyword
Possible Duplicate: An Ideal Keyboard Layout for Programming As a programmer I don't type
Possible Duplicate: mysql_real_escape_string VS addslashes If they don't do exactly the same, what's the

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.