169 # libraries, and sure enough Mercurial is not a library.) |
169 # libraries, and sure enough Mercurial is not a library.) |
170 os.stat_float_times(False) |
170 os.stat_float_times(False) |
171 |
171 |
172 def safehasattr(thing, attr): |
172 def safehasattr(thing, attr): |
173 return getattr(thing, attr, _notset) is not _notset |
173 return getattr(thing, attr, _notset) is not _notset |
|
174 |
|
175 def bytesinput(fin, fout, *args, **kwargs): |
|
176 sin, sout = sys.stdin, sys.stdout |
|
177 try: |
|
178 if pycompat.ispy3: |
|
179 sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout) |
|
180 return encoding.strtolocal(input(*args, **kwargs)) |
|
181 else: |
|
182 sys.stdin, sys.stdout = fin, fout |
|
183 return raw_input(*args, **kwargs) |
|
184 finally: |
|
185 sys.stdin, sys.stdout = sin, sout |
174 |
186 |
175 def bitsfrom(container): |
187 def bitsfrom(container): |
176 bits = 0 |
188 bits = 0 |
177 for bit in container: |
189 for bit in container: |
178 bits |= bit |
190 bits |= bit |