@@ -68,7 +68,7 @@ def getopt(args, shortopts, longopts = []):
68
68
if args [0 ] == '--' :
69
69
args = args [1 :]
70
70
break
71
- if args [0 ][: 2 ] == '--' :
71
+ if args [0 ]. startswith ( '--' ) :
72
72
opts , args = do_longs (opts , args [0 ][2 :], longopts , args [1 :])
73
73
else :
74
74
opts , args = do_shorts (opts , args [0 ][1 :], shortopts , args [1 :])
@@ -124,7 +124,8 @@ def do_shorts(opts, optstring, shortopts, args):
124
124
if short_has_arg (opt , shortopts ):
125
125
if optstring == '' :
126
126
if not args :
127
- raise GetoptError ('option -%s requires argument' % opt , opt )
127
+ raise GetoptError ('option -%s requires argument' % opt ,
128
+ opt )
128
129
optstring , args = args [0 ], args [1 :]
129
130
optarg , optstring = optstring , ''
130
131
else :
@@ -135,7 +136,7 @@ def do_shorts(opts, optstring, shortopts, args):
135
136
def short_has_arg (opt , shortopts ):
136
137
for i in range (len (shortopts )):
137
138
if opt == shortopts [i ] != ':' :
138
- return shortopts [ i + 1 : i + 2 ] == ':'
139
+ return shortopts . startswith ( ':' , i + 1 )
139
140
raise GetoptError ('option -%s not recognized' % opt , opt )
140
141
141
142
if __name__ == '__main__' :
0 commit comments