[Twisted-Python] keyword changed API

Jp Calderone exarkun at divmod.com
Sat Dec 4 10:30:27 MST 2004


On Sat, 4 Dec 2004 18:10:19 +0100, Andrea Arcangeli <andrea at cpushare.com> wrote:
>This fixes a little runtime issue with the new python version:
> 
> --- ./python/htmlizer.py.~1~	2004-11-28 05:00:05.000000000 +0100
> +++ ./python/htmlizer.py	2004-12-04 18:06:06.329802464 +0100
> @@ -22,7 +22,7 @@ class TokenPrinter:
>              type = "identifier"
>              self.parameters = 1
>          elif type == tokenize.NAME:
> -             if keyword.kwdict.has_key(token):
> +             if keyword.iskeyword(token):
>                   type = 'keyword'
>               else:
>                   if self.parameters:
> 
> Not sure what's the right way to fix these things to retain backwards
> compatibility (perhaps checking sys.version_info?).

  keyword.iskeyword existed in Python 2.2.0, so there seem to be no backwards compatibility problems with just switching to that.

  Thanks.

  Jp




More information about the Twisted-Python mailing list