From techieth at gmail.com Wed Apr 4 00:23:58 2018 From: techieth at gmail.com (techi eth) Date: Wed, 4 Apr 2018 09:53:58 +0530 Subject: [Python.NET] crash in pythonnet Message-ID: Hi, I am trying to run python for NET but finding crash while running test. I am trying to run test from src/tests/. System Setup : Host : Ubuntu14.04 Python : Python2.7 Mono : Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC 2018) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: x86 Disabled: none Misc: softdebug Interpreter: yes LLVM: supported, not enabled. GC: sgen (concurrent by default) I am getting below error. *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** Stacktrace: at <0xffffffff> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize () <0x00012> at Python.Runtime.Runtime.Initialize () [0x0000a] in :0 at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1,bool) [0x00014] in :0 at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in :0 at Python.Runtime.PythonEngine.InitExt () [0x00000] in :0 at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) [0x0001e] in <65984520577646ec9044386ec4a7b3dd>:0 Attached core dump for more details. Please give me hint what is wrong. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- python2.7 runtests.py Load clr import hook *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** Stacktrace: at <0xffffffff> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize () <0x00012> at Python.Runtime.Runtime.Initialize () [0x0000a] in :0 at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1,bool) [0x00014] in :0 at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in :0 at Python.Runtime.PythonEngine.InitExt () [0x00000] in :0 at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) [0x0001e] in <65984520577646ec9044386ec4a7b3dd>:0 /proc/self/maps: 00010000-00081000 rw-p 00000000 00:00 0 08048000-082ee000 r-xp 00000000 08:01 918521 /usr/bin/python2.7 082ee000-082ef000 r--p 002a5000 08:01 918521 /usr/bin/python2.7 082ef000-0834e000 rw-p 002a6000 08:01 918521 /usr/bin/python2.7 0834e000-0835a000 rw-p 00000000 00:00 0 08dce000-0906a000 rw-p 00000000 00:00 0 [heap] b57db000-b5a9c000 r-xp 00000000 08:01 927810 /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 b5a9c000-b5a9d000 r--p 002c0000 08:01 927810 /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 b5a9d000-b5afc000 rw-p 002c1000 08:01 927810 /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 b5afc000-b5b08000 rw-p 00000000 00:00 0 b5b08000-b5c00000 r--p 00000000 08:01 424739 /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll b5c00000-b5c21000 rw-p 00000000 00:00 0 b5c21000-b5d00000 ---p 00000000 00:00 0 b5d37000-b5d77000 rw-p 00000000 00:00 0 b5d77000-b5d87000 rwxp 00000000 00:00 0 b5d87000-b5da9000 r--p 00000000 08:01 17971 /usr/local/lib/python2.7/dist-packages/Python.Runtime.dll b5da9000-b5db2000 ---p 00000000 00:00 0 b5db2000-b5eaa000 rw-p 00000000 00:00 0 [stack:11175] b5eaa000-b5eba000 rwxp 00000000 00:00 0 b5eba000-b6285000 r--p 00000000 08:01 1066901 /usr/lib/mono/4.5/mscorlib.dll b6285000-b6286000 rw-p 00000000 00:00 0 b6286000-b62b5000 ---p 00000000 00:00 0 b62b5000-b62b6000 ---p 00000000 00:00 0 b62b6000-b6ab6000 rw-p 00000000 00:00 0 [stack:11174] b6ab6000-b6eaf000 r-xp 00000000 08:01 941334 /usr/lib/libmonoboehm-2.0.so.1.0.0 b6eaf000-b6eb3000 r--p 003f9000 08:01 941334 /usr/lib/libmonoboehm-2.0.so.1.0.0 b6eb3000-b6eb6000 rw-p 003fd000 08:01 941334 /usr/lib/libmonoboehm-2.0.so.1.0.0 b6eb6000-b6f07000 rw-p 00000000 00:00 0 b6f07000-b709b000 r-xp 00000000 08:01 148881 /lib/i386-linux-gnu/libcrypto.so.1.0.0 b709b000-b70aa000 r--p 00194000 08:01 148881 /lib/i386-linux-gnu/libcrypto.so.1.0.0 b70aa000-b70b1000 rw-p 001a3000 08:01 148881 /lib/i386-linux-gnu/libcrypto.so.1.0.0 b70b1000-b70b4000 rw-p 00000000 00:00 0 b70bf000-b70c1000 rw-p 00000000 00:00 0 b70c1000-b70d1000 rwxp 00000000 00:00 0 b70d1000-b72b2000 rw-p 00000000 00:00 0 b72b2000-b74b2000 r--p 00000000 08:01 927577 /usr/lib/locale/locale-archive b74b2000-b7574000 rw-p 00000000 00:00 0 b7574000-b75b8000 r-xp 00000000 08:01 160804 /lib/i386-linux-gnu/libm-2.19.so b75b8000-b75b9000 r--p 00043000 08:01 160804 /lib/i386-linux-gnu/libm-2.19.so b75b9000-b75ba000 rw-p 00044000 08:01 160804 /lib/i386-linux-gnu/libm-2.19.so b75ba000-b75d2000 r-xp 00000000 08:01 132254 /lib/i386-linux-gnu/libz.so.1.2.8 b75d2000-b75d3000 r--p 00017000 08:01 132254 /lib/i386-linux-gnu/libz.so.1.2.8 b75d3000-b75d4000 rw-p 00018000 08:01 132254 /lib/i386-linux-gnu/libz.so.1.2.8 b75d4000-b75d6000 r-xp 00000000 08:01 154727 /lib/i386-linux-gnu/libutil-2.19.so b75d6000-b75d7000 r--p 00001000 08:01 154727 /lib/i386-linux-gnu/libutil-2.19.so b75d7000-b75d8000 rw-p 00002000 08:01 154727 /lib/i386-linux-gnu/libutil-2.19.so b75d8000-b75db000 r-xp 00000000 08:01 160814 /lib/i386-linux-gnu/libdl-2.19.so b75db000-b75dc000 r--p 00002000 08:01 160814 /lib/i386-linux-gnu/libdl-2.19.so b75dc000-b75dd000 rw-p 00003000 08:01 160814 /lib/i386-linux-gnu/libdl-2.19.so b75dd000-b75de000 rw-p 00000000 00:00 0 b75de000-b7789000 r-xp 00000000 08:01 160805 /lib/i386-linux-gnu/libc-2.19.so b7789000-b778b000 r--p 001aa000 08:01 160805 /lib/i386-linux-gnu/libc-2.19.so b778b000-b778c000 rw-p 001ac000 08:01 160805 /lib/i386-linux-gnu/libc-2.19.so b778c000-b778f000 rw-p 00000000 00:00 0 b778f000-b77a7000 r-xp 00000000 08:01 160811 /lib/i386-linux-gnu/libpthread-2.19.so b77a7000-b77a8000 r--p 00018000 08:01 160811 /lib/i386-linux-gnu/libpthread-2.19.so b77a8000-b77a9000 rw-p 00019000 08:01 160811 /lib/i386-linux-gnu/libpthread-2.19.so b77a9000-b77b3000 rw-p 00000000 00:00 0 b77b3000-b77b4000 rw-s 00000000 00:15 27903 /run/shm/mono.11173 b77b4000-b77bb000 r-xp 00000000 08:01 160815 /lib/i386-linux-gnu/librt-2.19.so b77bb000-b77bc000 r--p 00006000 08:01 160815 /lib/i386-linux-gnu/librt-2.19.so b77bc000-b77bd000 rw-p 00007000 08:01 160815 /lib/i386-linux-gnu/librt-2.19.so b77bd000-b77bf000 r-xp 00000000 08:01 17972 /usr/local/lib/python2.7/dist-packages/clr.so b77bf000-b77c0000 r--p 00001000 08:01 17972 /usr/local/lib/python2.7/dist-packages/clr.so b77c0000-b77c1000 rw-p 00002000 08:01 17972 /usr/local/lib/python2.7/dist-packages/clr.so b77c1000-b77c2000 rw-p 00000000 00:00 0 b77c2000-b77c5000 r-xp 00000000 08:01 1052070 /usr/lib/python2.7/lib-dynload/_hashlib.i386-linux-gnu.so b77c5000-b77c6000 r--p 00002000 08:01 1052070 /usr/lib/python2.7/lib-dynload/_hashlib.i386-linux-gnu.so b77c6000-b77c7000 rw-p 00003000 08:01 1052070 /usr/lib/python2.7/lib-dynload/_hashlib.i386-linux-gnu.so b77c7000-b77c8000 r--p 00855000 08:01 927577 /usr/lib/locale/locale-archive b77c8000-b77ca000 rw-p 00000000 00:00 0 b77ca000-b77cb000 r-xp 00000000 00:00 0 [vdso] b77cb000-b77cd000 r--p 00000000 00:00 0 [vvar] b77cd000-b77ed000 r-xp 00000000 08:01 160818 /lib/i386-linux-gnu/ld-2.19.so b77ed000-b77ee000 r--p 0001f000 08:01 160818 /lib/i386-linux-gnu/ld-2.19.so b77ee000-b77ef000 rw-p 00020000 08:01 160818 /lib/i386-linux-gnu/ld-2.19.so bf7d9000-bf7e1000 ---p 00000000 00:00 0 bffb7000-bffd8000 rw-p 00000000 00:00 0 [stack] Native stacktrace: /usr/lib/libmonoboehm-2.0.so.1(+0xe2b83) [0xb6b98b83] /usr/lib/libmonoboehm-2.0.so.1(+0x17c4fe) [0xb6c324fe] [0xb77cad34] [0xb77cad4c] /lib/i386-linux-gnu/libc.so.6(gsignal+0x47) [0xb760c687] /lib/i386-linux-gnu/libc.so.6(abort+0x143) [0xb760fab3] /lib/i386-linux-gnu/libc.so.6(+0x68fd3) [0xb7646fd3] /lib/i386-linux-gnu/libc.so.6(+0x734ca) [0xb76514ca] /lib/i386-linux-gnu/libc.so.6(+0x741bd) [0xb76521bd] /usr/lib/i386-linux-gnu/libpython2.7.so(PyString_InternInPlace+0x97) [0xb5952997] /usr/lib/i386-linux-gnu/libpython2.7.so(PyString_InternFromString+0x2f) [0xb58eed2f] /usr/lib/i386-linux-gnu/libpython2.7.so(PyType_Ready+0xb50) [0xb594df20] /usr/lib/i386-linux-gnu/libpython2.7.so(_Py_ReadyTypes+0xcd) [0xb5955cbd] /usr/lib/i386-linux-gnu/libpython2.7.so(Py_InitializeEx+0x6d) [0xb590092d] /usr/lib/i386-linux-gnu/libpython2.7.so(Py_Initialize+0x1b) [0xb59012cb] [0xb5d777f0] [0xb5d77194] [0xb5eab5e0] [0xb5eab31c] [0xb5eab148] [0xb5eab285] /usr/lib/libmonoboehm-2.0.so.1(+0x3f109) [0xb6af5109] Debug info from gdb: [New LWP 11175] [New LWP 11174] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". 0xb77cad4c in __kernel_vsyscall () Id Target Id Frame 3 Thread 0xb6ab5b40 (LWP 11174) "python2.7" 0xb77cad4c in __kernel_vsyscall () 2 Thread 0xb5ea9b40 (LWP 11175) "Finalizer" 0xb77cad4c in __kernel_vsyscall () * 1 Thread 0xb7572700 (LWP 11173) "python2.7" 0xb77cad4c in __kernel_vsyscall () Thread 3 (Thread 0xb6ab5b40 (LWP 11174)): #0 0xb77cad4c in __kernel_vsyscall () #1 0xb7799d0b in pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187 #2 0xb6d91827 in GC_wait_marker () from /usr/lib/libmonoboehm-2.0.so.1 #3 0xb6d891b9 in GC_help_marker () from /usr/lib/libmonoboehm-2.0.so.1 #4 0xb6d8fe46 in GC_mark_thread () from /usr/lib/libmonoboehm-2.0.so.1 #5 0xb7795f72 in start_thread (arg=0xb6ab5b40) at pthread_create.c:312 #6 0xb76cc3ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129 Thread 2 (Thread 0xb5ea9b40 (LWP 11175)): #0 0xb77cad4c in __kernel_vsyscall () #1 0xb779c0f5 in sem_wait@@GLIBC_2.1 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/sem_wait.S:79 #2 0xb6d4e83a in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #3 0xb6d09926 in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #4 0xb6d913a7 in GC_start_routine () from /usr/lib/libmonoboehm-2.0.so.1 #5 0xb7795f72 in start_thread (arg=0xb5ea9b40) at pthread_create.c:312 #6 0xb76cc3ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129 Thread 1 (Thread 0xb7572700 (LWP 11173)): #0 0xb77cad4c in __kernel_vsyscall () #1 0xb779dc9b in waitpid () at ../sysdeps/unix/syscall-template.S:81 #2 0xb6b98c9c in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #3 0xb6c324fe in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #4 #5 0xb77cad4c in __kernel_vsyscall () #6 0xb760c687 in __GI_raise (sig=sig at entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #7 0xb760fab3 in __GI_abort () at abort.c:89 #8 0xb7646fd3 in __libc_message (do_abort=do_abort at entry=1, fmt=fmt at entry=0xb774617c "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175 #9 0xb76514ca in malloc_printerr (action=, str=0xb7741cd2 "free(): invalid pointer", ptr=0xb5d37120) at malloc.c:4998 #10 0xb76521bd in _int_free (av=0xb778b420 , p=, have_lock=0) at malloc.c:3842 #11 0xb5952997 in PyString_InternInPlace () from /usr/lib/i386-linux-gnu/libpython2.7.so #12 0xb58eed2f in PyString_InternFromString () from /usr/lib/i386-linux-gnu/libpython2.7.so #13 0xb594df20 in PyType_Ready () from /usr/lib/i386-linux-gnu/libpython2.7.so #14 0xb5955cbd in _Py_ReadyTypes () from /usr/lib/i386-linux-gnu/libpython2.7.so #15 0xb590092d in Py_InitializeEx () from /usr/lib/i386-linux-gnu/libpython2.7.so #16 0xb59012cb in Py_Initialize () from /usr/lib/i386-linux-gnu/libpython2.7.so #17 0xb5d777f0 in ?? () #18 0xb5d77194 in ?? () #19 0xb5eab5e0 in ?? () #20 0xb5eab31c in ?? () #21 0xb5eab148 in ?? () #22 0xb5eab285 in ?? () #23 0xb6af5109 in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #24 0xb6ce1b92 in ?? () from /usr/lib/libmonoboehm-2.0.so.1 #25 0xb6ce3efe in mono_runtime_invoke () from /usr/lib/libmonoboehm-2.0.so.1 #26 0xb77be49c in main_thread_handler (user_data=user_data at entry=0x8f46128) at src/monoclr/pynetinit.c:228 #27 0xb77be694 in PyNet_Init (ext=ext at entry=1) at src/monoclr/pynetinit.c:50 #28 0xb77be741 in _initclr () at src/monoclr/clrmod.c:46 #29 initclr () at src/monoclr/clrmod.c:68 #30 0x0806c157 in _PyImport_LoadDynamicModule () #31 0x081ef540 in ?? () #32 0x0819a95f in ?? () #33 0x0819af37 in ?? () #34 0x0819b264 in ?? () #35 0x08171d86 in ?? () #36 0x08161aa9 in PyEval_CallObjectWithKeywords () #37 0x08142237 in PyEval_EvalFrameEx () #38 0x0816f9ae in ?? () #39 0x080a1a37 in PyRun_FileExFlags () #40 0x080a2004 in PyRun_SimpleFileExFlags () #41 0x080a2d61 in Py_Main () #42 0x080a2e40 in main () ================================================================= Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. ================================================================= Aborted (core dumped) From denis.akhiyarov at gmail.com Wed Apr 4 00:39:52 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Tue, 3 Apr 2018 23:39:52 -0500 Subject: [Python.NET] crash in pythonnet In-Reply-To: References: Message-ID: can you try previous mono versions? On Tue, Apr 3, 2018 at 11:23 PM, techi eth wrote: > Hi, > > > > I am trying to run python for NET but finding crash while running test. I > am trying to run test from src/tests/. > > > > System Setup : > > Host : Ubuntu14.04 > > Python : Python2.7 > > Mono : > > Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC 2018) > > Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. > www.mono-project.com > > TLS: __thread > > SIGSEGV: altstack > > Notifications: epoll > > Architecture: x86 > > Disabled: none > > Misc: softdebug > > Interpreter: yes > > LLVM: supported, not enabled. > > GC: sgen (concurrent by default) > > > > I am getting below error. > > > > *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** > > Stacktrace: > > > > at <0xffffffff> > > at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize () > <0x00012> > > at Python.Runtime.Runtime.Initialize () [0x0000a] in < > f0f76ef5431f474889e54afa364b2312>:0 > > at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1,bool) > [0x00014] in :0 > > at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in < > f0f76ef5431f474889e54afa364b2312>:0 > > at Python.Runtime.PythonEngine.InitExt () [0x00000] in < > f0f76ef5431f474889e54afa364b2312>:0 > > at (wrapper runtime-invoke) object.runtime_invoke_void > (object,intptr,intptr,intptr) [0x0001e] in <65984520577646ec9044386ec4a7b3 > dd>:0 > > > > Attached core dump for more details. > > Please give me hint what is wrong. > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Wed Apr 4 01:04:19 2018 From: techieth at gmail.com (techi eth) Date: Wed, 4 Apr 2018 10:34:19 +0530 Subject: [Python.NET] crash in pythonnet In-Reply-To: References: Message-ID: Initially i tried with default mono (3.8 -> Ubunut14.04 default) version but i was not able to build pythonfornet. Later i tried with 4.2.2 version,i am able to build but got similar crash. than i though to test with latest mono but still got crash. Could you please let me know i can get anywhere compatible version w.r.t to mono/python/pythonnet or any other dependencies. Please let me know which version from below link you are referring. http://www.mono-project.com/docs/about-mono/releases/ Thanks On Wed, Apr 4, 2018 at 10:09 AM, Denis Akhiyarov wrote: > can you try previous mono versions? > > On Tue, Apr 3, 2018 at 11:23 PM, techi eth wrote: > >> Hi, >> >> >> >> I am trying to run python for NET but finding crash while running test. I >> am trying to run test from src/tests/. >> >> >> >> System Setup : >> >> Host : Ubuntu14.04 >> >> Python : Python2.7 >> >> Mono : >> >> Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC 2018) >> >> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. >> www.mono-project.com >> >> TLS: __thread >> >> SIGSEGV: altstack >> >> Notifications: epoll >> >> Architecture: x86 >> >> Disabled: none >> >> Misc: softdebug >> >> Interpreter: yes >> >> LLVM: supported, not enabled. >> >> GC: sgen (concurrent by default) >> >> >> >> I am getting below error. >> >> >> >> *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** >> >> Stacktrace: >> >> >> >> at <0xffffffff> >> >> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize () >> <0x00012> >> >> at Python.Runtime.Runtime.Initialize () [0x0000a] in >> :0 >> >> at Python.Runtime.PythonEngine.Initialize ( >> System.Collections.Generic.IEnumerable`1,bool) [0x00014] in >> :0 >> >> at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in >> :0 >> >> at Python.Runtime.PythonEngine.InitExt () [0x00000] in >> :0 >> >> at (wrapper runtime-invoke) object.runtime_invoke_void >> (object,intptr,intptr,intptr) [0x0001e] in <65984520577646ec9044386ec4a7b >> 3dd>:0 >> >> >> >> Attached core dump for more details. >> >> Please give me hint what is wrong. >> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > > _________________________________________________ > 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 Wed Apr 4 01:09:38 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Wed, 04 Apr 2018 05:09:38 +0000 Subject: [Python.NET] crash in pythonnet In-Reply-To: References: Message-ID: See the Travis CI builds of pythonnet on GitHub for the current version of Mono passing the tests. On Wed, Apr 4, 2018, 12:04 AM techi eth wrote: > Initially i tried with default mono (3.8 -> Ubunut14.04 default) version > but i was not able to build pythonfornet. Later i tried with 4.2.2 > version,i am able to build but got similar crash. > than i though to test with latest mono but still got crash. > Could you please let me know i can get anywhere compatible version w.r.t > to mono/python/pythonnet or any other dependencies. > > Please let me know which version from below link you are referring. > http://www.mono-project.com/docs/about-mono/releases/ > > Thanks > > On Wed, Apr 4, 2018 at 10:09 AM, Denis Akhiyarov < > denis.akhiyarov at gmail.com> wrote: > >> can you try previous mono versions? >> >> On Tue, Apr 3, 2018 at 11:23 PM, techi eth wrote: >> >>> Hi, >>> >>> >>> >>> I am trying to run python for NET but finding crash while running test. >>> I am trying to run test from src/tests/. >>> >>> >>> >>> System Setup : >>> >>> Host : Ubuntu14.04 >>> >>> Python : Python2.7 >>> >>> Mono : >>> >>> Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC >>> 2018) >>> >>> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. >>> www.mono-project.com >>> >>> TLS: __thread >>> >>> SIGSEGV: altstack >>> >>> Notifications: epoll >>> >>> Architecture: x86 >>> >>> Disabled: none >>> >>> Misc: softdebug >>> >>> Interpreter: yes >>> >>> LLVM: supported, not enabled. >>> >>> GC: sgen (concurrent by default) >>> >>> >>> >>> I am getting below error. >>> >>> >>> >>> *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** >>> >>> Stacktrace: >>> >>> >>> >>> at <0xffffffff> >>> >>> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize >>> () <0x00012> >>> >>> at Python.Runtime.Runtime.Initialize () [0x0000a] in >>> :0 >>> >>> at Python.Runtime.PythonEngine.Initialize ( >>> System.Collections.Generic.IEnumerable`1,bool) [0x00014] in >>> :0 >>> >>> at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in >>> :0 >>> >>> at Python.Runtime.PythonEngine.InitExt () [0x00000] in >>> :0 >>> >>> at (wrapper runtime-invoke) object.runtime_invoke_void >>> (object,intptr,intptr,intptr) [0x0001e] in >>> <65984520577646ec9044386ec4a7b3dd>:0 >>> >>> >>> >>> Attached core dump for more details. >>> >>> Please give me hint what is wrong. >>> >>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Wed Apr 4 01:55:00 2018 From: techieth at gmail.com (techi eth) Date: Wed, 4 Apr 2018 11:25:00 +0530 Subject: [Python.NET] crash in pythonnet In-Reply-To: References: Message-ID: It is same version what i am using. I assume it could be something else. Can any one have working setup on ubuntu14.04 with mono & python version. Configure option for mono or python have any relation ? On Wed, Apr 4, 2018 at 10:39 AM, Denis Akhiyarov wrote: > See the Travis CI builds of pythonnet on GitHub for the current version of > Mono passing the tests. > > > On Wed, Apr 4, 2018, 12:04 AM techi eth wrote: > >> Initially i tried with default mono (3.8 -> Ubunut14.04 default) version >> but i was not able to build pythonfornet. Later i tried with 4.2.2 >> version,i am able to build but got similar crash. >> than i though to test with latest mono but still got crash. >> Could you please let me know i can get anywhere compatible version w.r.t >> to mono/python/pythonnet or any other dependencies. >> >> Please let me know which version from below link you are referring. >> http://www.mono-project.com/docs/about-mono/releases/ >> >> Thanks >> >> On Wed, Apr 4, 2018 at 10:09 AM, Denis Akhiyarov < >> denis.akhiyarov at gmail.com> wrote: >> >>> can you try previous mono versions? >>> >>> On Tue, Apr 3, 2018 at 11:23 PM, techi eth wrote: >>> >>>> Hi, >>>> >>>> >>>> >>>> I am trying to run python for NET but finding crash while running test. >>>> I am trying to run test from src/tests/. >>>> >>>> >>>> >>>> System Setup : >>>> >>>> Host : Ubuntu14.04 >>>> >>>> Python : Python2.7 >>>> >>>> Mono : >>>> >>>> Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC >>>> 2018) >>>> >>>> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. >>>> www.mono-project.com >>>> >>>> TLS: __thread >>>> >>>> SIGSEGV: altstack >>>> >>>> Notifications: epoll >>>> >>>> Architecture: x86 >>>> >>>> Disabled: none >>>> >>>> Misc: softdebug >>>> >>>> Interpreter: yes >>>> >>>> LLVM: supported, not enabled. >>>> >>>> GC: sgen (concurrent by default) >>>> >>>> >>>> >>>> I am getting below error. >>>> >>>> >>>> >>>> *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** >>>> >>>> Stacktrace: >>>> >>>> >>>> >>>> at <0xffffffff> >>>> >>>> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize >>>> () <0x00012> >>>> >>>> at Python.Runtime.Runtime.Initialize () [0x0000a] in < >>>> f0f76ef5431f474889e54afa364b2312>:0 >>>> >>>> at Python.Runtime.PythonEngine.Initialize ( >>>> System.Collections.Generic.IEnumerable`1,bool) [0x00014] in < >>>> f0f76ef5431f474889e54afa364b2312>:0 >>>> >>>> at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in < >>>> f0f76ef5431f474889e54afa364b2312>:0 >>>> >>>> at Python.Runtime.PythonEngine.InitExt () [0x00000] in < >>>> f0f76ef5431f474889e54afa364b2312>:0 >>>> >>>> at (wrapper runtime-invoke) object.runtime_invoke_void >>>> (object,intptr,intptr,intptr) [0x0001e] in < >>>> 65984520577646ec9044386ec4a7b3dd>:0 >>>> >>>> >>>> >>>> Attached core dump for more details. >>>> >>>> Please give me hint what is wrong. >>>> >>>> >>>> _________________________________________________ >>>> Python.NET mailing list - PythonDotNet at python.org >>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>> >>>> >>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> > > _________________________________________________ > 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 Wed Apr 4 22:40:20 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Wed, 4 Apr 2018 21:40:20 -0500 Subject: [Python.NET] crash in pythonnet In-Reply-To: References: Message-ID: No, it is different Mono version, see this issue: https://github.com/pythonnet/pythonnet/issues/654 Try opening a PR to pythonnet on github with updated Mono version and see if Travis CI fails. On Wed, Apr 4, 2018 at 12:55 AM, techi eth wrote: > It is same version what i am using. I assume it could be something else. > Can any one have working setup on ubuntu14.04 with mono & python version. > > Configure option for mono or python have any relation ? > > On Wed, Apr 4, 2018 at 10:39 AM, Denis Akhiyarov < > denis.akhiyarov at gmail.com> wrote: > >> See the Travis CI builds of pythonnet on GitHub for the current version >> of Mono passing the tests. >> >> >> On Wed, Apr 4, 2018, 12:04 AM techi eth wrote: >> >>> Initially i tried with default mono (3.8 -> Ubunut14.04 default) version >>> but i was not able to build pythonfornet. Later i tried with 4.2.2 >>> version,i am able to build but got similar crash. >>> than i though to test with latest mono but still got crash. >>> Could you please let me know i can get anywhere compatible version w.r.t >>> to mono/python/pythonnet or any other dependencies. >>> >>> Please let me know which version from below link you are referring. >>> http://www.mono-project.com/docs/about-mono/releases/ >>> >>> Thanks >>> >>> On Wed, Apr 4, 2018 at 10:09 AM, Denis Akhiyarov < >>> denis.akhiyarov at gmail.com> wrote: >>> >>>> can you try previous mono versions? >>>> >>>> On Tue, Apr 3, 2018 at 11:23 PM, techi eth wrote: >>>> >>>>> Hi, >>>>> >>>>> >>>>> >>>>> I am trying to run python for NET but finding crash while running >>>>> test. I am trying to run test from src/tests/. >>>>> >>>>> >>>>> >>>>> System Setup : >>>>> >>>>> Host : Ubuntu14.04 >>>>> >>>>> Python : Python2.7 >>>>> >>>>> Mono : >>>>> >>>>> Mono JIT compiler version 5.10.1.20 (tarball Thu Mar 29 10:42:14 UTC >>>>> 2018) >>>>> >>>>> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. >>>>> www.mono-project.com >>>>> >>>>> TLS: __thread >>>>> >>>>> SIGSEGV: altstack >>>>> >>>>> Notifications: epoll >>>>> >>>>> Architecture: x86 >>>>> >>>>> Disabled: none >>>>> >>>>> Misc: softdebug >>>>> >>>>> Interpreter: yes >>>>> >>>>> LLVM: supported, not enabled. >>>>> >>>>> GC: sgen (concurrent by default) >>>>> >>>>> >>>>> >>>>> I am getting below error. >>>>> >>>>> >>>>> >>>>> *** Error in `python2.7': free(): invalid pointer: 0xb5d37120 *** >>>>> >>>>> Stacktrace: >>>>> >>>>> >>>>> >>>>> at <0xffffffff> >>>>> >>>>> at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize >>>>> () <0x00012> >>>>> >>>>> at Python.Runtime.Runtime.Initialize () [0x0000a] in >>>>> :0 >>>>> >>>>> at Python.Runtime.PythonEngine.Initialize ( >>>>> System.Collections.Generic.IEnumerable`1,bool) [0x00014] in >>>>> :0 >>>>> >>>>> at Python.Runtime.PythonEngine.Initialize (bool) [0x00005] in >>>>> :0 >>>>> >>>>> at Python.Runtime.PythonEngine.InitExt () [0x00000] in >>>>> :0 >>>>> >>>>> at (wrapper runtime-invoke) object.runtime_invoke_void >>>>> (object,intptr,intptr,intptr) [0x0001e] in <65984520577646ec9044386ec4a7b >>>>> 3dd>:0 >>>>> >>>>> >>>>> >>>>> Attached core dump for more details. >>>>> >>>>> Please give me hint what is wrong. >>>>> >>>>> >>>>> _________________________________________________ >>>>> Python.NET mailing list - PythonDotNet at python.org >>>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>>> >>>>> >>>> >>>> _________________________________________________ >>>> Python.NET mailing list - PythonDotNet at python.org >>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>> >>>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Mon Apr 16 00:19:49 2018 From: techieth at gmail.com (techi eth) Date: Mon, 16 Apr 2018 09:49:49 +0530 Subject: [Python.NET] How to use C# object[] in python Message-ID: I am trying to use one of data struct class defined in c# dll to python script. I am facing difficulty in adding c# object under payload. Can anyone give me hint or any example which will useful for assigning payload under object array. public class TestPayload { public string RequestId { get; set; } public byte[] ServiceIds { get; set; } public object[] Payload { get; set; } public bool IsStatus { get; set; } public long ExpiryDateTime { get; set; } } Note : I am able to add other parameter defined in class & pass from python script to c#. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Mon Apr 16 07:30:47 2018 From: techieth at gmail.com (techi eth) Date: Mon, 16 Apr 2018 17:00:47 +0530 Subject: [Python.NET] Runtime.Py_Main function call Message-ID: Calling below function resulting thread launch from C# process or it is new process itself. Runtime.Py_Main(cmd.Length, cmd) I am referring console example for nPython.exe. Below is code snippet. public static int Main(string[] args) { // reference the static assemblyLoader to stop it being optimized away AssemblyLoader a = assemblyLoader; string[] cmd = Environment.GetCommandLineArgs(); PythonEngine.Initialize(); int i = Runtime.Py_Main(cmd.Length, cmd); PythonEngine.Shutdown(); return i; } Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Wed Apr 18 02:23:03 2018 From: techieth at gmail.com (techi eth) Date: Wed, 18 Apr 2018 11:53:03 +0530 Subject: [Python.NET] How to pass Out parameter Message-ID: Hi I have once class function in C# which is expecting out parameter. How can I pass out parameter from python. Below is signature of function. public void GetOutData(string InputData, out bool isHavingParams, out string Parm1, out int32 Parm2, out object Parm3) -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Wed Apr 18 09:20:07 2018 From: techieth at gmail.com (techi eth) Date: Wed, 18 Apr 2018 18:50:07 +0530 Subject: [Python.NET] How to use C# object[] in python In-Reply-To: References: Message-ID: Any hint or input on raised query will be helpful. Thanks On Mon, Apr 16, 2018 at 9:49 AM, techi eth wrote: > I am trying to use one of data struct class defined in c# dll to python > script. I am facing difficulty in adding c# object under payload. Can > anyone give me hint or any example which will useful for assigning payload > under object array. > > > > public class TestPayload > > { > > public string RequestId { get; set; } > > public byte[] ServiceIds { get; set; } > > public object[] Payload { get; set; } > > public bool IsStatus { get; set; } > > public long ExpiryDateTime { get; set; } > > } > > > > Note : I am able to add other parameter defined in class & pass from > python script to c#. > > > > Thanks > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Wed Apr 18 11:27:08 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Wed, 18 Apr 2018 15:27:08 +0000 Subject: [Python.NET] How to use C# object[] in python In-Reply-To: References: Message-ID: Is this a problem only for array of objects or the object itself? Might be this issue: https://github.com/pythonnet/pythonnet/issues/94 On Wed, Apr 18, 2018, 8:20 AM techi eth wrote: > Any hint or input on raised query will be helpful. > > Thanks > > On Mon, Apr 16, 2018 at 9:49 AM, techi eth wrote: > >> I am trying to use one of data struct class defined in c# dll to python >> script. I am facing difficulty in adding c# object under payload. Can >> anyone give me hint or any example which will useful for assigning payload >> under object array. >> >> >> >> public class TestPayload >> >> { >> >> public string RequestId { get; set; } >> >> public byte[] ServiceIds { get; set; } >> >> public object[] Payload { get; set; } >> >> public bool IsStatus { get; set; } >> >> public long ExpiryDateTime { get; set; } >> >> } >> >> >> >> Note : I am able to add other parameter defined in class & pass from >> python script to c#. >> >> >> >> Thanks >> >> > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Fri Apr 20 04:14:13 2018 From: techieth at gmail.com (techi eth) Date: Fri, 20 Apr 2018 13:44:13 +0530 Subject: [Python.NET] How to use C# object[] in python In-Reply-To: References: Message-ID: Thanks. that helps to me.Now i am able to pass Object & Object array from python to C# On Wed, Apr 18, 2018 at 8:57 PM, Denis Akhiyarov wrote: > Is this a problem only for array of objects or the object itself? > > Might be this issue: > > https://github.com/pythonnet/pythonnet/issues/94 > > On Wed, Apr 18, 2018, 8:20 AM techi eth wrote: > >> Any hint or input on raised query will be helpful. >> >> Thanks >> >> On Mon, Apr 16, 2018 at 9:49 AM, techi eth wrote: >> >>> I am trying to use one of data struct class defined in c# dll to python >>> script. I am facing difficulty in adding c# object under payload. Can >>> anyone give me hint or any example which will useful for assigning payload >>> under object array. >>> >>> >>> >>> public class TestPayload >>> >>> { >>> >>> public string RequestId { get; set; } >>> >>> public byte[] ServiceIds { get; set; } >>> >>> public object[] Payload { get; set; } >>> >>> public bool IsStatus { get; set; } >>> >>> public long ExpiryDateTime { get; set; } >>> >>> } >>> >>> >>> >>> Note : I am able to add other parameter defined in class & pass from >>> python script to c#. >>> >>> >>> >>> Thanks >>> >>> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Fri Apr 20 04:14:59 2018 From: techieth at gmail.com (techi eth) Date: Fri, 20 Apr 2018 13:44:59 +0530 Subject: [Python.NET] Garbage collector with Pyhton using PyhtonForNet Message-ID: I would like to know how the data structure of C# dll defined in python will get cleared from system memory. Any link or detail will be helpful to understand memory leak cased when using dotnet with python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Wed Apr 25 08:38:01 2018 From: techieth at gmail.com (techi eth) Date: Wed, 25 Apr 2018 18:08:01 +0530 Subject: [Python.NET] Error in calling Python class method from C# Message-ID: Hi, I am facing issue while calling python class function in C# programme. Can anyone give me hint what is wrong in below programme.While running I am getting error in invoking Initialize() function of class. Python module : def test(): print "Test called" return 1 class ClassTest: def __init__(self) def Initialize (): print " Initialize called" return 1 @staticmethod def Execute(): print "Execute called" return 1 C# Console Programme code snapshot : PythonEngine.Initialize(); using (Py.GIL()) { PyObject testClassModule = PythonEngine.ImportModule("Class"); //Calling module method PyObject result = testClassModule.InvokeMethod("test"); Console.WriteLine("Test method result = {0}", result.ToString()); PyObject classTest = testClassModule.GetAttr("ClassTest"); *classTest.InvokeMethod("Initialize "); -----------------------------> Error* classTest.InvokeMethod("Execute"); } PythonEngine.Shutdown(); -------------- next part -------------- An HTML attachment was scrubbed... URL: From SSchukat at dspace.de Thu Apr 26 07:24:14 2018 From: SSchukat at dspace.de (Stefan Schukat) Date: Thu, 26 Apr 2018 11:24:14 +0000 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: Message-ID: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Hello, you missed either @staticmethod decorator or the self argument for the Initialize method. Stefan From: PythonDotNet [mailto:pythondotnet-bounces+sschukat=dspace.de at python.org] On Behalf Of techi eth Sent: Wednesday, April 25, 2018 2:38 PM To: A list for users and developers of Python for .NET Subject: [Python.NET] Error in calling Python class method from C# Hi, I am facing issue while calling python class function in C# programme. Can anyone give me hint what is wrong in below programme.While running I am getting error in invoking Initialize() function of class. Python module : def test(): print "Test called" return 1 class ClassTest: def __init__(self) def Initialize (): print " Initialize called" return 1 @staticmethod def Execute(): print "Execute called" return 1 C# Console Programme code snapshot : PythonEngine.Initialize(); using (Py.GIL()) { PyObject testClassModule = PythonEngine.ImportModule("Class"); //Calling module method PyObject result = testClassModule.InvokeMethod("test"); Console.WriteLine("Test method result = {0}", result.ToString()); PyObject classTest = testClassModule.GetAttr("ClassTest"); classTest.InvokeMethod("Initialize "); -----------------------------> Error classTest.InvokeMethod("Execute"); } PythonEngine.Shutdown(); -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Thu Apr 26 08:17:02 2018 From: techieth at gmail.com (techi eth) Date: Thu, 26 Apr 2018 17:47:02 +0530 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: Yes,It will work with this way but i need to create multiple instance of same class.If you see other function (@Execute() ) with static was working. Please give me hint of doing without static. Thanks On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat wrote: > Hello, > > > > you missed either @staticmethod decorator or the self argument for the > Initialize method. > > > > Stefan > > > > *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= > dspace.de at python.org] *On Behalf Of *techi eth > *Se**nt:* Wednesday, April 25, 2018 2:38 PM > *To:* A list for users and developers of Python for .NET < > pythondotnet at python.org> > *Subject:* [Python.NET] Error in calling Python class method from C# > > > > Hi, > > > > I am facing issue while calling python class function in C# programme. Can > anyone give me hint what is wrong in below programme.While running I am > getting error in invoking Initialize() function of class. > > > > Python module : > > def test(): > > print "Test called" > > return 1 > > > > class ClassTest: > > def __init__(self) > > > > def Initialize (): > > print " Initialize called" > > return 1 > > > > @staticmethod > > def Execute(): > > print "Execute called" > > return 1 > > > > C# Console Programme code snapshot : > > PythonEngine.Initialize(); > > using (Py.GIL()) > > { > > PyObject testClassModule = PythonEngine.ImportModule(" > Class"); > > > > //Calling module method > > PyObject result = testClassModule.InvokeMethod("test"); > > Console.WriteLine("Test method result = {0}", > result.ToString()); > > > > PyObject classTest = testClassModule.GetAttr("ClassTest"); > > *classTest.InvokeMethod("Initialize "); > -----------------------------> Error* > > classTest.InvokeMethod("Execute"); > > } > > PythonEngine.Shutdown(); > > > > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Fri Apr 27 04:54:26 2018 From: techieth at gmail.com (techi eth) Date: Fri, 27 Apr 2018 14:24:26 +0530 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: Any input on raised query. I think i am missing something very simple but not able to catch. Thanks On Thu, Apr 26, 2018 at 5:47 PM, techi eth wrote: > Yes,It will work with this way but i need to create multiple instance of > same class.If you see other function (@Execute() ) with static was > working. > Please give me hint of doing without static. > > Thanks > > On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat > wrote: > >> Hello, >> >> >> >> you missed either @staticmethod decorator or the self argument for the >> Initialize method. >> >> >> >> Stefan >> >> >> >> *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= >> dspace.de at python.org] *On Behalf Of *techi eth >> *Se**nt:* Wednesday, April 25, 2018 2:38 PM >> *To:* A list for users and developers of Python for .NET < >> pythondotnet at python.org> >> *Subject:* [Python.NET] Error in calling Python class method from C# >> >> >> >> Hi, >> >> >> >> I am facing issue while calling python class function in C# programme. >> Can anyone give me hint what is wrong in below programme.While running I am >> getting error in invoking Initialize() function of class. >> >> >> >> Python module : >> >> def test(): >> >> print "Test called" >> >> return 1 >> >> >> >> class ClassTest: >> >> def __init__(self) >> >> >> >> def Initialize (): >> >> print " Initialize called" >> >> return 1 >> >> >> >> @staticmethod >> >> def Execute(): >> >> print "Execute called" >> >> return 1 >> >> >> >> C# Console Programme code snapshot : >> >> PythonEngine.Initialize(); >> >> using (Py.GIL()) >> >> { >> >> PyObject testClassModule = PythonEngine.ImportModule("Cla >> ss"); >> >> >> >> //Calling module method >> >> PyObject result = testClassModule.InvokeMethod("test"); >> >> Console.WriteLine("Test method result = {0}", >> result.ToString()); >> >> >> >> PyObject classTest = testClassModule.GetAttr("Class >> Test"); >> >> *classTest.InvokeMethod("Initialize "); >> -----------------------------> Error* >> >> classTest.InvokeMethod("Execute"); >> >> } >> >> PythonEngine.Shutdown(); >> >> >> >> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From solarjoe at posteo.org Fri Apr 20 01:40:41 2018 From: solarjoe at posteo.org (Joe) Date: Fri, 20 Apr 2018 07:40:41 +0200 Subject: [Python.NET] AddReferenceToFileAndName, AddReferenceToFile Message-ID: <0a899b29b4abf9db135fabfd46d01840@posteo.de> Hello, I found lots of references to AddReferenceToFileAndName and AddReferenceToFile online but could not find anything on them in the docs. Have they been removed? I looked at pythonnet/src/runtime/moduleobject.cs and there is only a single function public static Assembly AddReference(string name) which seems to handle all the cases. Kind regards, Joe From solarjoe at posteo.org Fri Apr 20 07:20:19 2018 From: solarjoe at posteo.org (Joe) Date: Fri, 20 Apr 2018 13:20:19 +0200 Subject: [Python.NET] Getting handles to .NET objects, un-referencing modules Message-ID: <94d1e8820668103ffbdffa4395ef7875@posteo.de> Hello, I have a .cs file that contains public struct SomeStruct { .... } public static class SomeClass { .... } So far I use it with PythonNET like import clr clr.AddReference('c:\\Test\Module.dll') from Module import SomeClass, SomeStruct SomeClass.SomeMethod(...) My problem is now that I need to work with dlls with identical names and no version number set, so PythonNET will not see them as two different dlls but as the same. Even if I import them using the full path with AddReference. Now I would like to use them as stated here https://stackoverflow.com/questions/31408391/python-for-net-using-same-net-assembly-in-multiple-versions like x = clr.AddReference('c:\\Test\Module.dll') But how would I get the handle to SomeClass and SomeStruct ? Another way would be to un-reference the dlls after each use, as described here https://stackoverflow.com/questions/1362114/how-to-unload-a-net-assembly-reference-in-ironpython How would that syntax look like? Kind regards, Joe From solarjoe at posteo.org Fri Apr 20 09:59:57 2018 From: solarjoe at posteo.org (Joe) Date: Fri, 20 Apr 2018 15:59:57 +0200 Subject: [Python.NET] AddReferenceToFileAndName, AddReferenceToFile In-Reply-To: <0a899b29b4abf9db135fabfd46d01840@posteo.de> References: <0a899b29b4abf9db135fabfd46d01840@posteo.de> Message-ID: <40abb5db83c49f41fd7303f88bc769a3@posteo.de> I found the answer :) These are IronPython methods, sorry I mixed that up. > Hello, > > I found lots of references to AddReferenceToFileAndName and > AddReferenceToFile online > but could not find anything on them in the docs. > > Have they been removed? > > I looked at pythonnet/src/runtime/moduleobject.cs and there is only a > single function > > public static Assembly AddReference(string name) > > which seems to handle all the cases. > > Kind regards, > Joe From solarjoe at posteo.org Tue Apr 24 08:04:23 2018 From: solarjoe at posteo.org (Joe) Date: Tue, 24 Apr 2018 14:04:23 +0200 Subject: [Python.NET] Using multiple versions of the same DLL Message-ID: <6c167d141a19432ba7c8a8f5ba9cb98d@posteo.de> Hello, I found a rather old thread (2003) that describes how multiple versions of a DLL can be used. It states > Things get a lot more complicated if you need to load more than one > version of a particular assembly (or more likely, you have a dependency > on some library the does so). In this case, the names you access via > the CLR modules will always come from the first version of the > assembly loaded (which will always win in the internals of the > runtime). (https://mail.python.org/pipermail/pythondotnet/2003-October/000010.html) Is this still correct or are there more convenient methods to do this? Kind regards, Joe From tunger at mitem.com Thu Apr 26 17:13:34 2018 From: tunger at mitem.com (Tom Unger) Date: Thu, 26 Apr 2018 21:13:34 +0000 Subject: [Python.NET] Embedding: finer control over module creation Message-ID: I'm starting on a project to embed CPython into a .NET application for scripting. The application currently uses IronPython, which is falling behind. Our scripting needs are fairly extensive and I'm challenged by the limited information I find available. First questions are about some finer grain control over First, my application loads a number of scripts. I currently use PythonEngine.ModuleFromString() and this works but I would like finer control. 1. Set the filename in call to Py_CompileString(). Current this is set to "none" 2. Set globals for module before executing it. I put certain values in the scripts global space for convenience. PythonEngine.Compile() will compile the code but then I don't see any way to execute the code. Runtime.PyImport_ExecCodeModule(name, c); is not public. Is there a way to do this with the current API? If I fork the GIT repo, make changes that I need, are they likely to be incorporated? Thanks, Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From tunger at evigils.com Fri Apr 27 13:06:35 2018 From: tunger at evigils.com (Tom Unger (eVigils)) Date: Fri, 27 Apr 2018 17:06:35 +0000 Subject: [Python.NET] Embedding: finer control over module creation Message-ID: I'm starting on a project to embed CPython into a .NET application for scripting. The application currently uses IronPython, which is falling behind. Our scripting needs are fairly extensive and I'm challenged by the limited information I find available. First questions are about some finer grain control over First, my application loads a number of scripts. I currently use PythonEngine.ModuleFromString() and this works but I would like finer control. 1. Set the filename in call to Py_CompileString(). Current this is set to "none" 2. Set globals for module before executing it. I put certain values in the scripts global space for convenience. PythonEngine.Compile() will compile the code but then I don't see any way to execute the code. Runtime.PyImport_ExecCodeModule(name, c); is not public. Is there a way to do this with the current API? If I fork the GIT repo, make changes that I need, are they likely to be incorporated? Thanks, Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Sun Apr 29 22:54:53 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Sun, 29 Apr 2018 21:54:53 -0500 Subject: [Python.NET] Embedding: finer control over module creation In-Reply-To: References: Message-ID: Tom, You may be interested in this PyScope implementation merged into pythonnet in 2017. This is in master branch but not in any release yet. https://github.com/pythonnet/pythonnet/pull/381 This was implemented by @yagweb (https://github.com/yagweb), who is now in core pythonnet team. Regarding merging PR - if this small enough change with tests (if applicable) that don't require extensive review, then we can definitely merge it as long as it passes Travis CI and Appveyor CI. If this is more intrusive PR, then at least few members of core team would need to review this. BTW, if anyone is willing to step up with helping out on PR reviews, mailing list management, preparing releases, then please contact me. Thanks, Denis On Fri, Apr 27, 2018 at 12:06 PM, Tom Unger (eVigils) wrote: > I?m starting on a project to embed CPython into a .NET application for > scripting. The application currently uses IronPython, which is falling > behind. Our scripting needs are fairly extensive and I?m challenged by the > limited information I find available. First questions are about some finer > grain control over > > > > First, my application loads a number of scripts. I currently use > PythonEngine.ModuleFromString() and this works but I would like finer > control. > > > > 1. Set the filename in call to Py_CompileString(). Current this is > set to ?none? > 2. Set globals for module before executing it. I put certain values > in the scripts global space for convenience. > > > > PythonEngine.Compile() will compile the code but then I don?t see any way > to *execute* the code. Runtime.PyImport_ExecCodeModule(name, c); is not > public. > > > > Is there a way to do this with the current API? > > > > If I fork the GIT repo, make changes that I need, are they likely to be > incorporated? > > > > 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 Sun Apr 29 22:58:25 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Sun, 29 Apr 2018 21:58:25 -0500 Subject: [Python.NET] Using multiple versions of the same DLL In-Reply-To: <6c167d141a19432ba7c8a8f5ba9cb98d@posteo.de> References: <6c167d141a19432ba7c8a8f5ba9cb98d@posteo.de> Message-ID: I presume this is your question with an open bounty on it? https://stackoverflow.com/questions/49942487/python-for-net-how-to-explicitly-create-instances-of-c-sharp-classes-using-dif On Tue, Apr 24, 2018 at 7:04 AM, Joe wrote: > Hello, > > I found a rather old thread (2003) that describes how multiple versions of > a > DLL can be used. > > It states > > Things get a lot more complicated if you need to load more than one >> version of a particular assembly (or more likely, you have a dependency >> on some library the does so). In this case, the names you access via >> the CLR modules will always come from the first version of the >> assembly loaded (which will always win in the internals of the runtime). >> > > (https://mail.python.org/pipermail/pythondotnet/2003-October/000010.html) > > Is this still correct or are there more convenient methods to do this? > > Kind regards, > Joe > _________________________________________________ > 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 Sun Apr 29 23:04:01 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Sun, 29 Apr 2018 22:04:01 -0500 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: You may get more feedback on stackoverflow than on this mailing list for questions like this: https://stackoverflow.com/questions/tagged/python.net?sort=newest&pageSize=50 On Fri, Apr 27, 2018 at 3:54 AM, techi eth wrote: > Any input on raised query. I think i am missing something very simple but > not able to catch. > > Thanks > > On Thu, Apr 26, 2018 at 5:47 PM, techi eth wrote: > >> Yes,It will work with this way but i need to create multiple instance of >> same class.If you see other function (@Execute() ) with static was >> working. >> Please give me hint of doing without static. >> >> Thanks >> >> On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat >> wrote: >> >>> Hello, >>> >>> >>> >>> you missed either @staticmethod decorator or the self argument for the >>> Initialize method. >>> >>> >>> >>> Stefan >>> >>> >>> >>> *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= >>> dspace.de at python.org] *On Behalf Of *techi eth >>> *Se**nt:* Wednesday, April 25, 2018 2:38 PM >>> *To:* A list for users and developers of Python for .NET < >>> pythondotnet at python.org> >>> *Subject:* [Python.NET] Error in calling Python class method from C# >>> >>> >>> >>> Hi, >>> >>> >>> >>> I am facing issue while calling python class function in C# programme. >>> Can anyone give me hint what is wrong in below programme.While running I am >>> getting error in invoking Initialize() function of class. >>> >>> >>> >>> Python module : >>> >>> def test(): >>> >>> print "Test called" >>> >>> return 1 >>> >>> >>> >>> class ClassTest: >>> >>> def __init__(self) >>> >>> >>> >>> def Initialize (): >>> >>> print " Initialize called" >>> >>> return 1 >>> >>> >>> >>> @staticmethod >>> >>> def Execute(): >>> >>> print "Execute called" >>> >>> return 1 >>> >>> >>> >>> C# Console Programme code snapshot : >>> >>> PythonEngine.Initialize(); >>> >>> using (Py.GIL()) >>> >>> { >>> >>> PyObject testClassModule = PythonEngine.ImportModule("Cla >>> ss"); >>> >>> >>> >>> //Calling module method >>> >>> PyObject result = testClassModule.InvokeMethod("test"); >>> >>> Console.WriteLine("Test method result = {0}", >>> result.ToString()); >>> >>> >>> >>> PyObject classTest = testClassModule.GetAttr("Class >>> Test"); >>> >>> *classTest.InvokeMethod("Initialize "); >>> -----------------------------> Error* >>> >>> classTest.InvokeMethod("Execute"); >>> >>> } >>> >>> PythonEngine.Shutdown(); >>> >>> >>> >>> >>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Mon Apr 30 01:06:33 2018 From: techieth at gmail.com (techi eth) Date: Mon, 30 Apr 2018 10:36:33 +0530 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: Thanks for link, I have been through most of pages but not able to found same query. I am also not sure is this possible with Pyhton For .NET. Could you please give me below query answer. Can i create python class instance in C# programme ???? On Mon, Apr 30, 2018 at 8:34 AM, Denis Akhiyarov wrote: > You may get more feedback on stackoverflow than on this mailing list for > questions like this: > > https://stackoverflow.com/questions/tagged/python.net? > sort=newest&pageSize=50 > > On Fri, Apr 27, 2018 at 3:54 AM, techi eth wrote: > >> Any input on raised query. I think i am missing something very simple but >> not able to catch. >> >> Thanks >> >> On Thu, Apr 26, 2018 at 5:47 PM, techi eth wrote: >> >>> Yes,It will work with this way but i need to create multiple instance of >>> same class.If you see other function (@Execute() ) with static was >>> working. >>> Please give me hint of doing without static. >>> >>> Thanks >>> >>> On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat >>> wrote: >>> >>>> Hello, >>>> >>>> >>>> >>>> you missed either @staticmethod decorator or the self argument for the >>>> Initialize method. >>>> >>>> >>>> >>>> Stefan >>>> >>>> >>>> >>>> *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= >>>> dspace.de at python.org] *On Behalf Of *techi eth >>>> *Se**nt:* Wednesday, April 25, 2018 2:38 PM >>>> *To:* A list for users and developers of Python for .NET < >>>> pythondotnet at python.org> >>>> *Subject:* [Python.NET] Error in calling Python class method from C# >>>> >>>> >>>> >>>> Hi, >>>> >>>> >>>> >>>> I am facing issue while calling python class function in C# programme. >>>> Can anyone give me hint what is wrong in below programme.While running I am >>>> getting error in invoking Initialize() function of class. >>>> >>>> >>>> >>>> Python module : >>>> >>>> def test(): >>>> >>>> print "Test called" >>>> >>>> return 1 >>>> >>>> >>>> >>>> class ClassTest: >>>> >>>> def __init__(self) >>>> >>>> >>>> >>>> def Initialize (): >>>> >>>> print " Initialize called" >>>> >>>> return 1 >>>> >>>> >>>> >>>> @staticmethod >>>> >>>> def Execute(): >>>> >>>> print "Execute called" >>>> >>>> return 1 >>>> >>>> >>>> >>>> C# Console Programme code snapshot : >>>> >>>> PythonEngine.Initialize(); >>>> >>>> using (Py.GIL()) >>>> >>>> { >>>> >>>> PyObject testClassModule = >>>> PythonEngine.ImportModule("Class"); >>>> >>>> >>>> >>>> //Calling module method >>>> >>>> PyObject result = testClassModule.InvokeMethod("test"); >>>> >>>> Console.WriteLine("Test method result = {0}", >>>> result.ToString()); >>>> >>>> >>>> >>>> PyObject classTest = testClassModule.GetAttr("Class >>>> Test"); >>>> >>>> *classTest.InvokeMethod("Initialize "); >>>> -----------------------------> Error* >>>> >>>> classTest.InvokeMethod("Execute"); >>>> >>>> } >>>> >>>> PythonEngine.Shutdown(); >>>> >>>> >>>> >>>> >>>> >>>> _________________________________________________ >>>> Python.NET mailing list - PythonDotNet at python.org >>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>> >>>> >>> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Mon Apr 30 02:05:09 2018 From: techieth at gmail.com (techi eth) Date: Mon, 30 Apr 2018 11:35:09 +0530 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: Iron Python is having way to do the same.Please check below link. https://stackoverflow.com/questions/579272/instantiating-a-python-class-in-c-sharp On Mon, Apr 30, 2018 at 10:36 AM, techi eth wrote: > Thanks for link, I have been through most of pages but not able to found > same query. > I am also not sure is this possible with Pyhton For .NET. Could you please > give me below query answer. > > Can i create python class instance in C# programme ???? > > On Mon, Apr 30, 2018 at 8:34 AM, Denis Akhiyarov < > denis.akhiyarov at gmail.com> wrote: > >> You may get more feedback on stackoverflow than on this mailing list for >> questions like this: >> >> https://stackoverflow.com/questions/tagged/python.net?sort= >> newest&pageSize=50 >> >> On Fri, Apr 27, 2018 at 3:54 AM, techi eth wrote: >> >>> Any input on raised query. I think i am missing something very simple >>> but not able to catch. >>> >>> Thanks >>> >>> On Thu, Apr 26, 2018 at 5:47 PM, techi eth wrote: >>> >>>> Yes,It will work with this way but i need to create multiple instance >>>> of same class.If you see other function (@Execute() ) with static was >>>> working. >>>> Please give me hint of doing without static. >>>> >>>> Thanks >>>> >>>> On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat >>>> wrote: >>>> >>>>> Hello, >>>>> >>>>> >>>>> >>>>> you missed either @staticmethod decorator or the self argument for the >>>>> Initialize method. >>>>> >>>>> >>>>> >>>>> Stefan >>>>> >>>>> >>>>> >>>>> *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= >>>>> dspace.de at python.org] *On Behalf Of *techi eth >>>>> *Se**nt:* Wednesday, April 25, 2018 2:38 PM >>>>> *To:* A list for users and developers of Python for .NET < >>>>> pythondotnet at python.org> >>>>> *Subject:* [Python.NET] Error in calling Python class method from C# >>>>> >>>>> >>>>> >>>>> Hi, >>>>> >>>>> >>>>> >>>>> I am facing issue while calling python class function in C# programme. >>>>> Can anyone give me hint what is wrong in below programme.While running I am >>>>> getting error in invoking Initialize() function of class. >>>>> >>>>> >>>>> >>>>> Python module : >>>>> >>>>> def test(): >>>>> >>>>> print "Test called" >>>>> >>>>> return 1 >>>>> >>>>> >>>>> >>>>> class ClassTest: >>>>> >>>>> def __init__(self) >>>>> >>>>> >>>>> >>>>> def Initialize (): >>>>> >>>>> print " Initialize called" >>>>> >>>>> return 1 >>>>> >>>>> >>>>> >>>>> @staticmethod >>>>> >>>>> def Execute(): >>>>> >>>>> print "Execute called" >>>>> >>>>> return 1 >>>>> >>>>> >>>>> >>>>> C# Console Programme code snapshot : >>>>> >>>>> PythonEngine.Initialize(); >>>>> >>>>> using (Py.GIL()) >>>>> >>>>> { >>>>> >>>>> PyObject testClassModule = >>>>> PythonEngine.ImportModule("Class"); >>>>> >>>>> >>>>> >>>>> //Calling module method >>>>> >>>>> PyObject result = testClassModule.InvokeMethod(" >>>>> test"); >>>>> >>>>> Console.WriteLine("Test method result = {0}", >>>>> result.ToString()); >>>>> >>>>> >>>>> >>>>> PyObject classTest = testClassModule.GetAttr("Class >>>>> Test"); >>>>> >>>>> *classTest.InvokeMethod("Initialize "); >>>>> -----------------------------> Error* >>>>> >>>>> classTest.InvokeMethod("Execute"); >>>>> >>>>> } >>>>> >>>>> PythonEngine.Shutdown(); >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> _________________________________________________ >>>>> Python.NET mailing list - PythonDotNet at python.org >>>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>>> >>>>> >>>> >>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From techieth at gmail.com Mon Apr 30 04:47:33 2018 From: techieth at gmail.com (techi eth) Date: Mon, 30 Apr 2018 14:17:33 +0530 Subject: [Python.NET] Error in calling Python class method from C# In-Reply-To: References: <19A216758DA7374193F26E107EDA37EA01ABC841C3@Exchange2010.dspace.de> Message-ID: I have got success on doing. I just need to get review to ensure right. Please find below code snapshot. Class.py def test(): print "Test called" return 1 class ClassTest: def __init__(self) def Initalize(self): print "Initalize called" return 1 @staticmethod def Execute(): print "Execute called" return 1 ------------------------------------------------------------------------------------- Programme.cs PythonEngine.Initialize(); using (Py.GIL()) { //Creating module object PyObject testClassModule = PythonEngine.ImportModule("Class"); //Calling module method PyObject result = testClassModule.InvokeMethod("test"); Console.WriteLine("Test method result = {0}", result.ToString()); Dynamic classTest = testClassModule.GetAttr("ClassTest"); Dynamic tmp = classTest(); tmp.Initalize(); tmp.Execute(); } PythonEngine.Shutdown(); return 0; } On Mon, Apr 30, 2018 at 11:35 AM, techi eth wrote: > Iron Python is having way to do the same.Please check below link. > https://stackoverflow.com/questions/579272/instantiating-a-python-class- > in-c-sharp > > > > > > On Mon, Apr 30, 2018 at 10:36 AM, techi eth wrote: > >> Thanks for link, I have been through most of pages but not able to found >> same query. >> I am also not sure is this possible with Pyhton For .NET. Could you >> please give me below query answer. >> >> Can i create python class instance in C# programme ???? >> >> On Mon, Apr 30, 2018 at 8:34 AM, Denis Akhiyarov < >> denis.akhiyarov at gmail.com> wrote: >> >>> You may get more feedback on stackoverflow than on this mailing list for >>> questions like this: >>> >>> https://stackoverflow.com/questions/tagged/python.net?sort=n >>> ewest&pageSize=50 >>> >>> On Fri, Apr 27, 2018 at 3:54 AM, techi eth wrote: >>> >>>> Any input on raised query. I think i am missing something very simple >>>> but not able to catch. >>>> >>>> Thanks >>>> >>>> On Thu, Apr 26, 2018 at 5:47 PM, techi eth wrote: >>>> >>>>> Yes,It will work with this way but i need to create multiple instance >>>>> of same class.If you see other function (@Execute() ) with static was >>>>> working. >>>>> Please give me hint of doing without static. >>>>> >>>>> Thanks >>>>> >>>>> On Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat >>>>> wrote: >>>>> >>>>>> Hello, >>>>>> >>>>>> >>>>>> >>>>>> you missed either @staticmethod decorator or the self argument for >>>>>> the Initialize method. >>>>>> >>>>>> >>>>>> >>>>>> Stefan >>>>>> >>>>>> >>>>>> >>>>>> *From:* PythonDotNet [mailto:pythondotnet-bounces+sschukat= >>>>>> dspace.de at python.org] *On Behalf Of *techi eth >>>>>> *Se**nt:* Wednesday, April 25, 2018 2:38 PM >>>>>> *To:* A list for users and developers of Python for .NET < >>>>>> pythondotnet at python.org> >>>>>> *Subject:* [Python.NET] Error in calling Python class method from C# >>>>>> >>>>>> >>>>>> >>>>>> Hi, >>>>>> >>>>>> >>>>>> >>>>>> I am facing issue while calling python class function in C# >>>>>> programme. Can anyone give me hint what is wrong in below programme.While >>>>>> running I am getting error in invoking Initialize() function of class. >>>>>> >>>>>> >>>>>> >>>>>> Python module : >>>>>> >>>>>> def test(): >>>>>> >>>>>> print "Test called" >>>>>> >>>>>> return 1 >>>>>> >>>>>> >>>>>> >>>>>> class ClassTest: >>>>>> >>>>>> def __init__(self) >>>>>> >>>>>> >>>>>> >>>>>> def Initialize (): >>>>>> >>>>>> print " Initialize called" >>>>>> >>>>>> return 1 >>>>>> >>>>>> >>>>>> >>>>>> @staticmethod >>>>>> >>>>>> def Execute(): >>>>>> >>>>>> print "Execute called" >>>>>> >>>>>> return 1 >>>>>> >>>>>> >>>>>> >>>>>> C# Console Programme code snapshot : >>>>>> >>>>>> PythonEngine.Initialize(); >>>>>> >>>>>> using (Py.GIL()) >>>>>> >>>>>> { >>>>>> >>>>>> PyObject testClassModule = >>>>>> PythonEngine.ImportModule("Class"); >>>>>> >>>>>> >>>>>> >>>>>> //Calling module method >>>>>> >>>>>> PyObject result = testClassModule.InvokeMethod(" >>>>>> test"); >>>>>> >>>>>> Console.WriteLine("Test method result = {0}", >>>>>> result.ToString()); >>>>>> >>>>>> >>>>>> >>>>>> PyObject classTest = testClassModule.GetAttr("Class >>>>>> Test"); >>>>>> >>>>>> *classTest.InvokeMethod("Initialize "); >>>>>> -----------------------------> Error* >>>>>> >>>>>> classTest.InvokeMethod("Execute"); >>>>>> >>>>>> } >>>>>> >>>>>> PythonEngine.Shutdown(); >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _________________________________________________ >>>>>> Python.NET mailing list - PythonDotNet at python.org >>>>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>>>> >>>>>> >>>>> >>>> >>>> _________________________________________________ >>>> Python.NET mailing list - PythonDotNet at python.org >>>> https://mail.python.org/mailman/listinfo/pythondotnet >>>> >>>> >>> >>> _________________________________________________ >>> Python.NET mailing list - PythonDotNet at python.org >>> https://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tunger at mitem.com Mon Apr 30 11:48:55 2018 From: tunger at mitem.com (Tom Unger) Date: Mon, 30 Apr 2018 15:48:55 +0000 Subject: [Python.NET] Using multiple versions of the same DLL In-Reply-To: References: <6c167d141a19432ba7c8a8f5ba9cb98d@posteo.de> Message-ID: Not me. Tom From: PythonDotNet On Behalf Of Denis Akhiyarov Sent: Sunday, April 29, 2018 7:58 PM To: A list for users and developers of Python for .NET Subject: Re: [Python.NET] Using multiple versions of the same DLL I presume this is your question with an open bounty on it? https://stackoverflow.com/questions/49942487/python-for-net-how-to-explicitly-create-instances-of-c-sharp-classes-using-dif On Tue, Apr 24, 2018 at 7:04 AM, Joe > wrote: Hello, I found a rather old thread (2003) that describes how multiple versions of a DLL can be used. It states Things get a lot more complicated if you need to load more than one version of a particular assembly (or more likely, you have a dependency on some library the does so). In this case, the names you access via the CLR modules will always come from the first version of the assembly loaded (which will always win in the internals of the runtime). (https://mail.python.org/pipermail/pythondotnet/2003-October/000010.html) Is this still correct or are there more convenient methods to do this? Kind regards, Joe _________________________________________________ Python.NET mailing list - PythonDotNet at python.org https://mail.python.org/mailman/listinfo/pythondotnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From tunger at mitem.com Mon Apr 30 12:24:15 2018 From: tunger at mitem.com (Tom Unger) Date: Mon, 30 Apr 2018 16:24:15 +0000 Subject: [Python.NET] Embedding: finer control over module creation In-Reply-To: References: Message-ID: I did see the PythonScope object. Your link helps explain it?s intended use: "eval" and "exec" are the most frequently used methods when interacting with Python. However, that is not my use. I have an application that relies heavily on scripting. Initially I used IronPython and that has worked great for years. However, many very useful modules don?t run on IronPython and development appears stalled. So, time to move on. My use has been to define an API for a specific operation and then implement that in a Python ?script?. These scripts function like modules but I call them ?scripts? because they are not on the PYTHONPATH but are named specifically in my application configuration. IronPython API lets me load, compile, and call the script explicitly. This approach has been very successful and we have implemented quite complex applications in python scripts called by the .NET application. Ideally, the my interface to CPython will use the same calling conventions. Ideally, we will be able to change from IronPython to CPython (2.7) with no changes in the Python scripts. So I?m trying to discover the python.net API equivalents to what I do in IronPython. Many I have not found, and my impression is that my use of Python is different than other coders use it. Above quote indicates this is true. I have no intention to use eval and exec. I want to load and compile code once at startup and then call repeatedly. I have most of this working. The one change I will have to check into python.net is addition of a call that loads a module from a file and associates the file name with that module. This gets the file name into stack traces which will be very, very helpful when we come to debug our complex scripts. It is a small feature addition. I?ve written a test case for it. I?ve not tested with Python 3 and should do that before creating the pull request. Currently, I can not pre-load the module scope with pre-defined globals. I load the module, it executes, and then I define the globals. But most modules just define functions to be called by my application and don?t reference any of these variables in their ?global scope code?. I have found there are two significant difference from IronPython. First is that CPython has one global scope. In IronPython I was able to create a scope for each script that I loaded. Any modules that script imported were within the scope of that script and entirely isolated from other scripts my application loaded. CPython has one global scope. If I load script A and script B and they both load module X, module X is shared. Any changes on moduel X?s state will be seen by both A and B. The isolation provided by IronPtyon was nice, but also mean that I could not write two scripts that coordinated logic with each other. I never needed to do this. The sharing in CPython will allow that. However, it means that we must write any shared modules to assume multiple clients. I think I have generally done this in all cases. Testing will tell? The other difference is that in IronPython, different scripts can execute concurrently on .net threads. The scripts have their own scope, the data each works on is not touched by other threads, and all other parts of my application are thread safe. My understanding is that CPython will not allow this. It is a bit of loss in scalability but performance has never been our limiting factor. That is a long description but I hope that some are interested in knowing how python.net is being used. Tom From: PythonDotNet On Behalf Of Denis Akhiyarov Sent: Sunday, April 29, 2018 7:55 PM To: A list for users and developers of Python for .NET Cc: ywg Subject: Re: [Python.NET] Embedding: finer control over module creation Tom, You may be interested in this PyScope implementation merged into pythonnet in 2017. This is in master branch but not in any release yet. https://github.com/pythonnet/pythonnet/pull/381 This was implemented by @yagweb (https://github.com/yagweb), who is now in core pythonnet team. Regarding merging PR - if this small enough change with tests (if applicable) that don't require extensive review, then we can definitely merge it as long as it passes Travis CI and Appveyor CI. If this is more intrusive PR, then at least few members of core team would need to review this. BTW, if anyone is willing to step up with helping out on PR reviews, mailing list management, preparing releases, then please contact me. Thanks, Denis On Fri, Apr 27, 2018 at 12:06 PM, Tom Unger (eVigils) > wrote: I?m starting on a project to embed CPython into a .NET application for scripting. The application currently uses IronPython, which is falling behind. Our scripting needs are fairly extensive and I?m challenged by the limited information I find available. First questions are about some finer grain control over First, my application loads a number of scripts. I currently use PythonEngine.ModuleFromString() and this works but I would like finer control. 1. Set the filename in call to Py_CompileString(). Current this is set to ?none? 2. Set globals for module before executing it. I put certain values in the scripts global space for convenience. PythonEngine.Compile() will compile the code but then I don?t see any way to execute the code. Runtime.PyImport_ExecCodeModule(name, c); is not public. Is there a way to do this with the current API? If I fork the GIT repo, make changes that I need, are they likely to be incorporated? 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: