[Django] #25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'

35 views
Skip to first unread message

Django

unread,
Dec 3, 2015, 6:14:30 PM12/3/15
to django-...@googlegroups.com
#25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'
------------------------------+--------------------
Reporter: codingjoe | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------
I don't really want to bug anyone with python 2.7, for I couldn't care
less. But, I stumbled upon something rather odd.

Easiest is to just check out the error on travis including the stack
trace:
https://travis-ci.org/codingjoe/django-stdimage/builds/94713726

Everything works fine in Python 3, the attribute is available, as it
should. It it's an instance attribute and properly set in the `__init__`
method:
https://github.com/django/django/blob/master/django/core/files/storage.py#L169-L172

I guess the error is here:
https://github.com/django/django/blob/master/django/utils/_os.py#L24-L32

I'm not sure tho, because the method must return at least `None`,
therefore I don't see how the attribute error is being raised.

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

Django

unread,
Dec 4, 2015, 3:19:45 AM12/4/15
to django-...@googlegroups.com
#25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'
------------------------------+--------------------------------------
Reporter: codingjoe | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

Creating a storage instance as a function parameter ((`DefaultStorage()`
for render_variations) looks a bit suspicious to me. I'm not convinced the
problem is on Django's side.

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

Django

unread,
Dec 4, 2015, 4:18:29 AM12/4/15
to django-...@googlegroups.com
#25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'
------------------------------+--------------------------------------
Reporter: codingjoe | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by codingjoe):

Let me try to convince you then. I just [changed](https://travis-
ci.org/codingjoe/django-stdimage/jobs/94828152) it to the
[documented](https://docs.djangoproject.com/en/1.8/topics/files/#storage-
objects) `default_storage` helper, which is nothing other than
`DefaultStorage()`.

I also just added a little test, that tests only storage.location. That
works, that doesn't mean there isn't a problem tho.
See the tests don't even execute the case with a default storage.
It uses the `FieldFile`'s storage.

Besides all that, I don't do any wizardry with the storages, nor in the
settings. It must strike you, that there is a different behavior on python
2.7 and 3.*

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

Django

unread,
Dec 4, 2015, 5:11:21 AM12/4/15
to django-...@googlegroups.com
#25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'
------------------------------+--------------------------------------
Reporter: codingjoe | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* resolution: worksforme => fixed


Comment:

I found the bug. It's the lazy object implementation of the default
storage. It doesn't work in python 2 using multiprocessing.

This little snippet allows to produce the error.
{{{
def has_location(storage):
return hasattr(storage, 'location')


def test_multiprocessing_lazy_objects(image_upload_file):
SimpleModel.objects.create(image=image_upload_file)
obj = SimpleModel.objects.last()
storage = obj.image.storage

p = Pool(2)
assert all(p.map(has_location, [default_storage, storage]))
}}}

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

Django

unread,
Dec 4, 2015, 5:11:39 AM12/4/15
to django-...@googlegroups.com
#25862: AttributeError: 'FileSystemStorage' object has no attribute 'location'
------------------------------+--------------------------------------

Reporter: codingjoe | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


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

Django

unread,
Dec 5, 2015, 8:13:59 AM12/5/15
to django-...@googlegroups.com
#25862: LazyObject doesn't support multiprocessing on Python 2
------------------------------+------------------------------------

Reporter: codingjoe | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* stage: Unreviewed => Accepted


Old description:

> I don't really want to bug anyone with python 2.7, for I couldn't care
> less. But, I stumbled upon something rather odd.
>
> Easiest is to just check out the error on travis including the stack
> trace:
> https://travis-ci.org/codingjoe/django-stdimage/builds/94713726
>
> Everything works fine in Python 3, the attribute is available, as it
> should. It it's an instance attribute and properly set in the `__init__`
> method:
> https://github.com/django/django/blob/master/django/core/files/storage.py#L169-L172
>
> I guess the error is here:
> https://github.com/django/django/blob/master/django/utils/_os.py#L24-L32
>
> I'm not sure tho, because the method must return at least `None`,
> therefore I don't see how the attribute error is being raised.

New description:

**Initial summary: AttributeError: 'FileSystemStorage' object has no
attribute 'location'**

I don't really want to bug anyone with python 2.7, for I couldn't care
less. But, I stumbled upon something rather odd.

Easiest is to just check out the error on travis including the stack
trace:
https://travis-ci.org/codingjoe/django-stdimage/builds/94713726

Everything works fine in Python 3, the attribute is available, as it
should. It it's an instance attribute and properly set in the `__init__`
method:
https://github.com/django/django/blob/master/django/core/files/storage.py#L169-L172

I'm not sure tho, because the method must return at least `None`,
therefore I don't see how the attribute error is being raised.

--

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

Django

unread,
May 30, 2016, 2:27:16 PM5/30/16
to django-...@googlegroups.com
#25862: LazyObject doesn't support multiprocessing on Python 2
------------------------------+------------------------------------
Reporter: codingjoe | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: py2 | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* keywords: => py2


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

Django

unread,
Dec 22, 2016, 9:25:29 AM12/22/16
to django-...@googlegroups.com
#25862: LazyObject doesn't support multiprocessing on Python 2
--------------------------------+------------------------------------
Reporter: Johannes Hoppe | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: wontfix

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

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Changes (by Tim Graham):

* status: new => closed

* resolution: => wontfix


Comment:

Doesn't look like anyone will tackle this before we drop Python 2.

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

Reply all
Reply to author
Forward
0 new messages