Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/statprof.py @ 30583:c6ce11f2ee50
py3: make a bytes version of getopt.getopt()
getopt.getopt() deals with unicodes on Python 3 internally and if bytes
arguments are passed, then it will return TypeError. So we have now
pycompat.getoptb() which takes bytes arguments, convert them to unicode, call
getopt.getopt() and then convert the returned value back to bytes and then
return those value.
All the instances of getopt.getopt() are replaced with pycompat.getoptb().
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 06 Dec 2016 06:36:36 +0530 |
parents | bb35fe8621f5 |
children | 344e68882cd3 |
comparison
equal
deleted
inserted
replaced
30582:6146d5acee69 | 30583:c6ce11f2ee50 |
---|---|
113 import signal | 113 import signal |
114 import sys | 114 import sys |
115 import tempfile | 115 import tempfile |
116 import threading | 116 import threading |
117 import time | 117 import time |
118 | |
119 from . import ( | |
120 pycompat, | |
121 ) | |
118 | 122 |
119 defaultdict = collections.defaultdict | 123 defaultdict = collections.defaultdict |
120 contextmanager = contextlib.contextmanager | 124 contextmanager = contextlib.contextmanager |
121 | 125 |
122 __all__ = ['start', 'stop', 'reset', 'display', 'profile'] | 126 __all__ = ['start', 'stop', 'reset', 'display', 'profile'] |
769 printusage() | 773 printusage() |
770 return 0 | 774 return 0 |
771 | 775 |
772 # process options | 776 # process options |
773 try: | 777 try: |
774 opts, args = getopt.getopt(sys.argv[optstart:], "hl:f:o:p:", | 778 opts, args = pycompat.getoptb(sys.argv[optstart:], "hl:f:o:p:", |
775 ["help", "limit=", "file=", "output-file=", "script-path="]) | 779 ["help", "limit=", "file=", "output-file=", "script-path="]) |
776 except getopt.error as msg: | 780 except getopt.error as msg: |
777 print(msg) | 781 print(msg) |
778 printusage() | 782 printusage() |
779 return 2 | 783 return 2 |