Discussion:
[Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0
Oleksii Bidiuk
2011-01-06 14:27:12 UTC
Permalink
Hi,

I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
downloaded the pythonnet-2.0-alpha2.zip and changed the project settings to
use .NET 4.0 under VS2010 and recompiled everything. The resulting
python.exe can be run, and statements like "import clr" and "from System
import String" work (as the Python standard library calls as well) until I
try to instantiate a class as e.g.

s = String('A')

At this moment the Python for .NET seem to crash in nativecall.cs at
NativeCall.Call_3() at (the only) line

return Impl.Call_3(fp, a1, a2, a3);

with dreaded "Exception of type 'System.ExecutionEngineException' was
thrown.". Trying to instantiate Int32() object results in "Attempted to read
or write protected memory. This is often an indication that other memory is
corrupt."

Suggestions are more than welcome! Thanks in advance!
--
oleksii
Oleksii Bidiuk
2011-01-06 14:59:59 UTC
Permalink
Hi Alla,

thanks for your prompt repsonse. In Python terms String('A') means
constructor with a string parameter AFAIK. When I use the python.exe build
against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works,
but then it talks against .NET 2.0 while I want to talk to the same 4.0
version as my .NET application.

With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'

Basically it seems that the version of python for .net compiled against .NET
4.0 runtime does not work out of box for me. I wonder if somebody had more
luck with this.

2011/1/6 Alla Gofman <Alla.Gofman-***@public.gmane.org>

Hi Oleksii,
I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A') for String class as you use,
which gets char.
http://msdn.microsoft.com/en-us/library/system.string.string.aspx
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct constructor to
call automatically based on the arguments. In some cases, it may be
necessary to call a particular overloaded constructor, which is supported by
from System import String, Char, Int32
s = String.__overloads__[Char, Int32]('A', 10)
I hope you succeed,
Alla
pythondotnet-bounces+alla.gofman <pythondotnet-bounces%2Balla.gofman>=
*Sent:* Thursday, January 06, 2011 4:27 PM
*Subject:* [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0
Hi,
I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
downloaded the pythonnet-2.0-alpha2.zip and changed the project settings to
use .NET 4.0 under VS2010 and recompiled everything. The resulting
python.exe can be run, and statements like "import clr" and "from System
import String" work (as the Python standard library calls as well) until I
try to instantiate a class as e.g.
s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs at
NativeCall.Call_3() at (the only) line
return Impl.Call_3(fp, a1, a2, a3);
with dreaded "Exception of type 'System.ExecutionEngineException' was
thrown.". Trying to instantiate Int32() object results in "Attempted to read
or write protected memory. This is often an indication that other memory is
corrupt."
Suggestions are more than welcome! Thanks in advance!
--
oleksii
------------------------------
PLEASE NOTE: The information contained in this electronic mail message is
intended only for the use of the designated recipient(s) named above. If the
reader of this message is not the intended recipient, you are hereby
notified that you have received this message in error and that any review,
dissemination, distribution, or copying of this message is strictly
prohibited. If you have received this communication in error, please notify
the sender by telephone or e-mail (as shown above) immediately and destroy
any and all copies of this message in your possession (whether hard copies
or electronically stored copies).
--
oleksii
--
oleksii
Barton
2011-01-07 09:02:25 UTC
Permalink
I've got this working on my private (for the moment) branch. I could do
this merge by this weekend if folks will find it useful.
-Barton
Post by Oleksii Bidiuk
Hi Alla,
thanks for your prompt repsonse. In Python terms String('A') means
constructor with a string parameter AFAIK. When I use the python.exe
build against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip)
it works, but then it talks against .NET 2.0 while I want to talk to
the same 4.0 version as my .NET application.
With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'
Basically it seems that the version of python for .net compiled
against .NET 4.0 runtime does not work out of box for me. I wonder if
somebody had more luck with this.
Hi Oleksii,
I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A')for String class as you
use, which gets char.
http://msdn.microsoft.com/en-us/library/system.string.string.aspx
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct
constructor to call automatically based on the arguments. In some
cases, it may be necessary to call a particular overloaded
constructor, which is supported by a special "__overloads__"
from System import String, Char, Int32
s = String.__overloads__[Char, Int32]('A', 10)
I hope you succeed,
Alla
*From:*pythondotnet-bounces+alla.gofman=sandisk.com
[mailto:pythondotnet-bounces+alla.gofman
<mailto:pythondotnet-bounces%2Balla.gofman>=sandisk.com
*Oleksii Bidiuk
*Sent:* Thursday, January 06, 2011 4:27 PM
*Subject:* [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0
Hi,
I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
downloaded the pythonnet-2.0-alpha2.zip and changed the project
settings to use .NET 4.0 under VS2010 and recompiled everything.
The resulting python.exe can be run, and statements like "import
clr" and "from System import String" work (as the Python standard
library calls as well) until I try to instantiate a class as e.g.
s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs
at NativeCall.Call_3() at (the only) line
return Impl.Call_3(fp, a1, a2, a3);
with dreaded "Exception of type 'System.ExecutionEngineException'
was thrown.". Trying to instantiate Int32() object results in
"Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."
Suggestions are more than welcome! Thanks in advance!
--
oleksii
------------------------------------------------------------------------
PLEASE NOTE: The information contained in this electronic mail
message is intended only for the use of the designated
recipient(s) named above. If the reader of this message is not the
intended recipient, you are hereby notified that you have received
this message in error and that any review, dissemination,
distribution, or copying of this message is strictly prohibited.
If you have received this communication in error, please notify
the sender by telephone or e-mail (as shown above) immediately and
destroy any and all copies of this message in your possession
(whether hard copies or electronically stored copies).
--
oleksii
--
oleksii
_________________________________________________
http://mail.python.org/mailman/listinfo/pythondotnet
Tribble, Brett
2011-01-08 00:26:22 UTC
Permalink
Merge away!

From: pythondotnet-bounces+btribble=***@python.org [mailto:pythondotnet-bounces+btribble=***@python.org] On Behalf Of Barton
Sent: Friday, January 07, 2011 1:02 AM
To: Oleksii Bidiuk
Cc: ***@python.org
Subject: Re: [Python.NET] Fwd: PythonNET 2.0 Alpha2 and .NET 4.0

I've got this working on my private (for the moment) branch. I could do this merge by this weekend if folks will find it useful.
-Barton

On 1/6/2011 6:59 AM, Oleksii Bidiuk wrote:
Hi Alla,

thanks for your prompt repsonse. In Python terms String('A') means constructor with a string parameter AFAIK. When I use the python.exe build against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works, but then it talks against .NET 2.0 while I want to talk to the same 4.0 version as my .NET application.
With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'

Basically it seems that the version of python for .net compiled against .NET 4.0 runtime does not work out of box for me. I wonder if somebody had more luck with this.

2011/1/6 Alla Gofman <***@sandisk.com<mailto:***@sandisk.com>>

Hi Oleksii,

I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A') for String class as you use, which gets char.
You can see which constructors exists in: http://msdn.microsoft.com/en-us/library/system.string.string.aspx

Example:
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct constructor to call automatically based on the arguments. In some cases, it may be necessary to call a particular overloaded constructor, which is supported by a special "__overloads__" attribute on a class:
from System import String, Char, Int32

s = String.__overloads__[Char, Int32]('A', 10)

I hope you succeed,

Alla

From: pythondotnet-bounces+alla.gofman=sandisk.com<http://sandisk.com>@python.org<http://python.org> [mailto:pythondotnet-bounces+alla.gofman<mailto:pythondotnet-bounces%2Balla.gofman>=sandisk.com<http://sandisk.com>@python.org<http://python.org>] On Behalf Of Oleksii Bidiuk
Sent: Thursday, January 06, 2011 4:27 PM
To: ***@python.org<mailto:***@python.org>
Subject: [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0

Hi,

I am trying to use Python for .NET under VS2010 and .NET 4.0. I've downloaded the pythonnet-2.0-alpha2.zip and changed the project settings to use .NET 4.0 under VS2010 and recompiled everything. The resulting python.exe can be run, and statements like "import clr" and "from System import String" work (as the Python standard library calls as well) until I try to instantiate a class as e.g.

s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs at NativeCall.Call_3() at (the only) line

return Impl.Call_3(fp, a1, a2, a3);

with dreaded "Exception of type 'System.ExecutionEngineException' was thrown.". Trying to instantiate Int32() object results in "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Suggestions are more than welcome! Thanks in advance!
--
oleksii

________________________________
PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
--
oleksii
--
oleksii






_________________________________________________

Python.NET mailing list - ***@python.org<mailto:***@python.org>

http://mail.python.org/mailman/listinfo/pythondotnet
Oleksii Bidiuk
2011-01-08 13:28:07 UTC
Permalink
Yes please!
Post by Barton
I've got this working on my private (for the moment) branch. I could do
this merge by this weekend if folks will find it useful.
-Barton
Hi Alla,
thanks for your prompt repsonse. In Python terms String('A') means
constructor with a string parameter AFAIK. When I use the python.exe build
against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works,
but then it talks against .NET 2.0 while I want to talk to the same 4.0
version as my .NET application.
With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'
Basically it seems that the version of python for .net compiled against
.NET 4.0 runtime does not work out of box for me. I wonder if somebody had
more luck with this.
Hi Oleksii,
I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A') for String class as you use,
which gets char.
http://msdn.microsoft.com/en-us/library/system.string.string.aspx
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct constructor to
call automatically based on the arguments. In some cases, it may be
necessary to call a particular overloaded constructor, which is supported by
from System import String, Char, Int32
s = String.__overloads__[Char, Int32]('A', 10)
I hope you succeed,
Alla
pythondotnet-bounces+alla.gofman <pythondotnet-bounces%2Balla.gofman>=
*Sent:* Thursday, January 06, 2011 4:27 PM
*Subject:* [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0
Hi,
I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
downloaded the pythonnet-2.0-alpha2.zip and changed the project settings to
use .NET 4.0 under VS2010 and recompiled everything. The resulting
python.exe can be run, and statements like "import clr" and "from System
import String" work (as the Python standard library calls as well) until I
try to instantiate a class as e.g.
s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs at
NativeCall.Call_3() at (the only) line
return Impl.Call_3(fp, a1, a2, a3);
with dreaded "Exception of type 'System.ExecutionEngineException' was
thrown.". Trying to instantiate Int32() object results in "Attempted to read
or write protected memory. This is often an indication that other memory is
corrupt."
Suggestions are more than welcome! Thanks in advance!
--
oleksii
------------------------------
PLEASE NOTE: The information contained in this electronic mail message is
intended only for the use of the designated recipient(s) named above. If the
reader of this message is not the intended recipient, you are hereby
notified that you have received this message in error and that any review,
dissemination, distribution, or copying of this message is strictly
prohibited. If you have received this communication in error, please notify
the sender by telephone or e-mail (as shown above) immediately and destroy
any and all copies of this message in your possession (whether hard copies
or electronically stored copies).
--
oleksii
--
oleksii
_________________________________________________
--
oleksii
Oleksii Bidiuk
2011-01-11 14:17:24 UTC
Permalink
Hi Barton,

do you still have any plans to work on the merge? I am curious what the
changes are (how much, what impact do they have) and whether there something
can be done to help you with this.

Thanks in advance!
Post by Barton
I've got this working on my private (for the moment) branch. I could do
this merge by this weekend if folks will find it useful.
-Barton
Hi Alla,
thanks for your prompt repsonse. In Python terms String('A') means
constructor with a string parameter AFAIK. When I use the python.exe build
against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works,
but then it talks against .NET 2.0 while I want to talk to the same 4.0
version as my .NET application.
With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'
Basically it seems that the version of python for .net compiled against
.NET 4.0 runtime does not work out of box for me. I wonder if somebody had
more luck with this.
Hi Oleksii,
I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A') for String class as you use,
which gets char.
http://msdn.microsoft.com/en-us/library/system.string.string.aspx
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct constructor to
call automatically based on the arguments. In some cases, it may be
necessary to call a particular overloaded constructor, which is supported by
from System import String, Char, Int32
s = String.__overloads__[Char, Int32]('A', 10)
I hope you succeed,
Alla
pythondotnet-bounces+alla.gofman <pythondotnet-bounces%2Balla.gofman>=
*Sent:* Thursday, January 06, 2011 4:27 PM
*Subject:* [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0
Hi,
I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
downloaded the pythonnet-2.0-alpha2.zip and changed the project settings to
use .NET 4.0 under VS2010 and recompiled everything. The resulting
python.exe can be run, and statements like "import clr" and "from System
import String" work (as the Python standard library calls as well) until I
try to instantiate a class as e.g.
s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs at
NativeCall.Call_3() at (the only) line
return Impl.Call_3(fp, a1, a2, a3);
with dreaded "Exception of type 'System.ExecutionEngineException' was
thrown.". Trying to instantiate Int32() object results in "Attempted to read
or write protected memory. This is often an indication that other memory is
corrupt."
Suggestions are more than welcome! Thanks in advance!
--
oleksii
------------------------------
PLEASE NOTE: The information contained in this electronic mail message is
intended only for the use of the designated recipient(s) named above. If the
reader of this message is not the intended recipient, you are hereby
notified that you have received this message in error and that any review,
dissemination, distribution, or copying of this message is strictly
prohibited. If you have received this communication in error, please notify
the sender by telephone or e-mail (as shown above) immediately and destroy
any and all copies of this message in your possession (whether hard copies
or electronically stored copies).
--
oleksii
--
oleksii
_________________________________________________
--
oleksii
Barton
2011-01-16 20:32:10 UTC
Permalink
This has been pushed to the trunk @ version 122 on the 9th of January, 2011.
See the Tracker/Patches for details.
Post by Oleksii Bidiuk
Hi Barton,
do you still have any plans to work on the merge? I am curious what
the changes are (how much, what impact do they have) and whether there
something can be done to help you with this.
Thanks in advance!
I've got this working on my private (for the moment) branch. I
could do this merge by this weekend if folks will find it useful.
-Barton
Post by Oleksii Bidiuk
Hi Alla,
thanks for your prompt repsonse. In Python terms String('A')
means constructor with a string parameter AFAIK. When I use the
python.exe build against CLR 2.0
(from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works, but
then it talks against .NET 2.0 while I want to talk to the same
4.0 version as my .NET application.
With the example below using the .NET 2.0 version I get
s = String.__overloads__[Char, Int32]('A', 10)
File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'
Basically it seems that the version of python for .net compiled
against .NET 4.0 runtime does not work out of box for me. I
wonder if somebody had more luck with this.
Hi Oleksii,
I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A')for String class as
you use, which gets char.
http://msdn.microsoft.com/en-us/library/system.string.string.aspx
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct
constructor to call automatically based on the arguments. In
some cases, it may be necessary to call a particular
overloaded constructor, which is supported by a special
from System import String, Char, Int32
s = String.__overloads__[Char, Int32]('A', 10)
I hope you succeed,
Alla
Oleksii Bidiuk
2011-01-17 14:15:34 UTC
Permalink
Hi Barton,

thanks for the update! I've got the latest version, but the changes to the
classmanager.cs do not seem to compile

// Implement Overloads on the class object
ConstructorBinding ctors = new ConstructorBinding(type, tp, co.binder);
// ExtensionType types are untracked, so don't Incref() them.
// XXX deprecate __overloads__ soon...
Runtime.PyDict_SetItemString(dict, "__overloads__", ctors.pyHandle);
Runtime.PyDict_SetItemString(dict, "Overloads", ctors.pyHandle);

as the new class is called 'ConstructorBinder' (instead of
ConstructorBinding) and it does not have a matching constructor. I am trying
to figure out the details, but I assume you will have to push new version
anyway.

Further I assume this only fixes the proper constructor overloading. I am
still interested in the .NET 4.0 and VS2010 support. Can you shed some light
on that? What changes do you expect for proper .NET 4.0 support? I see the
clrmodule.il and the buildclrmodule.bat refering to 2.0 runtime. Is it
enough to change these two?
Post by Barton
See the Tracker/Patches for details.
Hi Barton,
do you still have any plans to work on the merge? I am curious what the
changes are (how much, what impact do they have) and whether there something
can be done to help you with this.
Thanks in advance!
Post by Barton
I've got this working on my private (for the moment) branch. I could do
this merge by this weekend if folks will find it useful.
-Barton
--
oleksii
Oleksii Bidiuk
2011-01-20 13:49:57 UTC
Permalink
Hi Barton,

any news on the problem with ConstructorBinder/ConstructorBinding below? It
seems like the ConstructorBinding class was not checked in. Could this be
the case?

Thanks in advance.
Post by Oleksii Bidiuk
Hi Barton,
thanks for the update! I've got the latest version, but the changes to the
classmanager.cs do not seem to compile
// Implement Overloads on the class object
ConstructorBinding ctors = new ConstructorBinding(type, tp, co.binder);
// ExtensionType types are untracked, so don't Incref() them.
// XXX deprecate __overloads__ soon...
Runtime.PyDict_SetItemString(dict, "__overloads__", ctors.pyHandle);
Runtime.PyDict_SetItemString(dict, "Overloads", ctors.pyHandle);
as the new class is called 'ConstructorBinder' (instead of
ConstructorBinding) and it does not have a matching constructor. I am trying
to figure out the details, but I assume you will have to push new version
anyway.
Further I assume this only fixes the proper constructor overloading. I am
still interested in the .NET 4.0 and VS2010 support. Can you shed some light
on that? What changes do you expect for proper .NET 4.0 support? I see the
clrmodule.il and the buildclrmodule.bat refering to 2.0 runtime. Is it
enough to change these two?
Post by Barton
See the Tracker/Patches for details.
Hi Barton,
do you still have any plans to work on the merge? I am curious what the
changes are (how much, what impact do they have) and whether there something
can be done to help you with this.
Thanks in advance!
Post by Barton
I've got this working on my private (for the moment) branch. I could do
this merge by this weekend if folks will find it useful.
-Barton
--
oleksii
--
oleksii
Barton
2011-01-21 09:06:38 UTC
Permalink
You have a missing project file setting.
I've been reluctant to push my project file because it's apt to break
other peoples builds.

in Python.Runtime.csproj, add the line

<Compile Include="constructorbinding.cs" />

between


<Compile Include="constructorbinder.cs" />
<Compile Include="converter.cs" />
Post by Oleksii Bidiuk
Hi Barton,
thanks for the update! I've got the latest version, but the changes to
the classmanager.cs do not seem to compile
// Implement Overloads on the class object
ConstructorBinding ctors = new ConstructorBinding(type, tp, co.binder);
// ExtensionType types are untracked, so don't Incref() them.
// XXX deprecate __overloads__ soon...
Runtime.PyDict_SetItemString(dict, "__overloads__", ctors.pyHandle);
Runtime.PyDict_SetItemString(dict, "Overloads", ctors.pyHandle);
as the new class is called 'ConstructorBinder' (instead of
ConstructorBinding) and it does not have a matching constructor. I am
trying to figure out the details, but I assume you will have to push
new version anyway.
Further I assume this only fixes the proper constructor overloading. I
am still interested in the .NET 4.0 and VS2010 support. Can you shed
some light on that? What changes do you expect for proper .NET 4.0
support? I see the clrmodule.il <http://clrmodule.il> and the
buildclrmodule.bat refering to 2.0 runtime. Is it enough to change
these two?
See the Tracker/Patches for details.
Post by Oleksii Bidiuk
Hi Barton,
do you still have any plans to work on the merge? I am curious
what the changes are (how much, what impact do they have) and
whether there something can be done to help you with this.
Thanks in advance!
I've got this working on my private (for the moment) branch.
I could do this merge by this weekend if folks will find it
useful.
-Barton
--
oleksii
Loading...