@@ -409,7 +409,7 @@ package py
409
409
410
410
// ParseTupleAndKeywords
411
411
func ParseTupleAndKeywords (args Tuple , kwargs StringDict , format string , kwlist []string , results ... * Object ) {
412
- if len (results ) != len (kwlist ) {
412
+ if kwlist != nil && len (results ) != len (kwlist ) {
413
413
panic ("Internal error: supply the same number of results and kwlist" )
414
414
}
415
415
min , max , name , ops := parseFormat (format )
@@ -455,12 +455,27 @@ func ParseTupleAndKeywords(args Tuple, kwargs StringDict, format string, kwlist
455
455
panic (ExceptionNewf (TypeError , "%s() argument %d must be int, not %s" , name , i + 1 , arg .Type ().Name ))
456
456
}
457
457
* result = arg
458
+ case "d" :
459
+ switch x := arg .(type ) {
460
+ case Int :
461
+ * result = Float (x )
462
+ case Float :
463
+ * result = x
464
+ default :
465
+ panic (ExceptionNewf (TypeError , "%s() argument %d must be float, not %s" , name , i + 1 , arg .Type ().Name ))
466
+ }
467
+
458
468
default :
459
469
panic (ExceptionNewf (TypeError , "Unknown/Unimplemented format character %q in ParseTupleAndKeywords called from %s" , op , name ))
460
470
}
461
471
}
462
472
}
463
473
474
+ // Parse tuple only
475
+ func ParseTuple (args Tuple , format string , results ... * Object ) {
476
+ ParseTupleAndKeywords (args , nil , format , nil , results ... )
477
+ }
478
+
464
479
// Parse the format
465
480
func parseFormat (format string ) (min , max int , name string , ops []string ) {
466
481
name = "function"
0 commit comments