[Python.NET] TypeError: No method matches given arguments for SetContext: (<class 'int'>)

Steven Manross <[email protected]> Thu, 14 Jul 2022 19:58:08 +0000
Newsgroups gmane.comp.python.dotnet
Message-ID <[email protected]>
--===============4213736386130510007==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_ea084e857afc4b5eba1d4d2def23cd6emanrossnet_"

--_000_ea084e857afc4b5eba1d4d2def23cd6emanrossnet_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I got my initial code working on the C DLL and it's creating snapshot sets =
as I want.  I am now having a problem with a function to query ALL the snap=
shots.

This value can be sent to SetContext()
In [39]: alphavsslib.VssSnapshotContext.All
Out[39]: 4294967295

4294967295 =3D 0xFFFFFFFF

A sample of the call is here:
https://github.com/alphaleonis/AlphaVSS-Samples/blob/8482e83dd13cb8467860e8=
be199d265963aa6ab8/src/SnapshotQuery/Program.cs

# this is the declaration of SetContext
virtual void SetContext(VssSnapshotContext context);

This is the declaration for All:   VssSnapshotContext.All =3D 0xFFFFFFFF
https://github.com/alphaleonis/AlphaVSS/blob/13462e657f7993da5c80f835d219bb=
e82079ce75/src/AlphaVSS.Common/Enumerations/VssSnapshotContext.cs#L58

However, this line results in a Type error

In [40]: ctx =3D cmp.SetContext(alphavsslib.VssSnapshotContext.All)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [40], in <cell line: 1>()
----> 1 ctx =3D cmp.SetContext(alphavsslib.VssSnapshotContext.All)

TypeError: No method matches given arguments for SetContext: (<class 'int'>=
)


I've tried converting the value using:

ctx =3D cmp.SetContext(System.Convert.ToUInt32(alphavsslib.VssSnapshotConte=
xt.All))

*And*
ctx =3D cmp.SetContext(ctypes.c_uint32(alphavsslib.VssSnapshotContext.All).=
value)

but the same error occurs

I can get the function to succeed (albeit it doesn't show me what I want) w=
ith this:

cmp.SetContext(ctypes.c_int32(alphavsslib.VssSnapshotContext.All).value)

... because ctypes.c_int32(alphavsslib.VssSnapshotContext.All).value =3D -1

I believe it's possible that this could be related to the link below but I =
can't be sure because I am not a C developer and I can't determine how this=
 was fix from the notes in the link.

Granted, the author is on CentOS, and I'm on Windows... but the backstory b=
ehind the issue sounds like it's related.

https://github.com/pythonnet/pythonnet/issues/950

I'm currently running on pythonnet 2.5.2 and
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 =
bit (AMD64)] on win32

Any thoughts or suggestions would be greatly appreciated.

Steven

--_000_ea084e857afc4b5eba1d4d2def23cd6emanrossnet_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.pl-k
	{mso-style-name:pl-k;}
span.pl-en
	{mso-style-name:pl-en;}
span.pl-c1
	{mso-style-name:pl-c1;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:194193644;
	mso-list-type:hybrid;
	mso-list-template-ids:2098766708 1193440642 67698691 67698693 67698689 676=
98691 67698693 67698689 67698691 67698693;}
@list l0:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:20.25pt;
	text-indent:-.25in;
	font-family:Symbol;
	mso-fareast-font-family:Calibri;
	mso-bidi-font-family:"Times New Roman";}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:56.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:92.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:128.25pt;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:164.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:200.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:236.25pt;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:272.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:308.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l1
	{mso-list-id:939606948;
	mso-list-type:hybrid;
	mso-list-template-ids:-128834376 1448666662 67698691 67698693 67698689 676=
98691 67698693 67698689 67698691 67698693;}
@list l1:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:20.25pt;
	text-indent:-.25in;
	font-family:"Calibri",sans-serif;
	mso-fareast-font-family:Calibri;}
@list l1:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:56.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l1:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:92.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l1:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:128.25pt;
	text-indent:-.25in;
	font-family:Symbol;}
@list l1:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:164.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l1:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:200.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l1:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:236.25pt;
	text-indent:-.25in;
	font-family:Symbol;}
@list l1:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:272.25pt;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l1:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	margin-left:308.25pt;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l2
	{mso-list-id:1668901329;
	mso-list-type:hybrid;
	mso-list-template-ids:-786790346 -58553054 67698691 67698693 67698689 6769=
8691 67698693 67698689 67698691 67698693;}
@list l2:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Calibri",sans-serif;
	mso-fareast-font-family:Calibri;}
