-
Notifications
You must be signed in to change notification settings - Fork 16
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
functions appear in stack trace with their original name #55
Comments
If you care about this, I found a way to do this using eval. |
Hello @uriva I am deeply sorry to only see your message just now. With github switching to the "new notifications experience" it seems that a few notifications got lost in the way, or at least I missed some of them. So the answer is yes, this is why makefun was created. from makefun import with_signature
@with_signature('foo()')
def original_foo():
raise Exception()
print(original_foo) yields
You can also apply the decorator programmatically of course: original_foo = with_signature('foo()')(original_foo) Note that using Does that answer your question ? |
Hi @uriva , did the above answer work for you ? |
Still on my backlog, but I think I will get to it at some point. |
Hey, looking into this today. I have a working solution (which is slow): https://gist.github.com/uriva/04333004f2379e959197993ed416b1e1 Can I do this using this lib? i.e. given a function, just rename it, but don't change its signature? When I same "rename" I mean rename so stack trace shows its new name, I don't care about other stuff (so just changing |
Ok I understand your problem : you would like the frame in the stack trace to be available with the appropriate name. So with the code below and putting a breakpoint inside the original function : from makefun import with_signature
@with_signature('foo()')
def original_foo():
raise Exception()
print(original_foo)
original_foo() you do not like this: Apparently the absence of frame for the created wrapper is due to the fact that I create it with If you find a way to add something to this function so that it does what you want do not hesitate to propose a PR ! |
When running this:
I want
foo
to be the name of the function in the stack trace. Any way I can achieve that using this lib?The text was updated successfully, but these errors were encountered: