[Django] #30234: Disallow non-upper settings

7 views
Skip to first unread message

Django

unread,
Mar 3, 2019, 8:30:12 PM3/3/19
to django-...@googlegroups.com
#30234: Disallow non-upper settings
----------------------------------------+--------------------------
Reporter: orlnub123 | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Keywords: settings
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+--------------------------
Contradictory to the documentation, `settings.configure()` and
`UserSettingsHolder.__getattr__()` allow non-upper settings to be set and
retrieved, respectively. This allows for the following to happen:
{{{
import types
from django.conf import settings

settings.configure(types.SimpleNamespace(foo="bar"), baz="qux")
print(settings.foo, settings.baz) # Doesn't error
}}}

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

Django

unread,
Mar 4, 2019, 3:02:11 AM3/4/19
to django-...@googlegroups.com
#30234: Disallow non-upper settings
------------------------------+------------------------------------

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

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

* stage: Unreviewed => Accepted


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

Django

unread,
Mar 4, 2019, 6:01:08 AM3/4/19
to django-...@googlegroups.com
#30234: Disallow non-upper settings
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by orlnub123):

Just non-upper ones. Some components such as diffsettings or the debug
view rely on there only being uppercase settings.

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

Django

unread,
Mar 4, 2019, 6:45:05 PM3/4/19
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------

Reporter: orlnub123 | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

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

Django

unread,
Mar 5, 2019, 10:18:20 AM3/5/19
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody
Type: Bug | Status: closed

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

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

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


Comment:

In [changeset:"163236ea0e5df1a301371e79ec35fc67b7a1b7a6" 163236e]:
{{{
#!CommitTicketReference repository=""
revision="163236ea0e5df1a301371e79ec35fc67b7a1b7a6"
Fixed #30234 -- Disallowed non-upper settings in settings.configure().
}}}

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

Django

unread,
Jul 26, 2021, 11:20:28 PM7/26/21
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: dev

Severity: Normal | Resolution: fixed
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by k4ml):

The docs still showing example that using `_` in settings.py -
https://github.com/django/django/blob/7f33c1e22dbc34a7afae7967783725b10f1f13b1/docs/ref/settings.txt#L1951

And this check cause issue when third party app is calling
settings.configure():-

https://github.com/idlesign/pytest-
djangoapp/blob/master/pytest_djangoapp/plugin.py#L42

If this is no longer recommended practice, the docs above should be fixed
not to use `_` anymore in settings.py.

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

Django

unread,
Jul 26, 2021, 11:57:49 PM7/26/21
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:5 k4ml]:


> The docs still showing example that using `_` in settings.py -
https://github.com/django/django/blob/7f33c1e22dbc34a7afae7967783725b10f1f13b1/docs/ref/settings.txt#L1951
>
> And this check cause issue when third party app is calling
settings.configure():-
>
> https://github.com/idlesign/pytest-
djangoapp/blob/master/pytest_djangoapp/plugin.py#L42
>
> If this is no longer recommended practice, the docs above should be
fixed not to use `_` anymore in settings.py.

This ticket has nothing to do with using `_` in `settings.py`, it's about
non-uppercase setting names.

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

Django

unread,
Jul 27, 2021, 2:21:56 AM7/27/21
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by k4ml):

Replying to [comment:6 Mariusz Felisiak]:

> This ticket has nothing to do with using `_` in `settings.py`, it's
about non-uppercase setting names.

`_` failed `isupper()` check.

Btw the fix is simple actually, add:-

```
del _
```

at the end of settings.py. The localization docs should add this in notes.

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

Django

unread,
Jul 27, 2021, 2:48:22 AM7/27/21
to django-...@googlegroups.com
#30234: Disallow non-uppercase settings in settings.configure()
------------------------------+------------------------------------
Reporter: orlnub123 | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:7 k4ml]:


> Btw the fix is simple actually, add:-
>
>
> del _
>
> at the end of settings.py. The localization docs should add this in
notes.

It's not an issue in Django or its docs. It's an issue in
`pytest_djangoapp`. `_` is not a setting name and should not be passed to
the `.configure()`.

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

Reply all
Reply to author
Forward
0 new messages