@@ -329,7 +329,7 @@ private static Object[] createAndCheckArguments(PythonObject callable, Object[]
329
329
330
330
if (too_many_args ) {
331
331
// the node acts as a profile
332
- throw handleTooManyArguments (scope_w , callable , signature , co_argcount , co_kwonlyargcount , defaults .length , avail , methodcall , handleTooMany );
332
+ throw handleTooManyArguments (scope_w , callable , signature , co_argcount , co_kwonlyargcount , defaults .length , avail , methodcall , handleTooMany , self instanceof PythonModule ? 1 : 0 );
333
333
}
334
334
335
335
boolean more_filling = input_argcount < co_argcount + co_kwonlyargcount ;
@@ -355,8 +355,8 @@ private static void applyKeywords(Object callable, Signature signature, Object[]
355
355
}
356
356
357
357
private static PException handleTooManyArguments (Object [] scope_w , Object callable , Signature signature , int co_argcount , int co_kwonlyargcount , int ndefaults , int avail , boolean methodcall ,
358
- HandleTooManyArgumentsNode node ) {
359
- return node .execute (scope_w , callable , signature , co_argcount , co_kwonlyargcount , ndefaults , avail , methodcall );
358
+ HandleTooManyArgumentsNode node , int adjustCount ) {
359
+ return node .execute (scope_w , callable , signature , co_argcount , co_kwonlyargcount , ndefaults , avail , methodcall , adjustCount );
360
360
}
361
361
362
362
private static void fillDefaults (Object callable , Signature signature , Object [] scope_w , Object [] defaults , int input_argcount , int co_argcount , FillDefaultsNode node ) {
@@ -372,12 +372,13 @@ private static void fillKwDefaults(Object callable, Object[] scope_w, Signature
372
372
@ GenerateUncached
373
373
protected abstract static class HandleTooManyArgumentsNode extends PNodeWithContext {
374
374
375
- public abstract PException execute (Object [] scope_w , Object callable , Signature signature , int co_argcount , int co_kwonlyargcount , int ndefaults , int avail , boolean methodcall );
375
+ public abstract PException execute (Object [] scope_w , Object callable , Signature signature , int co_argcount , int co_kwonlyargcount , int ndefaults , int avail , boolean methodcall ,
376
+ int adjustCount );
376
377
377
378
@ Specialization (guards = {"co_kwonlyargcount == cachedKwOnlyArgCount" })
378
379
@ ExplodeLoop
379
380
PException doCached (Object [] scope_w , Object callable , Signature signature , int co_argcount , @ SuppressWarnings ("unused" ) int co_kwonlyargcount , int ndefaults , int avail ,
380
- boolean methodcall ,
381
+ boolean methodcall , int adjustCount ,
381
382
@ Cached PRaiseNode raise ,
382
383
@ Cached ("co_kwonlyargcount" ) int cachedKwOnlyArgCount ) {
383
384
int kwonly_given = 0 ;
@@ -386,23 +387,21 @@ PException doCached(Object[] scope_w, Object callable, Signature signature, int
386
387
kwonly_given += 1 ;
387
388
}
388
389
}
389
-
390
390
boolean forgotSelf = methodcall && avail + 1 == co_argcount && (signature .getParameterIds ().length == 0 || !signature .getParameterIds ()[0 ].equals ("self" ));
391
- throw raiseTooManyArguments (callable , co_argcount , ndefaults , avail , forgotSelf , kwonly_given , raise );
391
+ throw raiseTooManyArguments (callable , co_argcount - adjustCount , ndefaults , avail - adjustCount , forgotSelf , kwonly_given , raise );
392
392
}
393
393
394
394
@ Specialization (replaces = "doCached" )
395
- PException doUncached (Object [] scope_w , Object callable , Signature signature , int co_argcount , int co_kwonlyargcount , int ndefaults , int avail , boolean methodcall ,
395
+ PException doUncached (Object [] scope_w , Object callable , Signature signature , int co_argcount , int co_kwonlyargcount , int ndefaults , int avail , boolean methodcall , int adjustCount ,
396
396
@ Cached PRaiseNode raise ) {
397
397
int kwonly_given = 0 ;
398
398
for (int i = 0 ; i < co_kwonlyargcount ; i ++) {
399
399
if (PArguments .getArgument (scope_w , co_argcount + i ) != null ) {
400
400
kwonly_given += 1 ;
401
401
}
402
402
}
403
-
404
403
boolean forgotSelf = methodcall && avail + 1 == co_argcount && (signature .getParameterIds ().length == 0 || !signature .getParameterIds ()[0 ].equals ("self" ));
405
- throw raiseTooManyArguments (callable , co_argcount , ndefaults , avail , forgotSelf , kwonly_given , raise );
404
+ throw raiseTooManyArguments (callable , co_argcount - adjustCount , ndefaults , avail - adjustCount , forgotSelf , kwonly_given , raise );
406
405
}
407
406
408
407
private static PException raiseTooManyArguments (Object callable , int co_argcount , int ndefaults , int avail , boolean forgotSelf , int kwonly_given , PRaiseNode raise ) {
0 commit comments