mercurial/util.py
changeset 33839 7d5bc0e5b88f
parent 33820 fa7e30efe05a
child 33852 f18b11534274
equal deleted inserted replaced
33838:48f3e87ce650 33839:7d5bc0e5b88f
   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