diff --git a/contrib/byteify-strings.py b/contrib/byteify-strings.py --- a/contrib/byteify-strings.py +++ b/contrib/byteify-strings.py @@ -212,18 +212,14 @@ def replacetokens(tokens, opts): fn = t.string # *attr() builtins don't accept byte strings to 2nd argument. - if ( - fn - in ( - 'getattr', - 'setattr', - 'hasattr', - 'safehasattr', - 'wrapfunction', - 'wrapclass', - 'addattr', - ) - and (opts['allow-attr-methods'] or not _isop(i - 1, '.')) + if fn in ( + 'getattr', + 'setattr', + 'hasattr', + 'safehasattr', + 'wrapfunction', + 'wrapclass', + 'addattr', ): arg1idx = _findargnofcall(1) if arg1idx is not None: @@ -312,12 +308,6 @@ def main(): help='rewrite iteritems() and itervalues()', ), ap.add_argument( - '--allow-attr-methods', - action='store_true', - default=False, - help='also handle attr*() when they are methods', - ), - ap.add_argument( '--treat-as-kwargs', nargs="+", default=[], @@ -328,7 +318,6 @@ def main(): opts = { 'dictiter': args.dictiter, 'treat-as-kwargs': set(args.treat_as_kwargs), - 'allow-attr-methods': args.allow_attr_methods, } for fname in args.files: fname = os.path.realpath(fname) diff --git a/tests/test-byteify-strings.t b/tests/test-byteify-strings.t --- a/tests/test-byteify-strings.t +++ b/tests/test-byteify-strings.t @@ -110,19 +110,6 @@ Test attr*() as methods > def f(): > pass > EOF - $ byteify_strings testfile.py --allow-attr-methods - setattr(o, 'a', 1) - util.setattr(o, 'ae', 1) - util.getattr(o, 'alksjdf', b'default') - util.addattr(o, 'asdf') - util.hasattr(o, 'lksjdf', b'default') - util.safehasattr(o, 'lksjdf', b'default') - @eh.wrapfunction(func, 'lksjdf') - def f(): - pass - @eh.wrapclass(klass, 'lksjdf') - def f(): - pass Test without attr*() as methods @@ -142,15 +129,15 @@ Test without attr*() as methods > EOF $ byteify_strings testfile.py setattr(o, 'a', 1) - util.setattr(o, b'ae', 1) - util.getattr(o, b'alksjdf', b'default') - util.addattr(o, b'asdf') - util.hasattr(o, b'lksjdf', b'default') - util.safehasattr(o, b'lksjdf', b'default') - @eh.wrapfunction(func, b'lksjdf') + util.setattr(o, 'ae', 1) + util.getattr(o, 'alksjdf', b'default') + util.addattr(o, 'asdf') + util.hasattr(o, 'lksjdf', b'default') + util.safehasattr(o, 'lksjdf', b'default') + @eh.wrapfunction(func, 'lksjdf') def f(): pass - @eh.wrapclass(klass, b'lksjdf') + @eh.wrapclass(klass, 'lksjdf') def f(): pass