[Python-3000] telnetlib [was: Question about PEP 3001 and fixing API flaws]

Jim Jewett jimjjewett at gmail.com
Fri Mar 23 16:27:53 CET 2007


On 3/21/07, BJörn Lindqvist <bjourne at gmail.com> wrote:

> I think so too. Aliasing names is easy to do, but uglifies things.
> Plus, if you do it that way, can you still emit DeprecationWarnings?

Sure.

    def oldname(arg):
        "Deprecated version of newname"
        warn("Use newname instead", DeprecationWarning)
        return newname(arg)

> The patches eliminate the set.option_callback variable and the
> Telnetlib.set_option_negotiation_callback() method. The problem has an
> extra twist because the old way is mutually exclusive with the new
> way. Or well, you could support them both but that would make the
> class extra ugly.

Not really.   The default handle_option could look for (and call) a
callback.  If you don't want to mess with refixing the sbdataq, you
could just change the call sites.  Right now, they already all say

    if self.option_callback:
        self.option_callback(...)
    else:
        # fallback

Make that either

    # Support the deprecated callback in 2.6
    if self.option_callback:
        self.option_callback(...)
    else:
        self.handle_option(...)

or

    # Support the deprecated callback in 2.6
    if self.option_callback:
        self.option_callback(...)
    elif not self.handle_option(...):
        # fallback

-jJ


More information about the Python-3000 mailing list