Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred when raising TypeError in mapping function. #21

Closed
HansBug opened this issue Dec 30, 2021 · 0 comments · Fixed by #22
Closed

Error occurred when raising TypeError in mapping function. #21

HansBug opened this issue Dec 30, 2021 · 0 comments · Fixed by #22
Assignees
Labels
bug Something isn't working

Comments

@HansBug
Copy link
Member

HansBug commented Dec 30, 2021

Error occurred when raising TypeError in mapping function.

from treevalue import TreeValue, mapping


def f(x):
    raise TypeError


if __name__ == '__main__':
    t = TreeValue({'a': 1, 'b': 2, 'x': {'c': 3, 'd': 4}})
    t1 = mapping(t, f)

It will cause this wrong error now.

Traceback (most recent call last):
  File "test_p.py", line 10, in <module>
    t1 = mapping(t, f)
  File "treevalue/tree/tree/functional.pyx", line 47, in treevalue.tree.tree.functional.mapping
    cpdef TreeValue mapping(TreeValue tree, object func):
  File "treevalue/tree/tree/functional.pyx", line 77, in treevalue.tree.tree.functional.mapping
    return type(tree)(_c_mapping(tree._detach(), _ValuePathFuncWrapper(func), ()))
  File "treevalue/tree/tree/functional.pyx", line 42, in treevalue.tree.tree.functional._c_mapping
    _d_res[k] = func(v, curpath)
  File "treevalue/tree/tree/functional.pyx", line 20, in treevalue.tree.tree.functional._ValuePathFuncWrapper.__call__
    return self.func()
TypeError: f() missing 1 required positional argument: 'x'
@HansBug HansBug added the bug Something isn't working label Dec 30, 2021
@HansBug HansBug added this to the v1.2.0 Release milestone Dec 30, 2021
@HansBug HansBug self-assigned this Dec 30, 2021
@HansBug HansBug linked a pull request Dec 30, 2021 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant