Python3: fix remaining syntax errors found by py2exe - #9719
Conversation
Modified 'ur' strings to be just 'r' strings prefixes
|
Py2exe still fails later on when copying py2exe/pywintypes37.dll. directly above the assertion. |
17dcd48 to
f9ddb13
Compare
|
In my opinion, the actual bug here is that py2exe tries to copy stuff for pywin32, but we don't use pywin32 anymore within our code base. So rather than coming up with a fix or workaround for the assertion, we should try to stop copying parts of pywin32 altogether.
|
| oldTime=getattr(self,'_basicTextTime',0) | ||
| if newTime-oldTime>0.5: | ||
| self._basicText=u" ".join([x for x in self.name, self.value, self.description if isinstance(x, basestring) and len(x) > 0 and not x.isspace()]) | ||
| self._basicText=u" ".join([x for x in (self.name, self.value, self.description) if isinstance(x, basestring) and len(x) > 0 and not x.isspace()]) |
There was a problem hiding this comment.
The list (square) brackets were actually a part of this old syntax and can be removed. Also note that basestring is still in here, but that will probably be handled in a later stage?
| self._basicText=u" ".join([x for x in (self.name, self.value, self.description) if isinstance(x, basestring) and len(x) > 0 and not x.isspace()]) | |
| self._basicText=u" ".join(x for x in (self.name, self.value, self.description) if isinstance(x, basestring) and len(x) > 0 and not x.isspace()) |
| d=dict.get('_del_%s'%x,None) | ||
| if x in dict: | ||
| methodsString=",".join([str(i) for i in g,s,d if i]) | ||
| methodsString=",".join([str(i) for i in (g,s,d) if i]) |
There was a problem hiding this comment.
Square brackets can be removed
| if className: | ||
| break | ||
| return ".".join([x for x in path,className,funcName if x]) | ||
| return ".".join([x for x in (path,className,funcName) if x]) |
There was a problem hiding this comment.
brackets can be removed
| @@ -0,0 +1,18 @@ | |||
| import sys | |||
| exc = self._exc_info | ||
| if exc: | ||
| raise exc[0], exc[1], exc[2] | ||
| # The execution of the function in the other thread cuased an exception. |
| # Re-raise it here. | ||
| # Note that in Python3, the traceback (stack) is now part of the exception, | ||
| # So the logged traceback will correctly show the stack for both this thread and the other thread. | ||
| raise e |
There was a problem hiding this comment.
Where is this e coming from? Shouldn't this be exc?
|
@LeonarddeR I believe I have addressed your review comments. Changes of basestring etc are coming in a separate pr very soon. |
…pywintypes37.dll.
|
setup.py now excludes win32api (which we don't need), so it gets around the possible bug when trying to include pywintypes37.dll. |
| "serial.serialposix", | ||
| "serial.socket_connection", | ||
| # Py2exe seems to implicitly include this, but we don't need it. | ||
| "win32api", |
There was a problem hiding this comment.
I'd really like to know why this was included.
Also note the following lines from the output:
Copy d:\Development\NVDA\source repo\include\py2exe\win32wnet.pyd to D:\Development\NVDA\source repo\dist\win32wnet.pyd
Copy d:\Development\NVDA\source repo\include\py2exe\_winxptheme.pyd to D:\Development\NVDA\source repo\dist\_winxptheme.pyd
Copy ExtensionDLL d:\Development\NVDA\source repo\include\py2exe\pywintypes37.dll to D:\Development\NVDA\source repo\dist\
These 3 files are all pywin32. We also have the following files in library.zip:
- win32wnet.pyc
- winxptheme.pyc
- _winxptheme.pyc
|
Small additional detail. A non public application I wrote and converted to py2exe lately does not contain all these modules. So I really have the feeling that there is a reference in our code we aren't currently aware of. |
|
If I manually delete netbios.py, win32api.pyd, win32wnet.pyd and
winxptheme.py from our py2exe git submodule,
Py2exe then tells me the following modules are missing and why:
? netbios imported from uuid
? winxptheme imported from
wx.lib.agw.aui.dockart, wx.lib.agw.aui.framemanager
? winxptheme imported from
wx.lib.agw.aui.dockart, wx.lib.agw.aui.framemanager
I have confirmed online that winxptheme (from pywin32 is used in
wxPython if available.
I can also see from Python3's own uuid module source code, that to
generate a uuid, it tries various different ways of generating a
hardware node value, one of those ways is to use netbios / win32wnet if
available.
In short, we should be safe to exclude winxptheme, netbios and win32wnet.
However, @LeonarddeR, what was the reasoning behind why you thought that
py2exe depended upon pywin32? I assume it was something more significant
than missing modules at this stage in the build?
I.e. knowing this now, should we just put these in excludes, or can we
actually remove these modules from the git submodule?
|
Link to issue number:
None.
Summary of the issue:
When running py2exe over the codebase, it found some syntax errors and one missing module.
Description of how this pull request fixes the issue:
Fixes all remaining syntax errors:
Testing performed:
Py2exe successfully parsed all modules in the codebase.
Known issues with pull request:
Py2exe still fails later on, unrelated to these syntax errors. See my next comment.
Change log entry:
None.