##// END OF EJS Templates
py3: abuse r'' to preserve str-ness of literals passed to __setattr__()
Yuya Nishihara -
r31644:f80d9ddc default
parent child Browse files
Show More
@@ -76,9 +76,9 b' class _demandmod(object):'
76 else:
76 else:
77 head = name
77 head = name
78 after = []
78 after = []
79 object.__setattr__(self, "_data",
79 object.__setattr__(self, r"_data",
80 (head, globals, locals, after, level, set()))
80 (head, globals, locals, after, level, set()))
81 object.__setattr__(self, "_module", None)
81 object.__setattr__(self, r"_module", None)
82 def _extend(self, name):
82 def _extend(self, name):
83 """add to the list of submodules to load"""
83 """add to the list of submodules to load"""
84 self._data[3].append(name)
84 self._data[3].append(name)
@@ -138,7 +138,7 b' class _demandmod(object):'
138 if modref and getattr(modref, head, None) == self:
138 if modref and getattr(modref, head, None) == self:
139 setattr(modref, head, mod)
139 setattr(modref, head, mod)
140
140
141 object.__setattr__(self, "_module", mod)
141 object.__setattr__(self, r"_module", mod)
142
142
143 def __repr__(self):
143 def __repr__(self):
144 if self._module:
144 if self._module:
@@ -342,8 +342,8 b' else:'
342 # unfortunately, f.name is '<fdopen>' at this point -- so we store
342 # unfortunately, f.name is '<fdopen>' at this point -- so we store
343 # the name on this wrapper. We cannot just assign to f.name,
343 # the name on this wrapper. We cannot just assign to f.name,
344 # because that attribute is read-only.
344 # because that attribute is read-only.
345 object.__setattr__(self, 'name', name)
345 object.__setattr__(self, r'name', name)
346 object.__setattr__(self, '_file', f)
346 object.__setattr__(self, r'_file', f)
347
347
348 def __iter__(self):
348 def __iter__(self):
349 return self._file
349 return self._file
@@ -480,7 +480,7 b' class closewrapbase(object):'
480 Do not instantiate outside of the vfs layer.
480 Do not instantiate outside of the vfs layer.
481 """
481 """
482 def __init__(self, fh):
482 def __init__(self, fh):
483 object.__setattr__(self, '_origfh', fh)
483 object.__setattr__(self, r'_origfh', fh)
484
484
485 def __getattr__(self, attr):
485 def __getattr__(self, attr):
486 return getattr(self._origfh, attr)
486 return getattr(self._origfh, attr)
@@ -507,7 +507,7 b' class delayclosedfile(closewrapbase):'
507 """
507 """
508 def __init__(self, fh, closer):
508 def __init__(self, fh, closer):
509 super(delayclosedfile, self).__init__(fh)
509 super(delayclosedfile, self).__init__(fh)
510 object.__setattr__(self, '_closer', closer)
510 object.__setattr__(self, r'_closer', closer)
511
511
512 def __exit__(self, exc_type, exc_value, exc_tb):
512 def __exit__(self, exc_type, exc_value, exc_tb):
513 self._closer.close(self._origfh)
513 self._closer.close(self._origfh)
@@ -618,7 +618,7 b' class checkambigatclosing(closewrapbase)'
618 """
618 """
619 def __init__(self, fh):
619 def __init__(self, fh):
620 super(checkambigatclosing, self).__init__(fh)
620 super(checkambigatclosing, self).__init__(fh)
621 object.__setattr__(self, '_oldstat', util.filestat(fh.name))
621 object.__setattr__(self, r'_oldstat', util.filestat(fh.name))
622
622
623 def _checkambig(self):
623 def _checkambig(self):
624 oldstat = self._oldstat
624 oldstat = self._oldstat
@@ -61,8 +61,8 b' class mixedfilemodewrapper(object):'
61 OPWRITE = 2
61 OPWRITE = 2
62
62
63 def __init__(self, fp):
63 def __init__(self, fp):
64 object.__setattr__(self, '_fp', fp)
64 object.__setattr__(self, r'_fp', fp)
65 object.__setattr__(self, '_lastop', 0)
65 object.__setattr__(self, r'_lastop', 0)
66
66
67 def __getattr__(self, name):
67 def __getattr__(self, name):
68 return getattr(self._fp, name)
68 return getattr(self._fp, name)
@@ -74,42 +74,42 b' class mixedfilemodewrapper(object):'
74 self._fp.seek(0, os.SEEK_CUR)
74 self._fp.seek(0, os.SEEK_CUR)
75
75
76 def seek(self, *args, **kwargs):
76 def seek(self, *args, **kwargs):
77 object.__setattr__(self, '_lastop', self.OPNONE)
77 object.__setattr__(self, r'_lastop', self.OPNONE)
78 return self._fp.seek(*args, **kwargs)
78 return self._fp.seek(*args, **kwargs)
79
79
80 def write(self, d):
80 def write(self, d):
81 if self._lastop == self.OPREAD:
81 if self._lastop == self.OPREAD:
82 self._noopseek()
82 self._noopseek()
83
83
84 object.__setattr__(self, '_lastop', self.OPWRITE)
84 object.__setattr__(self, r'_lastop', self.OPWRITE)
85 return self._fp.write(d)
85 return self._fp.write(d)
86
86
87 def writelines(self, *args, **kwargs):
87 def writelines(self, *args, **kwargs):
88 if self._lastop == self.OPREAD:
88 if self._lastop == self.OPREAD:
89 self._noopeseek()
89 self._noopeseek()
90
90
91 object.__setattr__(self, '_lastop', self.OPWRITE)
91 object.__setattr__(self, r'_lastop', self.OPWRITE)
92 return self._fp.writelines(*args, **kwargs)
92 return self._fp.writelines(*args, **kwargs)
93
93
94 def read(self, *args, **kwargs):
94 def read(self, *args, **kwargs):
95 if self._lastop == self.OPWRITE:
95 if self._lastop == self.OPWRITE:
96 self._noopseek()
96 self._noopseek()
97
97
98 object.__setattr__(self, '_lastop', self.OPREAD)
98 object.__setattr__(self, r'_lastop', self.OPREAD)
99 return self._fp.read(*args, **kwargs)
99 return self._fp.read(*args, **kwargs)
100
100
101 def readline(self, *args, **kwargs):
101 def readline(self, *args, **kwargs):
102 if self._lastop == self.OPWRITE:
102 if self._lastop == self.OPWRITE:
103 self._noopseek()
103 self._noopseek()
104
104
105 object.__setattr__(self, '_lastop', self.OPREAD)
105 object.__setattr__(self, r'_lastop', self.OPREAD)
106 return self._fp.readline(*args, **kwargs)
106 return self._fp.readline(*args, **kwargs)
107
107
108 def readlines(self, *args, **kwargs):
108 def readlines(self, *args, **kwargs):
109 if self._lastop == self.OPWRITE:
109 if self._lastop == self.OPWRITE:
110 self._noopseek()
110 self._noopseek()
111
111
112 object.__setattr__(self, '_lastop', self.OPREAD)
112 object.__setattr__(self, r'_lastop', self.OPREAD)
113 return self._fp.readlines(*args, **kwargs)
113 return self._fp.readlines(*args, **kwargs)
114
114
115 def posixfile(name, mode='r', buffering=-1):
115 def posixfile(name, mode='r', buffering=-1):
General Comments 0
You need to be logged in to leave comments. Login now