@list l2:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l2:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l2:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l2:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l2:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l2:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l2:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l2:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72" style=3D"word-wrap:=
break-word">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">I got my initial code working on the C DLL and it&#8=
217;s creating snapshot sets as I want.&nbsp; I am now having a problem wit=
h a function to query ALL the snapshots.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">This value can be sent to SetContext()<o:p></o:p></p=
>
<p class=3D"MsoNormal">In [39]: alphavsslib.VssSnapshotContext.All<o:p></o:=
p></p>
<p class=3D"MsoNormal">Out[39]: 4294967295<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">4294967295 =3D 0xFFFFFFFF<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal">A sample of the call is here:<br>
<a href=3D"https://github.com/alphaleonis/AlphaVSS-Samples/blob/8482e83dd13=
cb8467860e8be199d265963aa6ab8/src/SnapshotQuery/Program.cs">https://github.=
com/alphaleonis/AlphaVSS-Samples/blob/8482e83dd13cb8467860e8be199d265963aa6=
ab8/src/SnapshotQuery/Program.cs</a><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span class=3D"pl-k"><span style=3D"font-size:9.0pt;=
font-family:Consolas"># this is the declaration of SetContext<o:p></o:p></s=
pan></span></p>
<p class=3D"MsoNormal"><span class=3D"pl-k"><span style=3D"font-size:9.0pt;=
font-family:Consolas">virtual</span></span><span style=3D"font-size:9.0pt;f=
ont-family:Consolas;color:#24292F;background:#FFF8C5">
</span><span class=3D"pl-k"><span style=3D"font-size:9.0pt;font-family:Cons=
olas">void</span></span><span style=3D"font-size:9.0pt;font-family:Consolas=
;color:#24292F;background:#FFF8C5">
</span><span class=3D"pl-en"><span style=3D"font-size:9.0pt;font-family:Con=
solas">SetContext</span></span><span style=3D"font-size:9.0pt;font-family:C=
onsolas;color:#24292F;background:#FFF8C5">(VssSnapshotContext context);<o:p=
></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">This is the declaration for All:&nbsp;&nbsp; VssSnap=
shotContext.<span class=3D"pl-en"><span style=3D"font-size:9.0pt;font-famil=
y:Consolas">All</span></span><span style=3D"font-size:9.0pt;font-family:Con=
solas;color:#24292F;background:#FFF8C5">
</span><span class=3D"pl-k"><span style=3D"font-size:9.0pt;font-family:Cons=
olas">=3D</span></span><span style=3D"font-size:9.0pt;font-family:Consolas;=
color:#24292F;background:#FFF8C5">
</span><span class=3D"pl-c1"><span style=3D"font-size:9.0pt;font-family:Con=
solas">0xFFFFFFFF</span></span><o:p></o:p></p>
<p class=3D"MsoNormal"><a href=3D"https://github.com/alphaleonis/AlphaVSS/b=
lob/13462e657f7993da5c80f835d219bbe82079ce75/src/AlphaVSS.Common/Enumeratio=
ns/VssSnapshotContext.cs#L58">https://github.com/alphaleonis/AlphaVSS/blob/=
13462e657f7993da5c80f835d219bbe82079ce75/src/AlphaVSS.Common/Enumerations/V=
ssSnapshotContext.cs#L58</a><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">However, this line results in a Type error <o:p></o:=
p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">In [40]: ctx =3D cmp.SetContext(alphavsslib.VssSnaps=
hotContext.All)<o:p></o:p></p>
<p class=3D"MsoNormal">----------------------------------------------------=
-----------------------<o:p></o:p></p>
<p class=3D"MsoNormal">TypeError&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Traceback (most recent call last)<o:p></o:p></p>
<p class=3D"MsoNormal">Input In [40], in &lt;cell line: 1&gt;()<o:p></o:p><=
/p>
<p class=3D"MsoNormal">----&gt; 1 ctx =3D cmp.SetContext(alphavsslib.VssSna=
pshotContext.All)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">TypeError: No method matches given arguments for Set=
Context: (&lt;class 'int'&gt;)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span class=3D"pl-k"><span style=3D"font-size:9.0pt;=
font-family:Consolas"><o:p>&nbsp;</o:p></span></span></p>
<p class=3D"MsoNormal">I&#8217;ve tried converting the value using:<o:p></o=
:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">ctx =3D cmp.SetContext(System.Convert.ToUInt32(alpha=
vsslib.VssSnapshotContext.All))<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:2.25pt">*<b>And</b>*<o:p></o:p>=
</p>
<p class=3D"MsoNormal" style=3D"margin-left:2.25pt"><o:p></o:p></p>
<p class=3D"MsoNormal">ctx =3D cmp.SetContext(ctypes.c_uint32(alphavsslib.V=
ssSnapshotContext.All).value)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">but the same error occurs<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I can get the function to succeed (albeit it doesn&#=
8217;t show me what I want) with this:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in">cmp.SetContext(ctypes.c_i=
nt32(alphavsslib.VssSnapshotContext.All).value)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&#8230; because ctypes.c_int32(alphavsslib.VssSnapsh=
otContext.All).value =3D -1<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I believe it&#8217;s possible that this could be rel=
ated to the link below but I can&#8217;t be sure because I am not a C devel=
oper and I can&#8217;t determine how this was fix from the notes in the lin=
k.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Granted, the author is on CentOS, and I&#8217;m on W=
indows&#8230; but the backstory behind the issue sounds like it&#8217;s rel=
ated.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><a href=3D"https://github.com/pythonnet/pythonnet/is=
sues/950">https://github.com/pythonnet/pythonnet/issues/950</a><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I&#8217;m currently running on pythonnet 2.5.2 and<o=
:p></o:p></p>
<p class=3D"MsoNormal">Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16=
:36:42) [MSC v.1929 64 bit (AMD64)] on win32<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Any thoughts or suggestions would be greatly appreci=
ated.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Steven<o:p></o:p></p>
</div>
</body>
</html>

--_000_ea084e857afc4b5eba1d4d2def23cd6emanrossnet_--

--===============4213736386130510007==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]

--===============4213736386130510007==--