[Django] #30908: FilePathField doc & field scan dir issue

44 views
Skip to first unread message

Django

unread,
Oct 24, 2019, 12:14:40 PM10/24/19
to django-...@googlegroups.com
#30908: FilePathField doc & field scan dir issue
-----------------------------------------+------------------------
Reporter: jheld | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The docs around the model of FilePathField show the path as being default
None, while the code is empty string.

Also, due to a change in 2.2 around using scandir on the form field for
FilePathField, if the path doesn't exist, a FileNotFoundError is issued
(same would have happened before the scandir change), but now the
try/except logic on OSError (super class) has been removed, in the PR that
changed to scandir.

So, the docs are out of date (regardless of whichever value is more sane
as a default), and the change on scandir also removed the try/except.

Previously it was not an issue because there was a try/except, so we were
caught off guard.

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

Django

unread,
Oct 25, 2019, 4:52:26 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

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

* severity: Normal => Release blocker
* component: Uncategorized => Forms
* easy: 0 => 1
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Thanks for this report, I agree that it's a regression in
a0ca4b5694f43c63ea13ba6908eff2bd53ee7ebb. We should restore catching
`OSError`. Documentation issue is not a regression so I sent a separate
[https://github.com/django/django/pull/11974 PR] with fix.

Reproduced at fc2b1cc926e34041953738e58fa6ad3053059b22.

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

Django

unread,
Oct 25, 2019, 4:53:07 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):

* Attachment "test-30908.diff" added.

Regression test.

Django

unread,
Oct 25, 2019, 4:54:33 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):

* Attachment "test-30908.diff" added.

Regression test.

--

Django

unread,
Oct 25, 2019, 5:22:52 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"daa9415f78279855808134e1f40766f6c5f4bdbc" daa9415f]:
{{{
#!CommitTicketReference repository=""
revision="daa9415f78279855808134e1f40766f6c5f4bdbc"
Refs #30908 -- Fixed the empty value of forms.FilePathField in docs.
}}}

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

Django

unread,
Oct 25, 2019, 5:23:52 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"76964cce206a0d709d874ea8f36c12f9f1d500e6" 76964cc]:
{{{
#!CommitTicketReference repository=""
revision="76964cce206a0d709d874ea8f36c12f9f1d500e6"
[3.0.x] Refs #30908 -- Fixed the empty value of forms.FilePathField in
docs.

Backport of daa9415f78279855808134e1f40766f6c5f4bdbc from master
}}}

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

Django

unread,
Oct 25, 2019, 5:24:17 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
---------------------------------+------------------------------------
Reporter: jheld | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"48df40262bb13ff923dcbafc2bc70af12fe9db47" 48df402]:
{{{
#!CommitTicketReference repository=""
revision="48df40262bb13ff923dcbafc2bc70af12fe9db47"
[2.2.x] Refs #30908 -- Fixed the empty value of forms.FilePathField in
docs.

Backport of daa9415f78279855808134e1f40766f6c5f4bdbc from master
}}}

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

Django

unread,
Oct 25, 2019, 8:56:34 AM10/25/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
-------------------------------------+-------------------------------------
Reporter: Jason Held | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned

Component: Forms | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* status: new => assigned
* owner: nobody => Hasan Ramezani


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

Django

unread,
Oct 28, 2019, 4:35:29 AM10/28/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
----------------------------+------------------------------------------

Reporter: Jason Held | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted

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

* status: assigned => closed
* resolution: => wontfix
* severity: Release blocker => Normal


Comment:

Sorry for the previous acceptance, but it is
[https://docs.djangoproject.com/en/2.2/ref/forms/fields/#django.forms.FilePathField.path
documented] from the very beginning that `"This directory must exist"`
(see 4457ba002d64d4a991b0561c5be69a8c61b2b828). We removed catching
`OSError` in Django 2.2, but it was untested and undocumented behavior.

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

Django

unread,
Oct 28, 2019, 4:41:08 AM10/28/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
----------------------------+------------------------------------------
Reporter: Jason Held | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------------

Comment (by Hasan Ramezani):

Would it be good to add a test case for `OSError`?

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

Django

unread,
Oct 29, 2019, 3:41:48 AM10/29/19
to django-...@googlegroups.com
#30908: FilePathField raises FileNotFoundError for nonexistent path.
----------------------------+------------------------------------------
Reporter: Jason Held | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"6c6d24a4feb632fc07d35c2ce23bb00f6ea9215c" 6c6d24a4]:
{{{
#!CommitTicketReference repository=""
revision="6c6d24a4feb632fc07d35c2ce23bb00f6ea9215c"
Refs #30908 -- Added test for nonexistent path in forms.FilePathField.
}}}

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

Reply all
Reply to author
Forward
0 new messages