[Django] #24978: Can't load fixtures with '[' and ']' in path

8 views
Skip to first unread message

Django

unread,
Jun 12, 2015, 4:10:26 PM6/12/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------+-------------------------------------------------
Reporter: mkow | Owner: nobody
Type: Bug | Status: new
Component: Testing | Version: 1.8
framework | Keywords: square brackets fixture path not
Severity: Normal | found
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 1 | UI/UX: 0
-------------------------+-------------------------------------------------
It's not possible to load a fixture from a path containing `[` or `]`. The
problem is in `django/core/management/commands/loaddata.py:206`
{{{
for candidate in glob.iglob(os.path.join(fixture_dir, fixture_name +
'*')):
}}}
fixture_dir and fixture_name should be escaped prior to passing it to
iglob(), because it interprets some characters as wildcards (see
[https://docs.python.org/2/library/glob.html]).

Note that square brackets are valid characters in filenames in majority of
filesystems (including ext and ntfs).

Steps to reproduce:
Set FIXTURE_DIRS in settings.py to anything containing square brackets,
e.g. `/home/user/test[123]`. Try to load any fixture from that directory
in your tests.py. It won't find it and will print a warning: `No fixture
named 'your_fixture_name' found.`

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

Django

unread,
Jun 12, 2015, 5:38:41 PM6/12/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------

Reporter: mkow | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* component: Testing framework => Core (Management commands)
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

Indeed, I can reproduce that issue.
Python 3.4 gained a `glob.escape` function that we'll probably want to
backport in some way:
https://docs.python.org/3/library/glob.html#glob.escape.


Thanks

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

Django

unread,
Jun 13, 2015, 6:29:13 AM6/13/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: assigned

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MoritzS):

* owner: nobody => MoritzS
* status: new => assigned
* has_patch: 0 => 1


Comment:

Added PR.

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

Django

unread,
Jun 13, 2015, 7:46:21 PM6/13/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: closed

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: fixed

Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"98df288ddaba9787e4a370f12aba51c2b9133142" 98df288]:
{{{
#!CommitTicketReference repository=""
revision="98df288ddaba9787e4a370f12aba51c2b9133142"
Fixed #24978 -- Escaped special characters in loaddata fixture paths
}}}

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

Django

unread,
Jun 13, 2015, 7:56:40 PM6/13/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: new

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>
* easy: 1 => 0


Comment:

Sorry, but the new test doesn't pass on Windows. Are you able to
investigate?

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

Django

unread,
Jun 17, 2015, 10:22:30 AM6/17/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: new

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"81aae2884377ff1a60b74e510e3358738971bbc0" 81aae28]:
{{{
#!CommitTicketReference repository=""
revision="81aae2884377ff1a60b74e510e3358738971bbc0"
Refs #24978 -- Skipped an unsupported test on Windows.
}}}

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

Django

unread,
Jun 17, 2015, 10:22:39 AM6/17/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: closed

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: fixed

Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


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

Django

unread,
Jun 20, 2015, 9:45:12 AM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: fixed
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gagaro):

"?" and "*" are invalid characters on Windows and thus the
"fixture?with[special]chars*.json" file cannot be created and cause issue
when cloning the repository.

Should I create a new ticket or reopen this one ?

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

Django

unread,
Jun 20, 2015, 9:49:45 AM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: fixed
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bmispelon):

Replying to [comment:7 Gagaro]:


> Should I create a new ticket or reopen this one ?

I would open a new one.

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/24978#comment:8>

Django

unread,
Jun 20, 2015, 10:08:38 AM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: new

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


Comment:

The fix for this one hasn't been released, so it's fine to reopen. I had
just skipped the test on Windows, but I guess if we can find characters
that work as a regression test but keep Windows happy, that solution would
be fine as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/24978#comment:9>

Django

unread,
Jun 20, 2015, 1:14:01 PM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: new

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gagaro):

"[" and "]" are enough for the regression test and works on Windows. I did
the fix and the pull request is there:
https://github.com/django/django/pull/4898

This pull request should be squashed with the other fix to avoid having
the bad file in the repository at all.

--
Ticket URL: <https://code.djangoproject.com/ticket/24978#comment:10>

Django

unread,
Jun 20, 2015, 2:23:45 PM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: new

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8b7bd62ae52313dbe96f27f21fbd63f0dd061744" 8b7bd62]:
{{{
#!CommitTicketReference repository=""
revision="8b7bd62ae52313dbe96f27f21fbd63f0dd061744"
Refs #24978 -- Amended test filename to avoid checkout warnings on
Windows.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24978#comment:11>

Django

unread,
Jun 20, 2015, 2:27:23 PM6/20/15
to django-...@googlegroups.com
#24978: Can't load fixtures with '[' and ']' in path
-------------------------------------+-------------------------------------
Reporter: mkow | Owner: MoritzS
Type: Bug | Status: closed

Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: fixed

Keywords: square brackets | Triage Stage: Accepted
fixture path not found |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


--
Ticket URL: <https://code.djangoproject.com/ticket/24978#comment:12>

Reply all
Reply to author
Forward
0 new messages