Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/lib64/python3....
File: site.py
"""Append module search paths for third-party packages to sys.path.
[0] Fix | Delete
[1] Fix | Delete
****************************************************************
[2] Fix | Delete
* This module is automatically imported during initialization. *
[3] Fix | Delete
****************************************************************
[4] Fix | Delete
[5] Fix | Delete
This will append site-specific paths to the module search path. On
[6] Fix | Delete
Unix (including Mac OSX), it starts with sys.prefix and
[7] Fix | Delete
sys.exec_prefix (if different) and appends
[8] Fix | Delete
lib/python<version>/site-packages.
[9] Fix | Delete
On other platforms (such as Windows), it tries each of the
[10] Fix | Delete
prefixes directly, as well as with lib/site-packages appended. The
[11] Fix | Delete
resulting directories, if they exist, are appended to sys.path, and
[12] Fix | Delete
also inspected for path configuration files.
[13] Fix | Delete
[14] Fix | Delete
If a file named "pyvenv.cfg" exists one directory above sys.executable,
[15] Fix | Delete
sys.prefix and sys.exec_prefix are set to that directory and
[16] Fix | Delete
it is also checked for site-packages (sys.base_prefix and
[17] Fix | Delete
sys.base_exec_prefix will always be the "real" prefixes of the Python
[18] Fix | Delete
installation). If "pyvenv.cfg" (a bootstrap configuration file) contains
[19] Fix | Delete
the key "include-system-site-packages" set to anything other than "false"
[20] Fix | Delete
(case-insensitive), the system-level prefixes will still also be
[21] Fix | Delete
searched for site-packages; otherwise they won't.
[22] Fix | Delete
[23] Fix | Delete
All of the resulting site-specific directories, if they exist, are
[24] Fix | Delete
appended to sys.path, and also inspected for path configuration
[25] Fix | Delete
files.
[26] Fix | Delete
[27] Fix | Delete
A path configuration file is a file whose name has the form
[28] Fix | Delete
<package>.pth; its contents are additional directories (one per line)
[29] Fix | Delete
to be added to sys.path. Non-existing directories (or
[30] Fix | Delete
non-directories) are never added to sys.path; no directory is added to
[31] Fix | Delete
sys.path more than once. Blank lines and lines beginning with
[32] Fix | Delete
'#' are skipped. Lines starting with 'import' are executed.
[33] Fix | Delete
[34] Fix | Delete
For example, suppose sys.prefix and sys.exec_prefix are set to
[35] Fix | Delete
/usr/local and there is a directory /usr/local/lib/python2.5/site-packages
[36] Fix | Delete
with three subdirectories, foo, bar and spam, and two path
[37] Fix | Delete
configuration files, foo.pth and bar.pth. Assume foo.pth contains the
[38] Fix | Delete
following:
[39] Fix | Delete
[40] Fix | Delete
# foo package configuration
[41] Fix | Delete
foo
[42] Fix | Delete
bar
[43] Fix | Delete
bletch
[44] Fix | Delete
[45] Fix | Delete
and bar.pth contains:
[46] Fix | Delete
[47] Fix | Delete
# bar package configuration
[48] Fix | Delete
bar
[49] Fix | Delete
[50] Fix | Delete
Then the following directories are added to sys.path, in this order:
[51] Fix | Delete
[52] Fix | Delete
/usr/local/lib/python2.5/site-packages/bar
[53] Fix | Delete
/usr/local/lib/python2.5/site-packages/foo
[54] Fix | Delete
[55] Fix | Delete
Note that bletch is omitted because it doesn't exist; bar precedes foo
[56] Fix | Delete
because bar.pth comes alphabetically before foo.pth; and spam is
[57] Fix | Delete
omitted because it is not mentioned in either path configuration file.
[58] Fix | Delete
[59] Fix | Delete
The readline module is also automatically configured to enable
[60] Fix | Delete
completion for systems that support it. This can be overridden in
[61] Fix | Delete
sitecustomize, usercustomize or PYTHONSTARTUP. Starting Python in
[62] Fix | Delete
isolated mode (-I) disables automatic readline configuration.
[63] Fix | Delete
[64] Fix | Delete
After these operations, an attempt is made to import a module
[65] Fix | Delete
named sitecustomize, which can perform arbitrary additional
[66] Fix | Delete
site-specific customizations. If this import fails with an
[67] Fix | Delete
ImportError exception, it is silently ignored.
[68] Fix | Delete
"""
[69] Fix | Delete
[70] Fix | Delete
import sys
[71] Fix | Delete
import os
[72] Fix | Delete
import builtins
[73] Fix | Delete
import _sitebuiltins
[74] Fix | Delete
import io
[75] Fix | Delete
[76] Fix | Delete
# Prefixes for site-packages; add additional prefixes like /usr/local here
[77] Fix | Delete
PREFIXES = [sys.prefix, sys.exec_prefix]
[78] Fix | Delete
# Enable per user site-packages directory
[79] Fix | Delete
# set it to False to disable the feature or True to force the feature
[80] Fix | Delete
ENABLE_USER_SITE = None
[81] Fix | Delete
[82] Fix | Delete
# for distutils.commands.install
[83] Fix | Delete
# These values are initialized by the getuserbase() and getusersitepackages()
[84] Fix | Delete
# functions, through the main() function when Python starts.
[85] Fix | Delete
USER_SITE = None
[86] Fix | Delete
USER_BASE = None
[87] Fix | Delete
[88] Fix | Delete
[89] Fix | Delete
def makepath(*paths):
[90] Fix | Delete
dir = os.path.join(*paths)
[91] Fix | Delete
try:
[92] Fix | Delete
dir = os.path.abspath(dir)
[93] Fix | Delete
except OSError:
[94] Fix | Delete
pass
[95] Fix | Delete
return dir, os.path.normcase(dir)
[96] Fix | Delete
[97] Fix | Delete
[98] Fix | Delete
def abs_paths():
[99] Fix | Delete
"""Set all module __file__ and __cached__ attributes to an absolute path"""
[100] Fix | Delete
for m in set(sys.modules.values()):
[101] Fix | Delete
if (getattr(getattr(m, '__loader__', None), '__module__', None) not in
[102] Fix | Delete
('_frozen_importlib', '_frozen_importlib_external')):
[103] Fix | Delete
continue # don't mess with a PEP 302-supplied __file__
[104] Fix | Delete
try:
[105] Fix | Delete
m.__file__ = os.path.abspath(m.__file__)
[106] Fix | Delete
except (AttributeError, OSError, TypeError):
[107] Fix | Delete
pass
[108] Fix | Delete
try:
[109] Fix | Delete
m.__cached__ = os.path.abspath(m.__cached__)
[110] Fix | Delete
except (AttributeError, OSError, TypeError):
[111] Fix | Delete
pass
[112] Fix | Delete
[113] Fix | Delete
[114] Fix | Delete
def removeduppaths():
[115] Fix | Delete
""" Remove duplicate entries from sys.path along with making them
[116] Fix | Delete
absolute"""
[117] Fix | Delete
# This ensures that the initial path provided by the interpreter contains
[118] Fix | Delete
# only absolute pathnames, even if we're running from the build directory.
[119] Fix | Delete
L = []
[120] Fix | Delete
known_paths = set()
[121] Fix | Delete
for dir in sys.path:
[122] Fix | Delete
# Filter out duplicate paths (on case-insensitive file systems also
[123] Fix | Delete
# if they only differ in case); turn relative paths into absolute
[124] Fix | Delete
# paths.
[125] Fix | Delete
dir, dircase = makepath(dir)
[126] Fix | Delete
if dircase not in known_paths:
[127] Fix | Delete
L.append(dir)
[128] Fix | Delete
known_paths.add(dircase)
[129] Fix | Delete
sys.path[:] = L
[130] Fix | Delete
return known_paths
[131] Fix | Delete
[132] Fix | Delete
[133] Fix | Delete
def _init_pathinfo():
[134] Fix | Delete
"""Return a set containing all existing file system items from sys.path."""
[135] Fix | Delete
d = set()
[136] Fix | Delete
for item in sys.path:
[137] Fix | Delete
try:
[138] Fix | Delete
if os.path.exists(item):
[139] Fix | Delete
_, itemcase = makepath(item)
[140] Fix | Delete
d.add(itemcase)
[141] Fix | Delete
except TypeError:
[142] Fix | Delete
continue
[143] Fix | Delete
return d
[144] Fix | Delete
[145] Fix | Delete
[146] Fix | Delete
def addpackage(sitedir, name, known_paths):
[147] Fix | Delete
"""Process a .pth file within the site-packages directory:
[148] Fix | Delete
For each line in the file, either combine it with sitedir to a path
[149] Fix | Delete
and add that to known_paths, or execute it if it starts with 'import '.
[150] Fix | Delete
"""
[151] Fix | Delete
if known_paths is None:
[152] Fix | Delete
known_paths = _init_pathinfo()
[153] Fix | Delete
reset = True
[154] Fix | Delete
else:
[155] Fix | Delete
reset = False
[156] Fix | Delete
fullname = os.path.join(sitedir, name)
[157] Fix | Delete
try:
[158] Fix | Delete
f = io.TextIOWrapper(io.open_code(fullname))
[159] Fix | Delete
except OSError:
[160] Fix | Delete
return
[161] Fix | Delete
with f:
[162] Fix | Delete
for n, line in enumerate(f):
[163] Fix | Delete
if line.startswith("#"):
[164] Fix | Delete
continue
[165] Fix | Delete
try:
[166] Fix | Delete
if line.startswith(("import ", "import\t")):
[167] Fix | Delete
exec(line)
[168] Fix | Delete
continue
[169] Fix | Delete
line = line.rstrip()
[170] Fix | Delete
dir, dircase = makepath(sitedir, line)
[171] Fix | Delete
if not dircase in known_paths and os.path.exists(dir):
[172] Fix | Delete
sys.path.append(dir)
[173] Fix | Delete
known_paths.add(dircase)
[174] Fix | Delete
except Exception:
[175] Fix | Delete
print("Error processing line {:d} of {}:\n".format(n+1, fullname),
[176] Fix | Delete
file=sys.stderr)
[177] Fix | Delete
import traceback
[178] Fix | Delete
for record in traceback.format_exception(*sys.exc_info()):
[179] Fix | Delete
for line in record.splitlines():
[180] Fix | Delete
print(' '+line, file=sys.stderr)
[181] Fix | Delete
print("\nRemainder of file ignored", file=sys.stderr)
[182] Fix | Delete
break
[183] Fix | Delete
if reset:
[184] Fix | Delete
known_paths = None
[185] Fix | Delete
return known_paths
[186] Fix | Delete
[187] Fix | Delete
[188] Fix | Delete
def addsitedir(sitedir, known_paths=None):
[189] Fix | Delete
"""Add 'sitedir' argument to sys.path if missing and handle .pth files in
[190] Fix | Delete
'sitedir'"""
[191] Fix | Delete
if known_paths is None:
[192] Fix | Delete
known_paths = _init_pathinfo()
[193] Fix | Delete
reset = True
[194] Fix | Delete
else:
[195] Fix | Delete
reset = False
[196] Fix | Delete
sitedir, sitedircase = makepath(sitedir)
[197] Fix | Delete
if not sitedircase in known_paths:
[198] Fix | Delete
sys.path.append(sitedir) # Add path component
[199] Fix | Delete
known_paths.add(sitedircase)
[200] Fix | Delete
try:
[201] Fix | Delete
names = os.listdir(sitedir)
[202] Fix | Delete
except OSError:
[203] Fix | Delete
return
[204] Fix | Delete
names = [name for name in names if name.endswith(".pth")]
[205] Fix | Delete
for name in sorted(names):
[206] Fix | Delete
addpackage(sitedir, name, known_paths)
[207] Fix | Delete
if reset:
[208] Fix | Delete
known_paths = None
[209] Fix | Delete
return known_paths
[210] Fix | Delete
[211] Fix | Delete
[212] Fix | Delete
def check_enableusersite():
[213] Fix | Delete
"""Check if user site directory is safe for inclusion
[214] Fix | Delete
[215] Fix | Delete
The function tests for the command line flag (including environment var),
[216] Fix | Delete
process uid/gid equal to effective uid/gid.
[217] Fix | Delete
[218] Fix | Delete
None: Disabled for security reasons
[219] Fix | Delete
False: Disabled by user (command line option)
[220] Fix | Delete
True: Safe and enabled
[221] Fix | Delete
"""
[222] Fix | Delete
if sys.flags.no_user_site:
[223] Fix | Delete
return False
[224] Fix | Delete
[225] Fix | Delete
if hasattr(os, "getuid") and hasattr(os, "geteuid"):
[226] Fix | Delete
# check process uid == effective uid
[227] Fix | Delete
if os.geteuid() != os.getuid():
[228] Fix | Delete
return None
[229] Fix | Delete
if hasattr(os, "getgid") and hasattr(os, "getegid"):
[230] Fix | Delete
# check process gid == effective gid
[231] Fix | Delete
if os.getegid() != os.getgid():
[232] Fix | Delete
return None
[233] Fix | Delete
[234] Fix | Delete
return True
[235] Fix | Delete
[236] Fix | Delete
[237] Fix | Delete
# NOTE: sysconfig and it's dependencies are relatively large but site module
[238] Fix | Delete
# needs very limited part of them.
[239] Fix | Delete
# To speedup startup time, we have copy of them.
[240] Fix | Delete
#
[241] Fix | Delete
# See https://bugs.python.org/issue29585
[242] Fix | Delete
[243] Fix | Delete
# Copy of sysconfig._getuserbase()
[244] Fix | Delete
def _getuserbase():
[245] Fix | Delete
env_base = os.environ.get("PYTHONUSERBASE", None)
[246] Fix | Delete
if env_base:
[247] Fix | Delete
return env_base
[248] Fix | Delete
[249] Fix | Delete
def joinuser(*args):
[250] Fix | Delete
return os.path.expanduser(os.path.join(*args))
[251] Fix | Delete
[252] Fix | Delete
if os.name == "nt":
[253] Fix | Delete
base = os.environ.get("APPDATA") or "~"
[254] Fix | Delete
return joinuser(base, "Python")
[255] Fix | Delete
[256] Fix | Delete
if sys.platform == "darwin" and sys._framework:
[257] Fix | Delete
return joinuser("~", "Library", sys._framework,
[258] Fix | Delete
"%d.%d" % sys.version_info[:2])
[259] Fix | Delete
[260] Fix | Delete
return joinuser("~", ".local")
[261] Fix | Delete
[262] Fix | Delete
[263] Fix | Delete
# Same to sysconfig.get_path('purelib', os.name+'_user')
[264] Fix | Delete
def _get_path(userbase):
[265] Fix | Delete
version = sys.version_info
[266] Fix | Delete
[267] Fix | Delete
if os.name == 'nt':
[268] Fix | Delete
return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages'
[269] Fix | Delete
[270] Fix | Delete
if sys.platform == 'darwin' and sys._framework:
[271] Fix | Delete
return f'{userbase}/lib/python/site-packages'
[272] Fix | Delete
[273] Fix | Delete
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
[274] Fix | Delete
[275] Fix | Delete
[276] Fix | Delete
def getuserbase():
[277] Fix | Delete
"""Returns the `user base` directory path.
[278] Fix | Delete
[279] Fix | Delete
The `user base` directory can be used to store data. If the global
[280] Fix | Delete
variable ``USER_BASE`` is not initialized yet, this function will also set
[281] Fix | Delete
it.
[282] Fix | Delete
"""
[283] Fix | Delete
global USER_BASE
[284] Fix | Delete
if USER_BASE is None:
[285] Fix | Delete
USER_BASE = _getuserbase()
[286] Fix | Delete
return USER_BASE
[287] Fix | Delete
[288] Fix | Delete
[289] Fix | Delete
def getusersitepackages():
[290] Fix | Delete
"""Returns the user-specific site-packages directory path.
[291] Fix | Delete
[292] Fix | Delete
If the global variable ``USER_SITE`` is not initialized yet, this
[293] Fix | Delete
function will also set it.
[294] Fix | Delete
"""
[295] Fix | Delete
global USER_SITE
[296] Fix | Delete
userbase = getuserbase() # this will also set USER_BASE
[297] Fix | Delete
[298] Fix | Delete
if USER_SITE is None:
[299] Fix | Delete
USER_SITE = _get_path(userbase)
[300] Fix | Delete
[301] Fix | Delete
return USER_SITE
[302] Fix | Delete
[303] Fix | Delete
def addusersitepackages(known_paths):
[304] Fix | Delete
"""Add a per user site-package to sys.path
[305] Fix | Delete
[306] Fix | Delete
Each user has its own python directory with site-packages in the
[307] Fix | Delete
home directory.
[308] Fix | Delete
"""
[309] Fix | Delete
# get the per user site-package path
[310] Fix | Delete
# this call will also make sure USER_BASE and USER_SITE are set
[311] Fix | Delete
user_site = getusersitepackages()
[312] Fix | Delete
[313] Fix | Delete
if ENABLE_USER_SITE and os.path.isdir(user_site):
[314] Fix | Delete
addsitedir(user_site, known_paths)
[315] Fix | Delete
return known_paths
[316] Fix | Delete
[317] Fix | Delete
def getsitepackages(prefixes=None):
[318] Fix | Delete
"""Returns a list containing all global site-packages directories.
[319] Fix | Delete
[320] Fix | Delete
For each directory present in ``prefixes`` (or the global ``PREFIXES``),
[321] Fix | Delete
this function will find its `site-packages` subdirectory depending on the
[322] Fix | Delete
system environment, and will return a list of full paths.
[323] Fix | Delete
"""
[324] Fix | Delete
sitepackages = []
[325] Fix | Delete
seen = set()
[326] Fix | Delete
[327] Fix | Delete
if prefixes is None:
[328] Fix | Delete
prefixes = PREFIXES
[329] Fix | Delete
[330] Fix | Delete
for prefix in prefixes:
[331] Fix | Delete
if not prefix or prefix in seen:
[332] Fix | Delete
continue
[333] Fix | Delete
seen.add(prefix)
[334] Fix | Delete
[335] Fix | Delete
if os.sep == '/':
[336] Fix | Delete
sitepackages.append(os.path.join(prefix, "lib64",
[337] Fix | Delete
"python" + sys.version[:3],
[338] Fix | Delete
"site-packages"))
[339] Fix | Delete
sitepackages.append(os.path.join(prefix, "lib",
[340] Fix | Delete
"python%d.%d" % sys.version_info[:2],
[341] Fix | Delete
"site-packages"))
[342] Fix | Delete
else:
[343] Fix | Delete
sitepackages.append(prefix)
[344] Fix | Delete
sitepackages.append(os.path.join(prefix, "lib64", "site-packages"))
[345] Fix | Delete
sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
[346] Fix | Delete
return sitepackages
[347] Fix | Delete
[348] Fix | Delete
def addsitepackages(known_paths, prefixes=None):
[349] Fix | Delete
"""Add site-packages to sys.path
[350] Fix | Delete
[351] Fix | Delete
'/usr/local' is included in PREFIXES if RPM build is not detected
[352] Fix | Delete
to make packages installed into this location visible.
[353] Fix | Delete
[354] Fix | Delete
"""
[355] Fix | Delete
if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ:
[356] Fix | Delete
PREFIXES.insert(0, "/usr/local")
[357] Fix | Delete
for sitedir in getsitepackages(prefixes):
[358] Fix | Delete
if os.path.isdir(sitedir):
[359] Fix | Delete
addsitedir(sitedir, known_paths)
[360] Fix | Delete
[361] Fix | Delete
return known_paths
[362] Fix | Delete
[363] Fix | Delete
def setquit():
[364] Fix | Delete
"""Define new builtins 'quit' and 'exit'.
[365] Fix | Delete
[366] Fix | Delete
These are objects which make the interpreter exit when called.
[367] Fix | Delete
The repr of each object contains a hint at how it works.
[368] Fix | Delete
[369] Fix | Delete
"""
[370] Fix | Delete
if os.sep == '\\':
[371] Fix | Delete
eof = 'Ctrl-Z plus Return'
[372] Fix | Delete
else:
[373] Fix | Delete
eof = 'Ctrl-D (i.e. EOF)'
[374] Fix | Delete
[375] Fix | Delete
builtins.quit = _sitebuiltins.Quitter('quit', eof)
[376] Fix | Delete
builtins.exit = _sitebuiltins.Quitter('exit', eof)
[377] Fix | Delete
[378] Fix | Delete
[379] Fix | Delete
def setcopyright():
[380] Fix | Delete
"""Set 'copyright' and 'credits' in builtins"""
[381] Fix | Delete
builtins.copyright = _sitebuiltins._Printer("copyright", sys.copyright)
[382] Fix | Delete
if sys.platform[:4] == 'java':
[383] Fix | Delete
builtins.credits = _sitebuiltins._Printer(
[384] Fix | Delete
"credits",
[385] Fix | Delete
"Jython is maintained by the Jython developers (www.jython.org).")
[386] Fix | Delete
else:
[387] Fix | Delete
builtins.credits = _sitebuiltins._Printer("credits", """\
[388] Fix | Delete
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
[389] Fix | Delete
for supporting Python development. See www.python.org for more information.""")
[390] Fix | Delete
files, dirs = [], []
[391] Fix | Delete
# Not all modules are required to have a __file__ attribute. See
[392] Fix | Delete
# PEP 420 for more details.
[393] Fix | Delete
if hasattr(os, '__file__'):
[394] Fix | Delete
here = os.path.dirname(os.__file__)
[395] Fix | Delete
files.extend(["LICENSE.txt", "LICENSE"])
[396] Fix | Delete
dirs.extend([os.path.join(here, os.pardir), here, os.curdir])
[397] Fix | Delete
builtins.license = _sitebuiltins._Printer(
[398] Fix | Delete
"license",
[399] Fix | Delete
"See https://www.python.org/psf/license/",
[400] Fix | Delete
files, dirs)
[401] Fix | Delete
[402] Fix | Delete
[403] Fix | Delete
def sethelper():
[404] Fix | Delete
builtins.help = _sitebuiltins._Helper()
[405] Fix | Delete
[406] Fix | Delete
def enablerlcompleter():
[407] Fix | Delete
"""Enable default readline configuration on interactive prompts, by
[408] Fix | Delete
registering a sys.__interactivehook__.
[409] Fix | Delete
[410] Fix | Delete
If the readline module can be imported, the hook will set the Tab key
[411] Fix | Delete
as completion key and register ~/.python_history as history file.
[412] Fix | Delete
This can be overridden in the sitecustomize or usercustomize module,
[413] Fix | Delete
or in a PYTHONSTARTUP file.
[414] Fix | Delete
"""
[415] Fix | Delete
def register_readline():
[416] Fix | Delete
import atexit
[417] Fix | Delete
try:
[418] Fix | Delete
import readline
[419] Fix | Delete
import rlcompleter
[420] Fix | Delete
except ImportError:
[421] Fix | Delete
return
[422] Fix | Delete
[423] Fix | Delete
# Reading the initialization (config) file may not be enough to set a
[424] Fix | Delete
# completion key, so we set one first and then read the file.
[425] Fix | Delete
readline_doc = getattr(readline, '__doc__', '')
[426] Fix | Delete
if readline_doc is not None and 'libedit' in readline_doc:
[427] Fix | Delete
readline.parse_and_bind('bind ^I rl_complete')
[428] Fix | Delete
else:
[429] Fix | Delete
readline.parse_and_bind('tab: complete')
[430] Fix | Delete
[431] Fix | Delete
try:
[432] Fix | Delete
readline.read_init_file()
[433] Fix | Delete
except OSError:
[434] Fix | Delete
# An OSError here could have many causes, but the most likely one
[435] Fix | Delete
# is that there's no .inputrc file (or .editrc file in the case of
[436] Fix | Delete
# Mac OS X + libedit) in the expected location. In that case, we
[437] Fix | Delete
# want to ignore the exception.
[438] Fix | Delete
pass
[439] Fix | Delete
[440] Fix | Delete
if readline.get_current_history_length() == 0:
[441] Fix | Delete
# If no history was loaded, default to .python_history.
[442] Fix | Delete
# The guard is necessary to avoid doubling history size at
[443] Fix | Delete
# each interpreter exit when readline was already configured
[444] Fix | Delete
# through a PYTHONSTARTUP hook, see:
[445] Fix | Delete
# http://bugs.python.org/issue5845#msg198636
[446] Fix | Delete
history = os.path.join(os.path.expanduser('~'),
[447] Fix | Delete
'.python_history')
[448] Fix | Delete
try:
[449] Fix | Delete
readline.read_history_file(history)
[450] Fix | Delete
except OSError:
[451] Fix | Delete
pass
[452] Fix | Delete
[453] Fix | Delete
def write_history():
[454] Fix | Delete
try:
[455] Fix | Delete
readline.write_history_file(history)
[456] Fix | Delete
except OSError:
[457] Fix | Delete
# bpo-19891, bpo-41193: Home directory does not exist
[458] Fix | Delete
# or is not writable, or the filesystem is read-only.
[459] Fix | Delete
pass
[460] Fix | Delete
[461] Fix | Delete
atexit.register(write_history)
[462] Fix | Delete
[463] Fix | Delete
sys.__interactivehook__ = register_readline
[464] Fix | Delete
[465] Fix | Delete
def venv(known_paths):
[466] Fix | Delete
global PREFIXES, ENABLE_USER_SITE
[467] Fix | Delete
[468] Fix | Delete
env = os.environ
[469] Fix | Delete
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
[470] Fix | Delete
executable = sys._base_executable = os.environ['__PYVENV_LAUNCHER__']
[471] Fix | Delete
else:
[472] Fix | Delete
executable = sys.executable
[473] Fix | Delete
exe_dir, _ = os.path.split(os.path.abspath(executable))
[474] Fix | Delete
site_prefix = os.path.dirname(exe_dir)
[475] Fix | Delete
sys._home = None
[476] Fix | Delete
conf_basename = 'pyvenv.cfg'
[477] Fix | Delete
candidate_confs = [
[478] Fix | Delete
conffile for conffile in (
[479] Fix | Delete
os.path.join(exe_dir, conf_basename),
[480] Fix | Delete
os.path.join(site_prefix, conf_basename)
[481] Fix | Delete
)
[482] Fix | Delete
if os.path.isfile(conffile)
[483] Fix | Delete
]
[484] Fix | Delete
[485] Fix | Delete
if candidate_confs:
[486] Fix | Delete
virtual_conf = candidate_confs[0]
[487] Fix | Delete
system_site = "true"
[488] Fix | Delete
# Issue 25185: Use UTF-8, as that's what the venv module uses when
[489] Fix | Delete
# writing the file.
[490] Fix | Delete
with open(virtual_conf, encoding='utf-8') as f:
[491] Fix | Delete
for line in f:
[492] Fix | Delete
if '=' in line:
[493] Fix | Delete
key, _, value = line.partition('=')
[494] Fix | Delete
key = key.strip().lower()
[495] Fix | Delete
value = value.strip()
[496] Fix | Delete
if key == 'include-system-site-packages':
[497] Fix | Delete
system_site = value.lower()
[498] Fix | Delete
elif key == 'home':
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function