{"action":"created","issue":{"url":"https://api.github.com/repos/wagtail/wagtail/issues/4980","repository_url":"https://api.github.com/repos/wagtail/wagtail","labels_url":"https://api.github.com/repos/wagtail/wagtail/issues/4980/labels{/name}","comments_url":"https://api.github.com/repos/wagtail/wagtail/issues/4980/comments","events_url":"https://api.github.com/repos/wagtail/wagtail/issues/4980/events","html_url":"https://github.com/wagtail/wagtail/issues/4980","id":395949039,"node_id":"MDU6SXNzdWUzOTU5NDkwMzk=","number":4980,"title":"Failing attempt to replace image ","user":{"login":"imanhodjaev","id":354868,"node_id":"MDQ6VXNlcjM1NDg2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/354868?v=4","gravatar_id":"","url":"https://api.github.com/users/imanhodjaev","html_url":"https://github.com/imanhodjaev","followers_url":"https://api.github.com/users/imanhodjaev/followers","following_url":"https://api.github.com/users/imanhodjaev/following{/other_user}","gists_url":"https://api.github.com/users/imanhodjaev/gists{/gist_id}","starred_url":"https://api.github.com/users/imanhodjaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imanhodjaev/subscriptions","organizations_url":"https://api.github.com/users/imanhodjaev/orgs","repos_url":"https://api.github.com/users/imanhodjaev/repos","events_url":"https://api.github.com/users/imanhodjaev/events{/privacy}","received_events_url":"https://api.github.com/users/imanhodjaev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-01-04T14:43:20Z","updated_at":"2019-01-04T15:10:56Z","closed_at":null,"author_association":"NONE","body":"### Issue Summary\r\nProblem occurs when replacing images, sometimes Wagtail admin seems to upload an image and very often fail w/ the following exception, is there anything to configure or do properly when replacing images?\r\n\r\n```\r\nValueError: I/O operation on closed file.\r\nERROR 2019-01-04 10:15:22,366 log 36751 123145484890112 Internal Server Error: /admin/images/1/\r\nTraceback (most recent call last):\r\n```\r\n\r\n\r\n### Steps to Reproduce\r\n\r\n1. `wagtail start myproject`\r\n2. Upload an image\r\n3. Try to replace image with new one\r\n\r\nI've been also trying to debug it and at the moment looking at https://github.com/wagtail/wagtail/blob/master/wagtail/images/views/images.py#L101\r\nJust before `form.is_valid()` `form.image.file` is not seekable. After setting breakpoints and debugging I tried to call `form.is_valid()` twice and on second call it was `True`.\r\n\r\n### Technical details\r\n\r\n* Python version: 3.6.7,\r\n* Wagtail version: 2.4.0,\r\n* Django version: 2.1.4,\r\n* Chrome: 71,\r\n* OS: MacOS.\r\n\r\n\r\nFull exception\r\n\r\n```\r\n[04/Jan/2019 14:33:22] \"POST /admin/images/1/ HTTP/1.1\" 500 157806\r\n[04/Jan/2019 14:33:23] \"GET /admin/images/1/ HTTP/1.1\" 200 14585\r\nInternal Server Error: /admin/images/1/\r\nTraceback (most recent call last):\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/handlers/exception.py\", line 34, in inner\r\n    response = get_response(request)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/handlers/base.py\", line 126, in _get_response\r\n    response = self.process_exception_by_middleware(e, request)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/handlers/base.py\", line 124, in _get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/views/decorators/cache.py\", line 44, in _wrapped_view_func\r\n    response = view_func(request, *args, **kwargs)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/wagtail/admin/urls/__init__.py\", line 102, in wrapper\r\n    return view_func(request, *args, **kwargs)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/wagtail/admin/decorators.py\", line 34, in decorated_view\r\n    return view_func(request, *args, **kwargs)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/wagtail/admin/utils.py\", line 148, in wrapped_view_func\r\n    return view_func(request, *args, **kwargs)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/wagtail/images/views/images.py\", line 101, in edit\r\n    if form.is_valid():\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/forms/forms.py\", line 185, in is_valid\r\n    return self.is_bound and not self.errors\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/forms/forms.py\", line 180, in errors\r\n    self.full_clean()\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/forms/forms.py\", line 383, in full_clean\r\n    self._post_clean()\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/forms/models.py\", line 398, in _post_clean\r\n    self.instance = construct_instance(self, self.instance, opts.fields, opts.exclude)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/forms/models.py\", line 63, in construct_instance\r\n    f.save_form_data(instance, cleaned_data[f.name])\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/db/models/fields/files.py\", line 317, in save_form_data\r\n    setattr(instance, self.name, data or '')\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/db/models/fields/files.py\", line 346, in __set__\r\n    self.field.update_dimension_fields(instance, force=True)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/db/models/fields/files.py\", line 449, in update_dimension_fields\r\n    width = file.width\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/files/images.py\", line 19, in width\r\n    return self._get_image_dimensions()[0]\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/files/images.py\", line 29, in _get_image_dimensions\r\n    self._dimensions_cache = get_image_dimensions(self, close=close)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/django/core/files/images.py\", line 59, in get_image_dimensions\r\n    p.feed(data)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/PIL/ImageFile.py\", line 399, in feed\r\n    im = Image.open(fp)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/PIL/Image.py\", line 2672, in open\r\n    im = _open_core(fp, filename, prefix)\r\n  File \"Envs/publizist-V24PH7XT/lib/python3.6/site-packages/PIL/Image.py\", line 2657, in _open_core\r\n    fp.seek(0)\r\nValueError: I/O operation on closed file.\r\n```"},"comment":{"url":"https://api.github.com/repos/wagtail/wagtail/issues/comments/451470203","html_url":"https://github.com/wagtail/wagtail/issues/4980#issuecomment-451470203","issue_url":"https://api.github.com/repos/wagtail/wagtail/issues/4980","id":451470203,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTQ3MDIwMw==","user":{"login":"imanhodjaev","id":354868,"node_id":"MDQ6VXNlcjM1NDg2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/354868?v=4","gravatar_id":"","url":"https://api.github.com/users/imanhodjaev","html_url":"https://github.com/imanhodjaev","followers_url":"https://api.github.com/users/imanhodjaev/followers","following_url":"https://api.github.com/users/imanhodjaev/following{/other_user}","gists_url":"https://api.github.com/users/imanhodjaev/gists{/gist_id}","starred_url":"https://api.github.com/users/imanhodjaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imanhodjaev/subscriptions","organizations_url":"https://api.github.com/users/imanhodjaev/orgs","repos_url":"https://api.github.com/users/imanhodjaev/repos","events_url":"https://api.github.com/users/imanhodjaev/events{/privacy}","received_events_url":"https://api.github.com/users/imanhodjaev/received_events","type":"User","site_admin":false},"created_at":"2019-01-04T15:10:56Z","updated_at":"2019-01-04T15:10:56Z","author_association":"NONE","body":"Found out that the issue only comes in Wagtail 2.4.0"}}
{"actor":{"display_login":"imanhodjaev"}}