[Django] #21509: XML assertions suppress KeyboardInterrupt and SystemExit

7 views
Skip to first unread message

Django

unread,
Nov 25, 2013, 8:13:38 AM11/25/13
to django-...@googlegroups.com
#21509: XML assertions suppress KeyboardInterrupt and SystemExit
--------------------------------------+--------------------
Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+--------------------
In `assertXMLEqual` and `assertXMLNotEqual` methods, test result is
determined as following:

{{{#!python
try:
result = compare_xml(xml1, xml2)
except Exception as e:
standardMsg = 'First or second argument is not valid XML\n%s' % e
self.fail(self._formatMessage(msg, standardMsg))
}}}

Because of that, KeyboardInterrupt and SystemExit raised during XML
comparison are suppressed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21509>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 25, 2013, 8:18:42 AM11/25/13
to django-...@googlegroups.com
#21509: XML assertions suppress KeyboardInterrupt and SystemExit
-------------------------------------+-------------------------------------
Reporter: KJ | Owner: KJ
Type: | Status: new
Cleanup/optimization | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by KJ):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


Comment:

I’ve created a pull request: https://github.com/django/django/pull/1992

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:1>

Django

unread,
Nov 25, 2013, 8:22:27 AM11/25/13
to django-...@googlegroups.com
#21509: XML assertions suppress KeyboardInterrupt and SystemExit
-------------------------------------+-------------------------------------
Reporter: KJ | Owner: KJ
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Testing framework | Resolution: invalid

Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* status: new => closed
* resolution: => invalid


Comment:

Hi,

`KeyboardInterrupt` and `SystemExit` are not caught by an `except
Exception` clause (that's because they inherit from `BaseException`):
{{{#!python
>>> issubclass(SystemExit, Exception)
False
>>> issubclassKeyboardInterrupt, Exception)
False
}}}

The code change you proposed would have no effect.

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:2>

Django

unread,
Nov 25, 2013, 8:36:39 AM11/25/13
to django-...@googlegroups.com
#21509: XML assertions suppress KeyboardInterrupt and SystemExit
-------------------------------------+-------------------------------------
Reporter: KJ | Owner: KJ
Type: | Status: new

Cleanup/optimization | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by KJ):

* status: closed => new
* resolution: invalid =>


Comment:

Indeed, I was misleaded, by this legacy code:
https://github.com/django/django/blob/3c10d1e64faeb67b41e7aa501b21252e357a4564/django/test/testcases.py#L178
. Since we don’t support Python 2.4 and lower anymore, such parts of code
can be removed, so I’m reopening the ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:3>

Django

unread,
Nov 25, 2013, 8:43:41 AM11/25/13
to django-...@googlegroups.com
#21509: Remove explicit catching of SystemExit or Keboardinterrupt
--------------------------------------+------------------------------------

Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by bmispelon):

* has_patch: 1 => 0
* stage: Unreviewed => Accepted
* component: Testing framework => Uncategorized


Comment:

Indeed, that is not necessary anymore. Good catch.

A cleanup of the whole codebase to remove this outdated pattern would be
nice.

I'm accepting the ticket on this basis (and changing the description
accordingly).

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:4>

Django

unread,
Nov 25, 2013, 9:59:49 AM11/25/13
to django-...@googlegroups.com
#21509: Remove explicit catching of SystemExit or Keboardinterrupt
--------------------------------------+------------------------------------
Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by KJ):

* has_patch: 0 => 1


Comment:

Ok, I’ve opened another pull request:
https://github.com/django/django/pull/1993 . I’ve grepped the whole
codebase, but found this pattern only in one file.

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:5>

Django

unread,
Nov 25, 2013, 10:32:06 AM11/25/13
to django-...@googlegroups.com
#21509: Remove explicit catching of SystemExit or Keboardinterrupt
--------------------------------------+------------------------------------
Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: closed
Component: Uncategorized | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Baptiste Mispelon <bmispelon@…>):

* status: new => closed

* resolution: => fixed


Comment:

In [changeset:"7a0a3a64a827480c737060bcd5af9af25c3b3c15"]:
{{{
#!CommitTicketReference repository=""
revision="7a0a3a64a827480c737060bcd5af9af25c3b3c15"
Fixed #21509 -- Removed dead exception catching code.

Since Python 2.5, KeyboardInterrupt and SystemExit are not subclasses of
Exception, so explicitly reraising them before the “except Exception”
clause
is not necessary anymore.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:6>

Django

unread,
Feb 27, 2014, 9:55:46 PM2/27/14
to django-...@googlegroups.com
#21509: Remove explicit catching of SystemExit or Keboardinterrupt
--------------------------------------+------------------------------------
Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: closed
Component: Uncategorized | Version: 1.5

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by qBCgQNkl):

* version: master => 1.5


Comment:

<a href=http://www.andresramirezgaviria.com/file/#o0c0>provigil 200</a>
provigil 100mg side effects - provigil generic release date

--
Ticket URL: <https://code.djangoproject.com/ticket/21509#comment:7>

Django

unread,
Feb 28, 2014, 3:59:17 AM2/28/14
to django-...@googlegroups.com
#21509: Remove explicit catching of SystemExit or Keboardinterrupt
--------------------------------------+------------------------------------
Reporter: KJ | Owner: KJ
Type: Cleanup/optimization | Status: closed
Component: Uncategorized | Version: 1.5-rc-1

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by kLcYkken):

* version: master => 1.5-rc-1


Comment:

<a href=http://www.andresramirezgaviria.com/file/#o0c0>Learn More</a> buy
provigil - provigil medication

Reply all
Reply to author
Forward
0 new messages