Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BufferedFile should have a 'closed' propery #80

smunaut opened this issue Sep 10, 2012 · 2 comments

BufferedFile should have a 'closed' propery #80

smunaut opened this issue Sep 10, 2012 · 2 comments


Copy link

smunaut commented Sep 10, 2012

The Python file interface seems to publically define a xxx.closed property and some application use it.
Currently there is an internal _closed propery and just exposing it read-only works:

def closed(self):
    return self._closed
Copy link

Bockit commented Oct 17, 2012

I ran into this problem today when running django's collectstatic function with the SFTP backend and some Pipeline'd files.

Traceback (most recent call last):
  File "./", line 10, in <module>
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/", line 443, in execute_from_command_line
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/", line 382, in execute
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 163, in handle_noargs
    collected = self.collect()
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 120, in collect
    for original_path, processed_path, processed in processor:
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/", line 239, in post_process
    saved_name = self._save(hashed_name, original_file)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/storages/backends/", line 167, in _save
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/files/", line 111, in open
    if not self.closed:
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/files/", line 51, in _get_closed
    return not self.file or self.file.closed
AttributeError: 'SFTPFile' object has no attribute 'closed'

I eventually tracked it down to this issue (BufferedFile needing a closed property) and had the same solution as suggested.

Copy link

Thanks to both of you, this fix works for now. (Reckon eventually we'll want to simply make the "private" var public.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants