[ZCM] [ZC] 1621/ 5 Comment "The whrandom module is deprecated in
Python 2.4"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Tue Jul 12 10:06:05 EDT 2005
Issue #1621 Update (Comment) "The whrandom module is deprecated in Python 2.4"
Status Deferred, Zope/bug+solution medium
To followup, visit:
http://www.zope.org/Collectors/Zope/1621
==============================================================
= Comment - Entry #5 by sacco on Jul 12, 2005 10:06 am
> = Comment - Entry #4 by ajung on Jul 12, 2005 9:31 am
>
> Python 2.4 is *not* a supported platform *yet*.
Sure, but whrandom was also deprecated in Python 2.1, Python 2.2, and Python 2.3 , as the Python documentation clearly states.
The fact that it is only in Python 2.4 that a message has been added to remind people that the module is likely to disappear or (more likely) be renamed shortly doesn't make the problem go away.
By apparently continuing to support the use of whrandom without
complaining, Zope will simply help prolong the delay before other
things (e.g. Zope Products and sites) make the switch, which inevitably leads to the situation where:
a) Zope cannot run on the latest version of Python because whrandom no longer exists;
b) whrandom cannot be removed from Zope because too much 3rd
party code depends on it.
Better to start moving towards eliminating whrandom sooner
rather than later ... after all, how difficult is it:
i) replace all occurrences of 'whrandom' with 'random'
ii) replace each call to whrandom's seed function having more
than one argument:
whrandom.seed(a, b, c) ==> whrandom.seed((a,b,c))
whrandom.seed(a, b) ==> whrandom.seed((a,b,))
That's it! You can do something cleverer if you like, but this is
enough.
________________________________________
= Comment - Entry #4 by ajung on Jul 12, 2005 9:31 am
Python 2.4 is *not* a supported platform *yet*.
________________________________________
= Comment - Entry #3 by sacco on Jul 12, 2005 9:13 am
The python documentation for the module,
<URL: http://python.org/doc/current/lib/module-whrandom.html > ,
actually says:
"Deprecated since release 2.1. Use random instead."
However, there problem with simply updating to use random is that in some places (e.g. DTML.py ) whrandom is imported just in
order to give the module security clearance should it be imported
by a document template or Python script. Thus replacing whrandom
with random in the Zope source tree could break third party code
which uses the obsolete module, so there is no easy way to get rid
of that deprecation warning without potentially breaking
somebody's site.
The best way to resolve this is:
1) avoid loading whrandom automatically, but implement a hook
which adds the necessary security clearance automatically if it
is loaded. However, this should be done by somebody who knows the
Zope internals well and should in any case be removed again before
the next major release.
2) Deprecate the whrandom module immediately for use with Zope,
warning that it (or rather its security clearance) will be removed
from the next Zope release.
Personally I'd do both, but in any case remove the module a.s.a.p.
as updating legacy code to use random instead is simple.
________________________________________
= Defer - Entry #2 by ajung on Dec 12, 2004 7:40 am
Status: Pending => Deferred
Python 2.4 is unsupported at this time.
________________________________________
= Request - Entry #1 by juanval on Dec 12, 2004 7:34 am
In Python 2.4 the whrandom module is deprecated. Instead, the random module should be used.
whrandom is used in the following modules:
lib/python/AccessControl/DTML.py
lib/python/Products/ZCatalog/regressiontests/loadmail.py
lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py
lib/python/Products/PythonScripts/help/PythonScript.py
lib/python/RestrictedPython/Utilities.py
lib/python/DocumentTemplate/DT_Util.py
==============================================================
More information about the Zope-Collector-Monitor
mailing list