contrib/byteify-strings.py
changeset 45942 89a2afe31e82
parent 44559 bc9a9016467d
child 48875 6000f5b25c9b
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
   211         # This looks like a function call.
   211         # This looks like a function call.
   212         if t.type == token.NAME and _isop(i + 1, '('):
   212         if t.type == token.NAME and _isop(i + 1, '('):
   213             fn = t.string
   213             fn = t.string
   214 
   214 
   215             # *attr() builtins don't accept byte strings to 2nd argument.
   215             # *attr() builtins don't accept byte strings to 2nd argument.
   216             if fn in (
   216             if (
   217                 'getattr',
   217                 fn
   218                 'setattr',
   218                 in (
   219                 'hasattr',
   219                     'getattr',
   220                 'safehasattr',
   220                     'setattr',
   221                 'wrapfunction',
   221                     'hasattr',
   222                 'wrapclass',
   222                     'safehasattr',
   223                 'addattr',
   223                     'wrapfunction',
   224             ) and (opts['allow-attr-methods'] or not _isop(i - 1, '.')):
   224                     'wrapclass',
       
   225                     'addattr',
       
   226                 )
       
   227                 and (opts['allow-attr-methods'] or not _isop(i - 1, '.'))
       
   228             ):
   225                 arg1idx = _findargnofcall(1)
   229                 arg1idx = _findargnofcall(1)
   226                 if arg1idx is not None:
   230                 if arg1idx is not None:
   227                     _ensuresysstr(arg1idx)
   231                     _ensuresysstr(arg1idx)
   228 
   232 
   229             # .encode() and .decode() on str/bytes/unicode don't accept
   233             # .encode() and .decode() on str/bytes/unicode don't accept