mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #27023 -- Prevented possibility of shell loading ~/.pythonrc.py twice.
This commit is contained in:
parent
3c20aa49d7
commit
e139ef5741
@ -2,6 +2,7 @@ import os
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.utils.datastructures import OrderedSet
|
||||||
from django.utils.deprecation import RemovedInDjango20Warning
|
from django.utils.deprecation import RemovedInDjango20Warning
|
||||||
|
|
||||||
|
|
||||||
@ -88,10 +89,9 @@ class Command(BaseCommand):
|
|||||||
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
|
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
|
||||||
# conventions and get $PYTHONSTARTUP first then .pythonrc.py.
|
# conventions and get $PYTHONSTARTUP first then .pythonrc.py.
|
||||||
if not options['no_startup']:
|
if not options['no_startup']:
|
||||||
for pythonrc in (os.environ.get("PYTHONSTARTUP"), '~/.pythonrc.py'):
|
for pythonrc in OrderedSet([os.environ.get("PYTHONSTARTUP"), os.path.expanduser('~/.pythonrc.py')]):
|
||||||
if not pythonrc:
|
if not pythonrc:
|
||||||
continue
|
continue
|
||||||
pythonrc = os.path.expanduser(pythonrc)
|
|
||||||
if not os.path.isfile(pythonrc):
|
if not os.path.isfile(pythonrc):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user