Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 36636:c263c684da91
py3: conditionalize initialization of stdio flags
Since Python 3 doesn't depend on the stdio of libc, there should be no need
to set O_BINARY flag on Windows.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 02 Mar 2018 22:10:36 -0500 |
parents | 8b662717c53f |
children | e8c361316803 |
comparison
equal
deleted
inserted
replaced
36635:e80f8a134731 | 36636:c263c684da91 |
---|---|
103 req.ui.ferr.flush() | 103 req.ui.ferr.flush() |
104 # There's not much we can do about an I/O error here. So (possibly) | 104 # There's not much we can do about an I/O error here. So (possibly) |
105 # change the status code and move on. | 105 # change the status code and move on. |
106 except IOError: | 106 except IOError: |
107 status = -1 | 107 status = -1 |
108 | |
109 sys.exit(status & 255) | 108 sys.exit(status & 255) |
110 | 109 |
111 def _initstdio(): | 110 if pycompat.ispy3: |
112 for fp in (sys.stdin, sys.stdout, sys.stderr): | 111 def _initstdio(): |
113 util.setbinary(fp) | 112 pass |
113 else: | |
114 def _initstdio(): | |
115 for fp in (sys.stdin, sys.stdout, sys.stderr): | |
116 util.setbinary(fp) | |
114 | 117 |
115 def _getsimilar(symbols, value): | 118 def _getsimilar(symbols, value): |
116 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() | 119 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() |
117 # The cutoff for similarity here is pretty arbitrary. It should | 120 # The cutoff for similarity here is pretty arbitrary. It should |
118 # probably be investigated and tweaked. | 121 # probably be investigated and tweaked. |