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

Fixed Pythonwin's editor failing due to invalid regex import #2419

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true
- run: pip install types-regex types-setuptools PyOpenGL mypy==1.11
- run: pip install types-setuptools PyOpenGL mypy==1.11
- run: mypy . --python-version=${{ matrix.python-version }}

pyright:
Expand All @@ -162,7 +162,7 @@ jobs:
cache-dependency-path: .github/workflows/main.yml
check-latest: true
# pyright vendors typeshed, but let's make sure we have the most up to date stubs
- run: pip install types-regex types-setuptools PyOpenGL
- run: pip install types-setuptools PyOpenGL
- uses: jakebailey/pyright-action@v2
with:
python-version: ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html.
Coming in build 309, as yet unreleased
--------------------------------------

* Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam)
* Dropped support for Python 3.7 (#2207, @Avasam)
* Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317, @geppi)
* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2304, #2310, @geppi)
Expand Down
12 changes: 6 additions & 6 deletions Pythonwin/pywin/framework/editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# We now support reloading of externally modified documented
# (eg, presumably by some other process, such as source control or
# another editor.
# We also suport auto-loading of externally modified files.
# We also support auto-loading of externally modified files.
# - if the current document has not been modified in this
# editor, but has been modified on disk, then the file
# can be automatically reloaded.
Expand All @@ -19,7 +19,6 @@

import re

import regex
import win32api
import win32con
import win32ui
Expand All @@ -36,8 +35,8 @@
# from pywin.mfc.docview import EditView as ParentEditorView
# from pywin.mfc.docview import Document as ParentEditorDocument

patImport = regex.symcomp(r"import \(<name>.*\)")
patIndent = regex.compile(r"^\([ \t]*[~ \t]\)")
patImport = re.compile(r"import (?P<name>.*)")
patIndent = re.compile(r"^([ \t]*[~ \t])")

ID_LOCATE_FILE = 0xE200
ID_GOTO_LINE = 0xE2001
Expand Down Expand Up @@ -364,9 +363,10 @@ def OnRClick(self, params):
# look for a module name
line = self._obj_.GetLine().strip()
flags = win32con.MF_STRING | win32con.MF_ENABLED
if patImport.match(line) == len(line):
matchResult = patImport.match(line)
if matchResult and matchResult[0] == line:
menu.AppendMenu(
flags, ID_LOCATE_FILE, "&Locate %s.py" % patImport.group("name")
flags, ID_LOCATE_FILE, "&Locate %s.py" % matchResult.group("name")
)
menu.AppendMenu(win32con.MF_SEPARATOR)
menu.AppendMenu(flags, win32ui.ID_EDIT_UNDO, "&Undo")
Expand Down
3 changes: 1 addition & 2 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def __radd__(self, other):


# Group(1) is the filename, group(2) is the lineno.
# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))")
# regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)")
# regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what's the point of this line. Debugging?

Suggested change
# regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)")

regexGrep = re.compile(r"^(..[^\(:]+)?[\(:](\d+)[\):]:?\s*(.*)")

# these are the atom numbers defined by Windows for basic dialog controls
Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/framework/sgrepmdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def __radd__(self, other):


# Group(1) is the filename, group(2) is the lineno.
# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))")

regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\(([0-9]+)\)")

# these are the atom numbers defined by Windows for basic dialog controls
Expand Down
Loading