[issue6634] sys.exit() called from threads other than the main one: undocumented behaviour
David Manowitz added the comment: I don't see why this should be considered acceptable behavior. Why don't threads have their own ThreadExit exception, rather than overloading the use, and therefore, the meaning, of the SystemExit exception? As indicated by their names, sys.exit and the SystemExit exception should *only* be used to exit the entire system, not just a thread! -- components: +Library (Lib) nosy: +David.Manowitz ___ Python tracker <http://bugs.python.org/issue6634> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6634] sys.exit() called from threads other than the main one: undocumented behaviour
David Manowitz added the comment: I have a couple of issues with that argument: 1.) Until fairly recently, the fact that sys.exit() when called from a non-primary thread only causes the thread to die, was not clearly documented (and still isn't in the python2.6 docs). Admittedly, thread.exit() does say that it raises the SystemExit exception, but as most people are encouraged to use the *threading* module, rather than the *thread* module directly, this is still fairly obscure. 2.) A ThreadExit exception could be derived from the SystemExit exception, so existing code that works by catching a SystemExit exception would still work. --David On Sat, Mar 24, 2012 at 6:47 AM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > > I don't see why this should be considered acceptable behavior. Why > > don't threads have their own ThreadExit exception, rather than > > overloading the use, and therefore, the meaning, of the SystemExit > > exception? As indicated by their names, sys.exit and the SystemExit > > exception should *only* be used to exit the entire system, not just a > > thread! > > I agree the situation isn't optimal. However, fixing this would also break > compatibility with any application that uses sys.exit() in a thread and > expects it to exit the thread, not the whole process. So we're kind of > stuck with it. > > -- > nosy: +pitrou > > ___ > Python tracker > <http://bugs.python.org/issue6634> > ___ > -- ___ Python tracker <http://bugs.python.org/issue6634> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26751] Possible bug in sorting algorithm
New submission from David Manowitz: I'm trying to sort a list of tuples. Most of the tuples are pairs of US state names. However, some of the tuples have None instead of the 2nd name. I want the items sorted first by the 1st element, and then by the 2nd element, BUT I want the None to count as LARGER than any name. Thus, I want to see [('Alabama', 'Iowa'), ('Alabama', None)] rather than [('Alabama', None), ('Alabama', 'Iowa')]. I defined the following comparitor: def cmp_keys (k1, k2): retval = cmp(k1[0], k2[0]) if retval == 0: if k2[1] is None: retval = -1 if k1[1] is None: retval = 1 else: retval = cmp(k1[1], k2[1]) return retval However, once I sort using this, some of the elements are out of order. -- components: Interpreter Core messages: 263367 nosy: David.Manowitz priority: normal severity: normal status: open title: Possible bug in sorting algorithm type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue26751> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com