I had to wrap the warning suppression code in a test for the existence
of FutureWarning
because that warning doesn't
exist in Python before 2.3. Gah.
Aha! The warnings module provides a method of filtering out the nasty new warnings :)
Be warned though, the module documentation lies (ok, that's possibly a
little strong ;) and the "message" and "module" arguments to
filterwarnings()
aren't actually a "compiled regular expression" as it states, but a
compileable string. I ended up inserting this code just before I
import portalocker:
import warnings warnings.filterwarnings("ignore", r'hex/oct constants > sys\.maxint .*', FutureWarning, 'portalocker', 0)
And now my unit tests are quiet, except for the calendar problem...
Roundup produces some strange and new output when run under Python 2.3a1. All but one of the unit tests pass. The failure results from a change in the way the calendar module is implemented (it's now mostly implemented by the new datetime module). This means that the following now fails:
>>> calendar.timegm((2003,2,30,0,0,0,0,0,0)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.3/calendar.py", line 216, in timegm days = datetime.date(year, month, day).toordinal() - _EPOCH_ORD ValueError: day is out of range for month
This is a shame. I'm not sure what will happen - I've posted a message to the python list to ask what the options are.
The second bit of fun was that my code has the literal
0xffff0000
in it (as part of the portalocker). This now
generates a FutureWarning, which I've yet to discover how to turn
off. I may resort to a silliness such as 0xffff000 << 8
to get around it, I don't know.
Finally, I have a couple of warnings about assigning to
None
, which is to become a keyword in some future Python
version, and thus will be unassignable. The couple of places that I have
that assignment were in the Zope Page Templates code (as hackish
optimisations). This was an easy fix :)