Open
Conversation
almarklein
reviewed
Oct 4, 2018
| code.append(self.lf('%s = arguments[0].flx_args;' % args_var)) | ||
| for i, name in enumerate(argnames): | ||
| for i, name in reversed(list(enumerate(argnames))): | ||
| code.append(self.lf('%s = %s[%i];' % (name, args_var, i))) |
Member
There was a problem hiding this comment.
I'm afraid that I don't follow. As far as I can see, the order should not matter, since we do not change arguments[0].flx_args. What am I missing?
Could you add a test for the problem you were having? That would help in understanding this change, and make sure that it's not accidentally broken at a later time :)
Contributor
Author
There was a problem hiding this comment.
@almarklein when you call a function like this one def partial2(a1, a2, *args, **kwargs): your "real" arguments dictionary is in a1 (which is the same with arguments[0]).
The following happens (at least in Chrome):
- You extract **kwargs from arguments[0]
- You extract and assign positional arguments starting with the 1st one (
a1) - So you've just cleared original
arguments[0](a1) by assigning a new value toa1 - You cannot access original
arguments[0]anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23
Problem:
The original order of assignment is **kwargs, a1, a2, *args.
But after assigning
a1(which isarguments[0]) we cannot get more arguments.Solution:
Assign everything in reverse order: **kwargs, *args, a2, a1.
So we "break"
arguments[0]at the very end when we don't need it anymore.