Opened 10 years ago

Closed 10 years ago

#3625 closed (fixed)

Test fixtures cause load_data to fail with Python 2.3

Reported by: ned.phillips@… Owned by: Adrian Holovaty
Component: Testing framework Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Database sync (sqlite) fails when trying to load initial data (in this case there is none). The error appears to stem from rsplit which is used in source:trunk/django/core/management.py and was introduced in [4659] with the test fixtures framework. I'm using the stock OS X Python (2.3.5) over here and I believe this function was introduced in 2.4.

Error:

Loading 'initial_data' fixtures...
Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/django/core/management.py", line 1663, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/django/core/management.py", line 1562, in execute_from_command_line
    action_mapping[action](int(options.verbosity), options.interactive)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/django/core/management.py", line 590, in syncdb
    load_data(['initial_data'], verbosity=verbosity)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/django/core/management.py", line 1358, in load_data
    fixture_name, format = fixture_label.rsplit('.', 1)
AttributeError: 'str' object has no attribute 'rsplit'

Attachments (1)

management-rsplit-python23.diff (744 bytes) - added by Antti Kaihola 10 years ago.
work around rsplit

Download all attachments as: .zip

Change History (9)

comment:1 Changed 10 years ago by Gary Wilson <gary.wilson@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 10 years ago by Antti Kaihola

work around rsplit

comment:2 Changed 10 years ago by Antti Kaihola

Has patch: set

I added a patch for this problem. I tested it just with a syncdb on a fairly complex database on Python 2.5, and also verified that my rsplit replacement works correctly at least for cases like "a", "a.b", "a.b.c" etc.

comment:3 Changed 10 years ago by Simon G. <dev@…>

Component: UncategorizedUnit test system
Owner: changed from Jacob to Adrian Holovaty
Triage Stage: AcceptedReady for checkin

comment:4 Changed 10 years ago by Chris Heisel

Any update on when this patch might get committed -- we're unfortunately stuck on RHEL 4.x and RH won't honor support contracts if you install Python 2.4, even in a sandbox/separate path?

comment:5 Changed 10 years ago by Chris Beaven

Hi Chris, you'd get a better response asking this question in the developer group.

comment:6 Changed 10 years ago by Malcolm Tredinnick

The patch as written did not pass all the tests under python 2.4. So I'm checking in a modified version that seems to do the right thing. Can somebody with ready access to python2.3 please check that this fixes the problem (in particular, all the tests should still pass). If it passes under 2.3, we can mark this as fixed.

comment:7 Changed 10 years ago by Malcolm Tredinnick

(In [4671]) Removed rsplit() usage for python2.3 compatibility. Refs #3625.

comment:8 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

Apparently if you want something tested you have to do it yourself, despite all the people who were apparently affected by this. :-(

I built Python 2.3 and database wrappers and it seems the rsplit() problem is gone. Some tests still fail under python2.3, but I don't believe it's related to this bug.

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