Description
util/filesys.py causes FutureWarning in python 2.3. The message printed to the Apache error_log is:
<Apache header removed> /usr/lib/python2.3/site-packages/!MoinMoin/util/filesys.py:106: FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up, referer: <site-name removed>/!FrontPage
Example
See Description for message in Apache error_log. Offending code runs on WinNT, but error appears even if you are running on Linux.
Details
MoinMoin Version |
Release 1.2.2 [!Revision 1.185] |
OS and Version |
Gentoo Linux kernel 2.6.7-gentoo-r10 |
Python Version |
Python 2.3.3 (#1, Jul 13 2004, 15:05:44) [!GCC 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)] |
Discussion
The problems is that python int is signed 32 bit integer, and 0xffff0000 is a negative number. Python 2.4 will create a long from this literal. The safe solution is to use long now. However, this might break the win32 code that use this __highbits.
My fix is to change line 106 from
__highbits = 0xffff0000 # XXX FIXME, gives Python2.3 warning
to
__highbits = long("0xffff0000", 32)
I can test that there are no warnings by running python filesys.py, but I'm not running on NT so I'm not entirely sure the fix will work.
A simpler fix is to use long literal:
__highbits = 0xffff0000L
But I did not checked this on NT.
Can't we just use the msvcrt.locking function? Is there a difference to this win32file stuff?
- We can use everything, but it needs to be tested. As long as nobody running Windows is willing to test and fix that stuff, it will simply stay as is.
Workaround
As there seem to be nobody out there using windows as a developer any more, we simply moved the offending code into a separate module that is only imported on win32. So python stops complaining for linux and mac users at least.
And if you are using Windows, just use the fixes from above (just needed for MoinMoin 1.2.x, it is fixed completly in MoinMoin 1.3).
Plan
First, write a test for file locking, so we can test this on NT and confirm that that this fix remove the warning but keeps the file locked. MoinMoin.util.filesys contain some commented test code.
- Priority:
- Assigned to: YOU - if you have access to a machine running windows.
- Will be fixed in release: 1.3