[Twisted-Python] How to handle arguments with undocumented types and argument deprecation
Adi Roiban
adi at roiban.ro
Sun Oct 25 02:34:15 MDT 2015
Hi,
This message is based on https://twistedmatrix.com/trac/ticket/5911#comment:14
In twisted/web/http.py we have the addCookie method which has the
'max_age' argument.
In the current code, the max_age is used as just anything which can be
converted into a text.
cookie = cookie +"; Max-Age=%s" % max_age
The latest patch documents max_age as requiring an int and adds tests
for the addCookie method... so to handly Py3 support the code looks
like this:
cookie = cookie + b"; Max-Age=" + intToBytes(max_age)
-----------
Should this code continue to handle str/int/long ?
---------
Is there a way to deprecate a single argument from a method/function?
Since max_age does not comply with the coding convention, can we
deprecated max_age with support for str/int/log and create a new
maxAge argument which only supports bytes.
Thanks!
--
Adi Roiban
More information about the Twisted-Python
mailing list