Skip to content

Commit 6c18157

Browse files
authored
Merge 5c0a1e3 into f925600
2 parents f925600 + 5c0a1e3 commit 6c18157

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

source/logHandler.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,34 @@
3131
CO_E_OBJNOTCONNECTED = -2147220995
3232
EVENT_E_ALL_SUBSCRIBERS_FAILED = -2147220991
3333
LOAD_WITH_ALTERED_SEARCH_PATH=0x8
34+
_NVDA_CODE_PATH = os.path.dirname(__file__)
35+
"""Store path in which NVDA code is placed.
36+
We cannot use `globalVars.appDir`, since for binary builds it points to the directory with NVDA binaries,
37+
whereas for compiled versions NVDA's code files are in `library.zip`.
38+
"""
3439

3540

3641
def isPathExternalToNVDA(path: str) -> bool:
3742
""" Checks if the given path is external to NVDA (I.e. not pointing to built-in code). """
3843
if(
3944
path[0] != "<"
4045
and os.path.isabs(path)
41-
and not os.path.normpath(path).startswith(sys.path[0] + "\\")
46+
and not os.path.normpath(path).startswith(_NVDA_CODE_PATH + "\\")
47+
or (
48+
globalVars.appArgs.configPath is not None # Handle messages logged before config is initialized
49+
and path.startswith(globalVars.appArgs.configPath)
50+
)
4251
):
4352
# This module is external because:
4453
# the code comes from a file (fn doesn't begin with "<");
4554
# it has an absolute file path (code bundled in binary builds reports relative paths); and
46-
# it is not part of NVDA's Python code (not beneath sys.path[0]).
55+
# it is not part of NVDA's Python code
56+
# (i.e. outside of NVDA directory or in NVDA's config,
57+
# so belongs to an add-on or a plugin in the scratchpad).
4758
return True
4859
return False
4960

61+
5062
def getCodePath(f):
5163
"""Using a frame object, gets its module path (relative to the current directory).[className.[funcName]]
5264
@param f: the frame object to use

0 commit comments

Comments
 (0)