Opened 10 years ago
Closed 10 years ago
#22780 closed Bug (fixed)
LOCALE_PATHS should be a tuple
Reported by: | Tim Shaffer | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I was trying to track down why my project was not auto-reloading when files were changed using the dev server.
Turns out, it was an improperly configured LOCALE_PATHS setting. My LOCALE_PATHS was configured like this:
LOCALE_PATHS = ( '/path/to/locale' )
Which is actually a string and not a tuple since it does not have a trailing comma. This causes a problem in the autoloader, here:
https://github.com/django/django/blob/master/django/utils/autoreload.py#L98
Since LOCALE_PATHS is a string, calling basedirs.extend(LOCALE_PATHS) actually causes every character in the string to get appended to basedirs. Then it walks through the tree and tries to find .mo files. And since there are 3 slashes in the string, the autoloader attempts to search the root drive 3 times.
Bottom line is that having LOCALE_PATHS set to a string with slashes causes autoreloading to silently stop working while it attempts to search the entire root drive.
This patch adds LOCALE_PATHS to the list of tuple_settings which checks to make sure it's a tuple.
Attachments (2)
Change History (5)
by , 10 years ago
Attachment: | ticket_22780.diff added |
---|
comment:1 by , 10 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 10 years ago
Attachment: | ticket_22780_test.diff added |
---|
comment:2 by , 10 years ago
I didn't see a test for either of the two other settings that were in the tuple_settings list, so I created a new test case in settings_tests.
Should be trivial to duplicate this test to make it work for the other 2 settings as well. I can go ahead and do that too if it's necessary.
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Needs a test.