[PATCH 4 of 6] byteify-strings: broaden handling of attr* functions
Raphaël Gomès
raphael.gomes at octobus.net
Fri Aug 2 04:22:15 EDT 2019
# HG changeset patch
# User Raphaël Gomès <rgomes at octobus.net>
# Date 1564733030 -7200
# Fri Aug 02 10:03:50 2019 +0200
# Node ID edff9054a1a327d3d444d4acfde0879a92742549
# Parent 2ba0327a754304b371c06d84a80ab1871e02fa66
# EXP-Topic byteify-strings
byteify-strings: broaden handling of attr* functions
The current safeguard that makes sure that `getattr`, etc. is not a method is
too restrictive as it is easy to ignore wrappers use as `util.getattr`.
This change also adds other "good candidates": `wrapfunction`, `wrapclass`
and `addattr`.
diff -r 2ba0327a7543 -r edff9054a1a3 contrib/byteify-strings.py
--- a/contrib/byteify-strings.py Fri Aug 02 09:55:32 2019 +0200
+++ b/contrib/byteify-strings.py Fri Aug 02 10:03:50 2019 +0200
@@ -178,8 +178,10 @@
fn = t.string
# *attr() builtins don't accept byte strings to 2nd argument.
- if (fn in ('getattr', 'setattr', 'hasattr', 'safehasattr') and
- not _isop(i - 1, '.')):
+ if fn in (
+ 'getattr', 'setattr', 'hasattr', 'safehasattr', 'wrapfunction',
+ 'wrapclass', 'addattr'
+ ):
arg1idx = _findargnofcall(1)
if arg1idx is not None:
_ensuresysstr(arg1idx)
More information about the Mercurial-devel
mailing list