Closed BergLucas closed 4 months ago
The _ObjectProxyMethods
is quite a fragile thing, I agree. It's probably not optimal regarding usability and portability to different subjects. C extensions always cause trouble, also regarding the bytecode instrumentation. However, I appreciate your approach and will happily incorporate in the upcoming Pynguin release.
Hello,
I've tried to fix the bug that I've explained in issue #59.
My solution to the "no signature found" error is just to provide a default method signature that is very generic and that works on every function. This default method signature is only used when the
inspect
module can't find a method signature and it's just to prevent Pynguin from crashing. This creates a signature that is the same as for this function:However, after correcting this error, I came across two others that were very closely related to it, so I've decided to correct them here too.
First, I got :
I've searched online and I think that this module is only available from C code and not from Python code so I've added a condition that skips modules that come from C code if they are not found using the
inspect
module.Then, I got the following error:
This error comes from the
_ObjectProxyMethods
class that overrides the__module__
attribute. I think that normally, the__module__
attribute is defined on the class and not on instances. I tried to create a custom property class that would keep the existing behavior but that would add the normal behavior on the_ObjectProxyMethods
class but that custom property would only work on "normal" methods and not on dunder methods so this idea was abandoned. Instead, I've just added a condition that skips when a__module__
attribute is aproperty
instead of astr
.What do you think of this solution?
Kind regards and have a nice day!