From tunger at mitem.com Fri Jun 1 13:55:54 2018 From: tunger at mitem.com (Tom Unger) Date: Fri, 1 Jun 2018 17:55:54 +0000 Subject: [Python.NET] Finalizers and proper dereference of CPython objects Message-ID: PythonException, PyObjecdt, PyScope have finallizers defined as: ~PyObject() { // We needs to disable Finalizers until it's valid implementation. // Current implementation can produce low probability floating bugs. return; Dispose(); } So the finalizer does not call dispose. Does this mean that I must explicitly Dispose all such objects to ensure no memory leaks? Thanks, Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Thu Jun 7 23:18:28 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Thu, 7 Jun 2018 22:18:28 -0500 Subject: [Python.NET] Finalizers and proper dereference of CPython objects In-Reply-To: References: Message-ID: There is a fix for this but the code review and merging of related PR is not complete yet: https://github.com/pythonnet/pythonnet/issues/541 On Fri, Jun 1, 2018, 12:56 PM Tom Unger wrote: > > > PythonException, PyObjecdt, PyScope have finallizers defined as: > > > > ~PyObject() > > { > > // We needs to disable Finalizers until it's valid > implementation. > > // Current implementation can produce low probability floating > bugs. > > return; > > > > Dispose(); > > } > > > > So the finalizer does not call dispose. Does this mean that I must > explicitly Dispose all such objects to ensure no memory leaks? > > > > Thanks, > > > > Tom > > > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Thu Jun 7 23:22:00 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Thu, 7 Jun 2018 22:22:00 -0500 Subject: [Python.NET] Passing a C# DateTime object to a Python script In-Reply-To: <000c01d3f825$e7ae8910$b70b9b30$@meniscus.co.uk> References: <000c01d3f825$e7ae8910$b70b9b30$@meniscus.co.uk> Message-ID: There is a pythonnet branch with datetime conversion implementation. Is this what you are looking for? https://github.com/QuantConnect/pythonnet/pull/8/files On Wed, May 30, 2018, 2:26 PM Ian Hannah wrote: > Hi, > > > > I have a simple python script: > > > > def test(datetime_or_doy): > > print datetime_or_doy.strftime('%m/%d/%Y') > > > > and I am using Python for .NET to try and call this method as follows: > > > > dynamic np = Py.Import(@"pvlib"); > > double d = np.irradiance.test(DateTime.Now); > > > > and I get the error: > > > > *Python.Runtime.PythonException:* 'AttributeError : 'DateTime' object has > no attribute 'strftime'' > > > > Clearly I need to pass a Python datetime object from the C# code but how > do I do that? > > > > Thanks > > Ian > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Fri Jun 8 23:54:08 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Fri, 8 Jun 2018 22:54:08 -0500 Subject: [Python.NET] New pythonnet presentation from Germany Message-ID: New pythonnet presentation: https://www.slideshare.net/mobile/StefanSchukat/introduction-to-pythonnet https://github.com/sschukat/PyNetExamples -------------- next part -------------- An HTML attachment was scrubbed... URL: From Steve.Ward at oxinst.com Tue Jun 19 11:37:42 2018 From: Steve.Ward at oxinst.com (WARD Steve) Date: Tue, 19 Jun 2018 15:37:42 +0000 Subject: [Python.NET] Cast PyObject to RoutedEventHandler Message-ID: Can anyone tell me how to cast or Convert (or use a TryGet, or As whatever...), a PyObject (a Python function), to a C# RoutedEventHandler? The Python function: def OnStartButton(sender,args): #do stuff pass Thanks Steve ___________________________________________________________________________ This e-mail is confidential and is for the addressee only. Please refer to www.oxinst.com/email-statement for regulatory information. -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Wed Jun 20 00:18:00 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Tue, 19 Jun 2018 23:18:00 -0500 Subject: [Python.NET] Cast PyObject to RoutedEventHandler In-Reply-To: References: Message-ID: Have you tried @clrmethod decorator? https://github.com/pythonnet/pythonnet/blob/master/src/runtime/resources/clr.py#L54 https://github.com/pythonnet/pythonnet/blob/master/src/tests/test_clrmethod.py#L14 On Tue, Jun 19, 2018 at 10:37 AM, WARD Steve wrote: > Can anyone tell me how to cast or Convert (or use a TryGet, or As > whatever?), a PyObject (a Python function), to a C# RoutedEventHandler? > > > > The Python function: > > > > def OnStartButton(sender,args): > > #do stuff > > pass > > > > Thanks > > Steve > ____________________________________________________________ > _______________ > This e-mail is confidential and is for the addressee only. Please refer > to > www.oxinst.com/email-statement for regulatory information. > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Steve.Ward at oxinst.com Thu Jun 21 11:10:05 2018 From: Steve.Ward at oxinst.com (WARD Steve) Date: Thu, 21 Jun 2018 15:10:05 +0000 Subject: [Python.NET] -|EXT|- Re: Cast PyObject to RoutedEventHandler In-Reply-To: References: Message-ID: I tried: import System import System.Windows @clr.clrmethod([System.object, System.Windows.RoutedEventArgs]) def OnStartButton(sender,args): #do stuff pass and get: ?Cannot perform runtime binding on a null referenceAttributeError : object? So I tried subscribing to the Click event from the Python end and that works. However, that?s not so good for me so I tried subclassing Button in C# and debugging what is passed to the Click event when subscribing from Python and sure enough, it is a RoutedEventhandler (even without the @clr.crlmethod decorator). There must be a way to pass-in the method to C#!! Background: this is an application to support simple GUI development in Python. The C# end handles creating and displaying the GUI components which results in very simple Python: # works in IronPython b = app.Button("Start", OnStartButton) # can?t use OnStartButton as argument, have to add this in Python.NET :-( b.Click += OnStartButton By the way I?m using Python.Net with PyScope from my own build. Steve From: PythonDotNet [mailto:pythondotnet-bounces+steve.ward=oxinst.com at python.org] On Behalf Of Denis Akhiyarov Sent: 20 June 2018 05:18 To: A list for users and developers of Python for .NET Subject: -|EXT|- Re: [Python.NET] Cast PyObject to RoutedEventHandler Have you tried @clrmethod decorator? https://github.com/pythonnet/pythonnet/blob/master/src/runtime/resources/clr.py#L54 https://github.com/pythonnet/pythonnet/blob/master/src/tests/test_clrmethod.py#L14 On Tue, Jun 19, 2018 at 10:37 AM, WARD Steve > wrote: Can anyone tell me how to cast or Convert (or use a TryGet, or As whatever?), a PyObject (a Python function), to a C# RoutedEventHandler? The Python function: def OnStartButton(sender,args): #do stuff pass Thanks Steve ___________________________________________________________________________ This e-mail is confidential and is for the addressee only. Please refer to www.oxinst.com/email-statement for regulatory information. _________________________________________________ Python.NET mailing list - PythonDotNet at python.org https://mail.python.org/mailman/listinfo/pythondotnet ___________________________________________________________________________ This e-mail is confidential and is for the addressee only. Please refer to www.oxinst.com/email-statement for regulatory information. -------------- next part -------------- An HTML attachment was scrubbed... URL: