Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gdb/python/lib/gdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def _execute_unwinders(pending_frame):


# Convenience variable to GDB's python directory
PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
try:
PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
except NameError:
PYTHONDIR = "FROZEN"

# Auto-load all functions/commands.

Expand All @@ -146,7 +149,13 @@ def _execute_unwinders(pending_frame):

def _auto_load_packages():
for package in packages:
location = os.path.join(os.path.dirname(__file__), package)
# __file__ isn't set when compiling the module remotely with static python. If Python is static, we
# can just skip this method because no Python packages that can be loaded exist. Everything is
# supposed to be frozen into the python lib/binary.
try:
location = os.path.join(os.path.dirname(__file__), package)
except NameError:
return
if os.path.exists(location):
py_files = filter(
lambda x: x.endswith(".py") and x != "__init__.py", os.listdir(location)
Expand Down