Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup win32comext.axdebug #2126

Merged
merged 5 commits into from
Nov 1, 2023
Merged

Cleanup win32comext.axdebug #2126

merged 5 commits into from
Nov 1, 2023

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Sep 22, 2023

This is the combination of the following changes, but scoped specifically to the win32comext.axdebug module:

Merging this first will reduce changes everywhere else.
Non-obvious changes are clarified in comments.

Comment on lines -112 to -156
def TestSmartHelper():
pdm = pythoncom.CoCreateInstance(
axdebug.CLSID_ProcessDebugManager,
None,
pythoncom.CLSCTX_ALL,
axdebug.IID_IProcessDebugManager,
)
app = pdm.CreateApplication()
app.SetName("Python Process")

pydebugger = adb.Debugger()

nodes = BuildModuleTree()

all_real_nodes = CreateDebugDocumentHelperNodes(pdm, app, nodes)
root = app.GetRootNode()
AttachParentNodes(root, nodes, all_real_nodes)

pydebugger.AttachApp(app)
cookie = pdm.AddApplication(app)
input("Waiting...")
ttest.test()

pdm.RemoveApplication(cookie)
print("Done")


def testdumb():
pdm = pythoncom.CoCreateInstance(
axdebug.CLSID_ProcessDebugManager,
None,
pythoncom.CLSCTX_ALL,
axdebug.IID_IProcessDebugManager,
)
app = pdm.GetDefaultApplication()

nodes = BuildModuleTree()
all_real_nodes = CreateDebugDocumentHelperNodes(pdm, app, nodes)
AttachParentNodes(None, nodes, all_real_nodes)

parentNode = None
all_real_nodes = {}
input("Waiting...")
print("Done")


Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were commented out in the caller code (so it's unused) and contain a bunch of undefined names / unbound variables that I can't find anywhere.
If you still think it's worth keeping around, I'll comment them out instead.

Comment on lines -12 to -17
from win32com.axdebug import axdebug
from win32com.axdebug import axdebug, contexts
from win32com.axdebug.util import _wrap
from win32com.server.exception import Exception

from . import contexts
from .util import RaiseNotImpl, _wrap

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS E:\Users\Avasam\Documents\Git\pywin32\com\win32comext\axdebug> python codecontainer.py
Traceback (most recent call last):
  File "E:\Users\Avasam\Documents\Git\pywin32\com\win32comext\axdebug\codecontainer.py", line 19, in <module>
    from . import contexts
ImportError: attempted relative import with no known parent package

Comment on lines -256 to +255
sys.path.append(".")
import ttest
from Test import ttest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested running this script from both pywin32\com\win32comext\axdebug and pywin32\com\win32comext\axdebug\Test. With this change, it finds the module in both cases.

@@ -34,7 +33,7 @@ def GetDocument(self):
return self.doc


class DebugDocumentText(gateways.DebugDocumentInfo, gateways.DebugDocumentText):
class DebugDocumentText(gateways.DebugDocumentText):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MRO issue, #2071 did not do enough

>>> import win32comext.axdebug.documents
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python39\lib\site-packages\win32comext\axdebug\documents.py", line 37, in <module>
    class DebugDocumentText(
TypeError: Cannot create a consistent method resolution
order (MRO) for bases DebugDocumentInfo, DebugDocumentText

from win32com.server.util import unwrap

print("Wrapped items:")
for key, items in all_wrapped.items():
Copy link
Collaborator Author

@Avasam Avasam Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing ever modifies all_wrapped. Meaning this code likely does nothing.

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mhammond mhammond merged commit ea43be2 into mhammond:main Nov 1, 2023
16 checks passed
@Avasam Avasam deleted the cleanup-axdebug branch November 1, 2023 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants