You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with adding attributes to .Net classes being unstable. E.g.
from System import TimeSpan
TimeSpan.my_method = lambda self: self.TotalMinutes
ts = TimeSpan.FromHours(1)
ts.my_method()
This code will sometimes work and other times fail with the exception 'TimeSpan' object has no attribute 'my_method'.
The failure rate is variable and for some scripts/program it will work all the time while for others it will not work at all. It seems to fail a lot more often on Python 3.5 than on Python 3.4.
If I look at either dir(ts) or ts.__class__.__dict__ the method is there even when the call to my_method fails.
I have tried to look into the PythonNet code for clues, but as far as I can see the new attribute is registered by MetaType. tp_setattro without error, but the method is still not found.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
I have a problem with adding attributes to .Net classes being unstable. E.g.
This code will sometimes work and other times fail with the exception 'TimeSpan' object has no attribute 'my_method'.
The failure rate is variable and for some scripts/program it will work all the time while for others it will not work at all. It seems to fail a lot more often on Python 3.5 than on Python 3.4.
If I look at either
dir(ts)
orts.__class__.__dict__
the method is there even when the call to my_method fails.I have tried to look into the PythonNet code for clues, but as far as I can see the new attribute is registered by MetaType. tp_setattro without error, but the method is still not found.
The text was updated successfully, but these errors were encountered: