[Patches] [ python-Patches-1685642 ] Add IllegalStateError

SourceForge.net noreply at sourceforge.net
Thu Mar 22 01:25:24 CET 2007


Patches item #1685642, was opened at 2007-03-22 01:25
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1685642&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Björn Lindqvist (sonderblade)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add IllegalStateError

Initial Comment:
Java has an exception called IllegalStateException. It is very useful for signaling "what you did would have been OK, but right now I can't do it." Python does not have a counterpart, but I think it should.

For example, if you have a Python RDBMS-binding and you call db.select() before calling db.connect() it could raise a IllegalStateError (or maybe a subclass of it) that says 'IllegalStateError: "Must be connected to perform queries"'. 

Or for another example, take the Thread.start() function. Currently, if you call myThread.start() twice it will raise an AssertionError. That's no good because the result is undefined if you run python with -O. See Bug #904498 and Patch #1676820 (Martin v. Löwis comment). IllegalStateError should fit perfectly here:

>>> t = threading.Thread()
>>> t.start()
>>> t.start()
Traceback (most recent call last):
  ...
IllegalStateError: thread already started

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

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


More information about the Patches mailing list