mirror of https://github.com/django/django.git
Refs #32355 -- Corrected comments about Python's _NamespacePath.
_NamespacePath supports indexing in Python 3.8+.
This commit is contained in:
parent
509d266c6a
commit
cecdec91cf
|
@ -73,8 +73,7 @@ class AppConfig:
|
||||||
"""Attempt to determine app's filesystem path from its module."""
|
"""Attempt to determine app's filesystem path from its module."""
|
||||||
# See #21874 for extended discussion of the behavior of this method in
|
# See #21874 for extended discussion of the behavior of this method in
|
||||||
# various cases.
|
# various cases.
|
||||||
# Convert paths to list because Python's _NamespacePath doesn't support
|
# Convert to list because __path__ may not support indexing.
|
||||||
# indexing.
|
|
||||||
paths = list(getattr(module, '__path__', []))
|
paths = list(getattr(module, '__path__', []))
|
||||||
if len(paths) != 1:
|
if len(paths) != 1:
|
||||||
filename = getattr(module, '__file__', None)
|
filename = getattr(module, '__file__', None)
|
||||||
|
|
|
@ -85,7 +85,7 @@ def module_dir(module):
|
||||||
Raise ValueError otherwise, e.g. for namespace packages that are split
|
Raise ValueError otherwise, e.g. for namespace packages that are split
|
||||||
over several directories.
|
over several directories.
|
||||||
"""
|
"""
|
||||||
# Convert to list because _NamespacePath does not support indexing.
|
# Convert to list because __path__ may not support indexing.
|
||||||
paths = list(getattr(module, '__path__', []))
|
paths = list(getattr(module, '__path__', []))
|
||||||
if len(paths) == 1:
|
if len(paths) == 1:
|
||||||
return paths[0]
|
return paths[0]
|
||||||
|
|
Loading…
Reference in New Issue