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 8369227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:35:33+00:00 2026-06-09T13:35:33+00:00

This happens on both python2.6 and python3: class Error(Exception): def __init__(self, args): print(type(args)) print(type(self.args))

  • 0

This happens on both python2.6 and python3:

class Error(Exception):
    def __init__(self, args):
            print(type(args))
            print(type(self.args)) # From BaseException
            self.args = args
            print(type(self.args))

Error("foo")

This results in:

<type 'str'>
<type 'tuple'>
<type 'tuple'>
Error('f', 'o', 'o')

For some reason, the args attribute is coerced into a tuple.
Might the fact that it’s defined in C have something to do with it? https://github.com/python/cpython/blob/master/Objects/exceptions.c

The name of the args argument is unrelated. Changing it to ‘a’ results in the same behavior, as long as it is assigned to self.args.

  • 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-09T13:35:34+00:00Added an answer on June 9, 2026 at 1:35 pm

    Looking at the code you link to, there is a setter defined for the “args” attribute. Look for BaseException_set_args – it is being set (elsewhere in the linked code) as the setter for args. So when you write self.args = args, you’re really calling the function BaseException_set_args, with args as the argument.

    If you then look in BaseException_set_args, it is coercing the argument into a tuple. If you give try to set self.args to something that can’t be converted to a tuple (e.g. try Error(23)), you’ll get a TypeError.

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

Sidebar

Related Questions

I am writting a Python class with this constructor: #constuctor def __init__(self, initPt_=[1,1],fun_=Optim_tests.peaks,NITER_=30,alpha_=0.7,NMAX_=5000,FTOL_=10**(-10)): self.initPt
I have the following python code: class FooMeta(type): def __setattr__(self, name, value): print name,
Sometimes users mistakenly redirected to ?Process=ViewImages&PAGEID=. When this happens, they get the following error.
I have a program which embeds both python2 and python3 interpreters. The libpython shared
This happens almost every time I init a new repo. Start a new project.
This happens after I hit Build and Go to run my app on my
This happens in IDLE and Windows 7 RC1 (if that helps). Here is the
I am authenticating users in ldap, but this happens only once, when user is
I need to catch segmentation fault in third party library cleanup operations. This happens
MacPorts installed libiconv @1.14_0+universal as a dependency on my system. This happens to be

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.