[Python-bugs-list] [ python-Bugs-810214 ] exit() raises exception

SourceForge.net noreply at sourceforge.net
Sun Sep 21 16:42:48 EDT 2003


Bugs item #810214, was opened at 2003-09-21 14:36
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=810214&group_id=5470

Category: None
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Jozef Behran (jojoworks)
Assigned to: Nobody/Anonymous (nobody)
Summary: exit() raises exception

Initial Comment:
--- BEGIN OF SESSION TRANSCRIPT ---

$ python

Python version: 2.2.2 (#2, Feb 5 2003, 10:40:08)

[GCC 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk)] on linux-i386

Type "help", "copyright", "credits" or "license" for

more information.

>>> <CTRL-D>

$ cat exit.py

exit(1)

$ python exit.py

Traceback (most recent call last):

  File "exit.py", line 1, in ?

    exit(1);

TypeError: 'str' object is not callable

$ cat exitstr.py

exit("Fatal error")

$ python exitstr.py

Traceback (most recent call last):

  File "exitstr.py", line 1, in ?

    exit("Fatal error");

TypeError: 'str' object is not callable

--- END OF SESSION TRANSCRIPT ---



The first "python ..." command shall output nothing and

return 1 as the result. The second "python ..." command

shall output "Fatal error" to stderr and return 1 as

the result. No exception shall be raised there.



----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2003-09-21 16:42

Message:
Logged In: YES 
user_id=31435

It appears that you want to use the os.exit() function.  If so, 

you must import it from os.  The builtin exit (which you're 

using) is indeed just a string, which displays a message to 

interactive users telling them the correct way to end an 

interpreter session.  This varies across platforms.  For 

example, here under Cygwin:



$ python

Python 2.2.2 (#1, Dec 31 2002, 12:24:34)

[GCC 3.2 20020927 (prerelease)] on cygwin

Type "help", "copyright", "credits" or "license" for more 

information.

>>> exit

'Use Ctrl-D (i.e. EOF) to exit.'

>>>



"'str' object is not callable" is a perfectly appropriate 

exception if you try to (as you are trying to do) *call* a 

string with an argument.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=810214&group_id=5470



More information about the Python-bugs-list mailing list