[Django] #27230: Inconsistency in AppConfig.path

10 views
Skip to first unread message

Django

unread,
Sep 15, 2016, 4:35:54 PM9/15/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path
--------------------------------+--------------------
Reporter: vinayinvicible | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------
Consider the following project structure
{{{
root/
app1/
__init__.py
...
app2/
__init__.py
...
project/
__init__.py
settings.py
urls.py
wsgi.py
manage.py
script.py
}}}

content of script.py is
{{{
#!python
import os
import sys

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")

import django
django.setup()

from django.apps import apps


for app in apps.get_app_configs():
print app.path
}}}


If I run `python script.py`, output will be
{{{
$ python script.py
....
/<project_path>/root/app1
/<project_path>/root/app2
}}}

If I run `ipython script.py`, output is
{{{
$ ipython script.py
....
app1
app2
}}}

Ipython inserts !'' as the first entry in sys.path which results in path
for project apps being relative path.
This in turn is making the output of
`django.template.utils.get_app_template_dirs` inconsistent.

I faced this issue with python 2.7.11+
This is not an issue with python 2.7.12. I think because of
[https://bugs.python.org/issue1739468 Patch #1739468]

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

Django

unread,
Sep 15, 2016, 4:48:56 PM9/15/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path
--------------------------------+--------------------------------------

Reporter: vinayinvicible | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

As per our [https://docs.djangoproject.com/en/dev/faq/install/#what-
python-version-can-i-use-with-django support policy], "For each version of
Python, only the latest micro release (A.B.C) is officially supported." So
perhaps we can close the issue as wontfix unless there's some other
argument for making the change?

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

Django

unread,
Sep 15, 2016, 4:58:25 PM9/15/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by vinayinvicible):

Even with 2.7.12, `AppConfig.path` will return relative path if I do
`sys.path.insert(0, '')` inside script.py before `django.setup()`

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

Django

unread,
Sep 15, 2016, 8:30:32 PM9/15/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path depending on sys.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by timgraham):

* type: Uncategorized => Bug
* component: Uncategorized => Core (Other)


Comment:

Not sure about this right now, but tests aren't passing with the
[https://github.com/django/django/pull/7251 PR].

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

Django

unread,
Sep 16, 2016, 3:14:15 AM9/16/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path depending on sys.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody

Type: Bug | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by aaugustin):

1. I'm wary of making this backwards-incompatible change.
2. I think you're hitting this issue because in one case an absolute
import is performed and in the other an implicit relative import. IIRC,
Python 3 no longer supports the latter, so the resolution is essentially
"fixed in Python 3"...

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

Django

unread,
Sep 16, 2016, 3:26:38 AM9/16/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path depending on sys.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody

Type: Bug | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by vinayinvicible):

I understand this wouldn't be an issue with python 3.
Shouldn't django handle this atleast until it supports python 2.

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

Django

unread,
Sep 16, 2016, 8:16:50 AM9/16/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path depending on sys.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody

Type: Bug | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by aaugustin):

Well, given that the issue doesn't exist in Python 3, is fixed in Django
2.7.12+, and that we're dropping support for Python 2 in six months:
https://www.djangoproject.com/weblog/2015/jun/25/roadmap/:

> Django 1.11 is likely to be the last version to support Python 2.7 as it
will be supported until the end of Python 2 upstream support in 2020.

absent other reasons, it doesn't seem reasonable to me to change the
return value of AppConfig.path from a relative to an absolute path, which
could cause issues with projects that use this value.

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

Django

unread,
Sep 16, 2016, 10:17:59 AM9/16/16
to django-...@googlegroups.com
#27230: Inconsistency in AppConfig.path depending on sys.path
--------------------------------+--------------------------------------
Reporter: vinayinvicible | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by timgraham):

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


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

Reply all
Reply to author
Forward
0 new messages