403
403
404
404
package py
405
405
406
- import (
407
- "fmt"
408
- )
409
-
410
406
// ParseTupleAndKeywords
411
407
func ParseTupleAndKeywords (args Tuple , kwargs StringDict , format string , kwlist []string , results ... * Object ) {
412
408
if len (results ) != len (kwlist ) {
@@ -423,7 +419,7 @@ func ParseTupleAndKeywords(args Tuple, kwargs StringDict, format string, kwlist
423
419
goto found
424
420
}
425
421
}
426
- panic (fmt . Sprintf ( " TypeError: %s() got an unexpected keyword argument '%s'" , name , kwargName ))
422
+ panic (ExceptionNewf ( TypeError , " %s() got an unexpected keyword argument '%s'" , name , kwargName ))
427
423
found:
428
424
}
429
425
@@ -432,8 +428,7 @@ func ParseTupleAndKeywords(args Tuple, kwargs StringDict, format string, kwlist
432
428
for i , kw := range kwlist {
433
429
if value , ok := kwargs [kw ]; ok {
434
430
if len (args ) >= i {
435
- // FIXME type error
436
- panic (fmt .Sprintf ("TypeError: %s() got multiple values for argument '%s'" , name , kw ))
431
+ panic (ExceptionNewf (TypeError , "%s() got multiple values for argument '%s'" , name , kw ))
437
432
}
438
433
args = append (args , value )
439
434
}
@@ -448,12 +443,11 @@ func ParseTupleAndKeywords(args Tuple, kwargs StringDict, format string, kwlist
448
443
* result = arg
449
444
case "U" :
450
445
if _ , ok := arg .(String ); ! ok {
451
- // FIXME type error
452
- panic (fmt .Sprintf ("TypeError: %s() argument %d must be str, not %s" , name , i + 1 , arg .Type ().Name ))
446
+ panic (ExceptionNewf (TypeError , "%s() argument %d must be str, not %s" , name , i + 1 , arg .Type ().Name ))
453
447
}
454
448
* result = arg
455
449
default :
456
- panic (fmt . Sprintf ( "Unknown/Unimplemented format character %q in ParseTupleAndKeywords called from %s" , op , name ))
450
+ panic (ExceptionNewf ( TypeError , "Unknown/Unimplemented format character %q in ParseTupleAndKeywords called from %s" , op , name ))
457
451
}
458
452
}
459
453
}
@@ -490,17 +484,14 @@ func parseFormat(format string) (min, max int, name string, ops []string) {
490
484
func checkNumberOfArgs (name string , nargs , nresults , min , max int ) {
491
485
if min == max {
492
486
if nargs != max {
493
- // FIXME type error
494
- panic (fmt .Sprintf ("TypeError: %s() takes exactly %d arguments (%d given)" , name , max , nargs ))
487
+ panic (ExceptionNewf (TypeError , "%s() takes exactly %d arguments (%d given)" , name , max , nargs ))
495
488
}
496
489
} else {
497
490
if nargs > max {
498
- // FIXME type error
499
- panic (fmt .Sprintf ("TypeError: %s() takes at most %d arguments (%d given)" , name , max , nargs ))
491
+ panic (ExceptionNewf (TypeError , "%s() takes at most %d arguments (%d given)" , name , max , nargs ))
500
492
}
501
493
if nargs < min {
502
- // FIXME type error
503
- panic (fmt .Sprintf ("TypeError: %s() takes at least %d arguments (%d given)" , name , min , nargs ))
494
+ panic (ExceptionNewf (TypeError , "%s() takes at least %d arguments (%d given)" , name , min , nargs ))
504
495
}
505
496
}
506
497
@@ -514,8 +505,7 @@ func checkNumberOfArgs(name string, nargs, nresults, min, max int) {
514
505
// Up to the caller to set default values
515
506
func UnpackTuple (args Tuple , kwargs StringDict , name string , min int , max int , results ... * Object ) {
516
507
if len (kwargs ) != 0 {
517
- // FIXME type error
518
- panic (fmt .Sprintf ("TypeError: %s() does not take keyword arguments" , name ))
508
+ panic (ExceptionNewf (TypeError , "%s() does not take keyword arguments" , name ))
519
509
}
520
510
521
511
// Check number of arguments
0 commit comments