Opened 4 years ago

Closed 4 years ago

#15702 closed (fixed)

Drop 2.4 compatibility boilerplate code

Reported by: jonash Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: 2.4
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Here's a patch that removes some 2.4 compatibility boiler plate code. Mostly easy changes like removing/replacing imports.

Note that we can't drop django.utils.functional.curry entirely because functools.partial returns a non-function which can't be used as a proper method.

Attachments (1)

24boilerplate.patch (63.2 KB) - added by jonash 4 years ago.

Download all attachments as: .zip

Change History (10)

Changed 4 years ago by jonash

comment:1 Changed 4 years ago by jonash

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Forgot to mention that this passes all tests for me (using the SQLite backend configuration providedin test_sqlite.py).

Version 0, edited 4 years ago by jonash (next)

comment:2 Changed 4 years ago by russellm

  • Component changed from Uncategorized to Core framework
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Thanks for that.

One thing I've noticed from a quick inspection of the patch; you've removed the Python 2.4 compatibility stuff from django.utils.unittest. That module is a direct copy of the public unittest project, so we're not going to introduce any variations, even if they are surplus to our internal requirements.

There are also some tests for context managers that were added in 1.3 (for transaction context managers and the SQL statement counter in the test framework). These were conditionally included tests for Python 2.4; they now can be integrated into the main suite.

comment:3 Changed 4 years ago by adrian

In [15926]:

Removed a bunch of Python 2.4 workarounds now that we don't support it. Refs #15702 -- thanks to jonash for the patch. Splitting this over muliple commits to make it more manageable.

comment:4 Changed 4 years ago by adrian

In [15927]:

Removed a bunch more Python 2.4 workarounds now that we don't support that version. Refs #15702 -- thanks to jonash for the patch.

comment:5 Changed 4 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

This is fixed as of [15926] and [15927]. Note that I found four more uses of django.utils.hashcompat that weren't included in the patch. I also didn't touch the stuff in django.utils.unittest per Russell's comment. Thanks, jonash!

comment:6 Changed 4 years ago by mk

  • Resolution fixed deleted
  • Status changed from closed to reopened

There is a grave bug since r15927 in Django: The decorator in django/db/transaction.py is missing a return statement, which causes testsuites and everything decorated with any transaction decorator to fail, f.e. with a 'NoneType' object has no attribute 'set_cookie' error.

The fix is so simple that I won't attach a patch for it:

diff --git a/django/db/transaction.py b/django/db/transaction.py
index cf7350c..6cbe39f 100644
--- a/django/db/transaction.py
+++ b/django/db/transaction.py
@@ -207,7 +207,7 @@ class Transaction(object):
         @wraps(func)
         def inner(*args, **kwargs):
             with self:
-                func(*args, **kwargs)
+                return func(*args, **kwargs)
         return inner
 
 def _transaction_func(entering, exiting, using):

comment:7 Changed 4 years ago by mk

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to Ready for checkin

Not adding a test either -- the current test suite is sufficient for testing this particular piece of code. And it fails with current SVN trunk.

comment:8 Changed 4 years ago by mk

Sorry for the comment spam -- patch is already attached; the patch by jonash contains the return statement, the committed version does not.

comment:9 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

In [15937]:

Fixed #15702 -- Corrected problem in test suite introduced by Python 2.4 changes from r15927. Thanks to mk for the report and patch.

Note: See TracTickets for help on using tickets.
Back to Top