[PATCH 6 of 7] py3: abuse r'' to preserve str-ness of literals passed to __setattr__()
Yuya Nishihara
yuya at tcha.org
Sun Mar 26 07:59:49 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1490513592 -32400
# Sun Mar 26 16:33:12 2017 +0900
# Node ID c00753c42a0b04dc72ed831a87945f1eb41c84c1
# Parent 5e8e48cb4f83a583515b4caaf97045b86747c499
py3: abuse r'' to preserve str-ness of literals passed to __setattr__()
diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -76,9 +76,9 @@ class _demandmod(object):
else:
head = name
after = []
- object.__setattr__(self, "_data",
+ object.__setattr__(self, r"_data",
(head, globals, locals, after, level, set()))
- object.__setattr__(self, "_module", None)
+ object.__setattr__(self, r"_module", None)
def _extend(self, name):
"""add to the list of submodules to load"""
self._data[3].append(name)
@@ -138,7 +138,7 @@ class _demandmod(object):
if modref and getattr(modref, head, None) == self:
setattr(modref, head, mod)
- object.__setattr__(self, "_module", mod)
+ object.__setattr__(self, r"_module", mod)
def __repr__(self):
if self._module:
diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -342,8 +342,8 @@ else:
# unfortunately, f.name is '<fdopen>' at this point -- so we store
# the name on this wrapper. We cannot just assign to f.name,
# because that attribute is read-only.
- object.__setattr__(self, 'name', name)
- object.__setattr__(self, '_file', f)
+ object.__setattr__(self, r'name', name)
+ object.__setattr__(self, r'_file', f)
def __iter__(self):
return self._file
diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -480,7 +480,7 @@ class closewrapbase(object):
Do not instantiate outside of the vfs layer.
"""
def __init__(self, fh):
- object.__setattr__(self, '_origfh', fh)
+ object.__setattr__(self, r'_origfh', fh)
def __getattr__(self, attr):
return getattr(self._origfh, attr)
@@ -507,7 +507,7 @@ class delayclosedfile(closewrapbase):
"""
def __init__(self, fh, closer):
super(delayclosedfile, self).__init__(fh)
- object.__setattr__(self, '_closer', closer)
+ object.__setattr__(self, r'_closer', closer)
def __exit__(self, exc_type, exc_value, exc_tb):
self._closer.close(self._origfh)
@@ -618,7 +618,7 @@ class checkambigatclosing(closewrapbase)
"""
def __init__(self, fh):
super(checkambigatclosing, self).__init__(fh)
- object.__setattr__(self, '_oldstat', util.filestat(fh.name))
+ object.__setattr__(self, r'_oldstat', util.filestat(fh.name))
def _checkambig(self):
oldstat = self._oldstat
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -61,8 +61,8 @@ class mixedfilemodewrapper(object):
OPWRITE = 2
def __init__(self, fp):
- object.__setattr__(self, '_fp', fp)
- object.__setattr__(self, '_lastop', 0)
+ object.__setattr__(self, r'_fp', fp)
+ object.__setattr__(self, r'_lastop', 0)
def __getattr__(self, name):
return getattr(self._fp, name)
@@ -74,42 +74,42 @@ class mixedfilemodewrapper(object):
self._fp.seek(0, os.SEEK_CUR)
def seek(self, *args, **kwargs):
- object.__setattr__(self, '_lastop', self.OPNONE)
+ object.__setattr__(self, r'_lastop', self.OPNONE)
return self._fp.seek(*args, **kwargs)
def write(self, d):
if self._lastop == self.OPREAD:
self._noopseek()
- object.__setattr__(self, '_lastop', self.OPWRITE)
+ object.__setattr__(self, r'_lastop', self.OPWRITE)
return self._fp.write(d)
def writelines(self, *args, **kwargs):
if self._lastop == self.OPREAD:
self._noopeseek()
- object.__setattr__(self, '_lastop', self.OPWRITE)
+ object.__setattr__(self, r'_lastop', self.OPWRITE)
return self._fp.writelines(*args, **kwargs)
def read(self, *args, **kwargs):
if self._lastop == self.OPWRITE:
self._noopseek()
- object.__setattr__(self, '_lastop', self.OPREAD)
+ object.__setattr__(self, r'_lastop', self.OPREAD)
return self._fp.read(*args, **kwargs)
def readline(self, *args, **kwargs):
if self._lastop == self.OPWRITE:
self._noopseek()
- object.__setattr__(self, '_lastop', self.OPREAD)
+ object.__setattr__(self, r'_lastop', self.OPREAD)
return self._fp.readline(*args, **kwargs)
def readlines(self, *args, **kwargs):
if self._lastop == self.OPWRITE:
self._noopseek()
- object.__setattr__(self, '_lastop', self.OPREAD)
+ object.__setattr__(self, r'_lastop', self.OPREAD)
return self._fp.readlines(*args, **kwargs)
def posixfile(name, mode='r', buffering=-1):
More information about the Mercurial-devel
mailing list