Show More
@@ -208,8 +208,10 b' def replacetokens(tokens, opts):' | |||
|
208 | 208 | fn = t.string |
|
209 | 209 | |
|
210 | 210 | # *attr() builtins don't accept byte strings to 2nd argument. |
|
211 | if (fn in ('getattr', 'setattr', 'hasattr', 'safehasattr') and | |
|
212 | not _isop(i - 1, '.')): | |
|
211 | if fn in ( | |
|
212 | 'getattr', 'setattr', 'hasattr', 'safehasattr', 'wrapfunction', | |
|
213 | 'wrapclass', 'addattr' | |
|
214 | ) and (opts['allow-attr-methods'] or not _isop(i - 1, '.')): | |
|
213 | 215 | arg1idx = _findargnofcall(1) |
|
214 | 216 | if arg1idx is not None: |
|
215 | 217 | _ensuresysstr(arg1idx) |
@@ -276,6 +278,9 b' def main():' | |||
|
276 | 278 | help='edit files in place') |
|
277 | 279 | ap.add_argument('--dictiter', action='store_true', default=False, |
|
278 | 280 | help='rewrite iteritems() and itervalues()'), |
|
281 | ap.add_argument('--allow-attr-methods', action='store_true', | |
|
282 | default=False, | |
|
283 | help='also handle attr*() when they are methods'), | |
|
279 | 284 | ap.add_argument('--treat-as-kwargs', nargs="+", default=[], |
|
280 | 285 | help="ignore kwargs-like objects"), |
|
281 | 286 | ap.add_argument('files', metavar='FILE', nargs='+', help='source file') |
@@ -283,6 +288,7 b' def main():' | |||
|
283 | 288 | opts = { |
|
284 | 289 | 'dictiter': args.dictiter, |
|
285 | 290 | 'treat-as-kwargs': set(args.treat_as_kwargs), |
|
291 | 'allow-attr-methods': args.allow_attr_methods, | |
|
286 | 292 | } |
|
287 | 293 | for fname in args.files: |
|
288 | 294 | if args.inplace: |
General Comments 0
You need to be logged in to leave comments.
Login now