<div dir="auto">Don, here is message with ProtoBody setter issue I found.  What I did in the setter is was add xx in front of the ProtoBody parameter, and I got past the error.</div><div dir="auto"><br></div><div dir="auto">I haven’t looked for the enclosing class yet.   I’m guessing that the ProtoDeclare creation is not compliant with SAI standards, which require XML or VRML encodings of Protos?  Afaict.   This would require an XML or VRML parser which I haven’t spotted in x3d.py yet.  I just looked at the examples in the standards, some time ago when I was working with VRMLScript.</div><div dir="auto"><br></div><div dir="auto">See python attached.   </div><div dir="auto"><br></div><div dir="auto">John</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">John Carlson</strong> <span dir="auto"><<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>></span><br>Date: Thu, Aug 19, 2021 at 3:46 AM<br>Subject: x3d.py ProtoBody setter?<br>To: Don Brutzman <<a href="mailto:brutzman@nps.edu">brutzman@nps.edu</a>>, X3D Graphics public mailing list <<a href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a>><br></div><br><br>    Fixing these bugs will give me a lot more confidence in x3d.py.  I <br>
hope there's a 4.0.42 version soon!<br>
<br>
<br>
Existing pattern, finding errors:<br>
<br>
    @ProtoBody.setter<br>
     def ProtoBody(self, ProtoBody):<br>
         if  ProtoBody is None:<br>
             ProtoBody = None # default<br>
         assertValidSFNode(ProtoBody)<br>
         if not ProtoBody is None and not <br>
isinstance(ProtoBody,(ProtoBody,ProtoInstance)):<br>
             # print(flush=True)<br>
             raise X3DTypeError(str(ProtoBody) + ' does not match <br>
required node type (ProtoBody,ProtoInstance) and is invalid')<br>
         self.__ProtoBody = ProtoBody<br>
<br>
<br>
===========================<br>
<br>
Exception (file attached will probably be rejected).   There are many <br>
files with this error.   Could it be a python 3.8 issue?  I'm guessing <br>
that ProtoBody is not a type as in the arg 2 tuple, rather it's a <br>
parameter? (see above)<br>
<br>
$ python3 rubik.py<br>
<br>
x3d.py package loaded, have fun with X3D Graphics!<br>
Traceback (most recent call last):<br>
   File "rubik.py", line 37, in <module><br>
     ProtoDeclare(name='sphereproto',<br>
   File <br>
"/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/x3d.py", <br>
line 10239, in __init__<br>
     self.ProtoBody = ProtoBody<br>
   File <br>
"/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/x3d.py", <br>
line 10282, in ProtoBody<br>
     if not ProtoBody is None and not <br>
isinstance(ProtoBody,(ProtoBody,ProtoInstance)):<br>
TypeError: isinstance() arg 2 must be a type or tuple of types<br>
<br>
=================================<br>
<br>
Perhaps this would be a better pattern?  Please look over this <br>
carefully! (the two str() functions are different).<br>
<br>
     def ProtoBody(self, xxProtoBody):<br>
         if  xxProtoBody is None:<br>
             xxProtoBody = None # default<br>
         assertValidSFNode(xxProtoBody)<br>
         if not xxProtoBody is None and not <br>
isinstance(xxProtoBody,(ProtoBody,ProtoInstance)):<br>
             # print(flush=True)<br>
             raise X3DTypeError(str(xxProtoBody) + ' does not match <br>
required node type (ProtoBody,ProtoInstance) and is invalid')<br>
         self.__ProtoBody = xxProtoBody<br>
<br>
also:<br>
<br>
     @ProtoInterface.setter<br>
     def ProtoInterface(self, xxProtoInterface):<br>
         if  xxProtoInterface is None:<br>
             xxProtoInterface = None # default<br>
         assertValidSFNode(xxProtoInterface)<br>
         if not xxProtoInterface is None and not <br>
isinstance(xxProtoInterface,(ProtoInterface,ProtoInstance)):<br>
             # print(flush=True)<br>
             raise X3DTypeError(str(ProtoInterface) + ' does not match <br>
required node type (ProtoInterface,ProtoInstance) and is invalid')<br>
         self.__ProtoInterface = xxProtoInterface<br>
<br>
<br>
========================================================<br>
<br>
Possible patch like above, but there's errors in ```ant examples``` and <br>
```ant examples.SmokeTests```, so please look over this carefully, or <br>
provide your own implementation of setters. This just got past the two <br>
"problems" above. There's more to do here.<br>
<br>
<br>
$ svn diff X3duomToX3dPythonPackage.xslt<br>
Index: X3duomToX3dPythonPackage.xslt<br>
===================================================================<br>
--- X3duomToX3dPythonPackage.xslt       (revision 32361)<br>
+++ X3duomToX3dPythonPackage.xslt       (working copy)<br>
@@ -2727,17 +2727,9 @@<br>
                  <xsl:text><br>
      def </xsl:text><!-- setter --><br>
                  <xsl:value-of select="$fieldName"/><br>
-                <xsl:text>(self, </xsl:text><br>
-                <xsl:value-of select="$fieldName"/><br>
-                <!-- =None is omitted; note that setter NEVER needs a <br>
default argument, it is only EVER called if attribute is being assigned <br>
with RHS passed as single argument --><br>
-                <xsl:text>):<br>
-        if  </xsl:text><br>
-                <xsl:value-of select="$fieldName"/><br>
-                <xsl:text> is None:<br>
-            </xsl:text><br>
-                <xsl:value-of select="$fieldName"/><br>
-                <xsl:text> = </xsl:text><br>
-                <xsl:choose><br>
+                <xsl:text>(self, xx</xsl:text><xsl:value-of <br>
select="$fieldName"/><!-- =None is omitted; note that setter NEVER needs <br>
a default argument, it is only EVER called if attribute is being <br>
assigned with RHS passed as single argument --><xsl:text>):<br>
+        if  </xsl:text>xx<xsl:value-of select="$fieldName"/><xsl:text> <br>
is None:</xsl:text><br>
+                xx<xsl:value-of select="$fieldName"/><xsl:text> = <br>
</xsl:text><xsl:choose><br>
                      <xsl:when test="(string-length(@default) > 0)"><br>
                          <xsl:value-of select="$defaultValue"/><br>
                          <xsl:text> # default</xsl:text><br>
@@ -2798,9 +2790,7 @@<br>
                  <xsl:text><br>
          assertValid</xsl:text><br>
                  <xsl:value-of select="@type"/><br>
-                <xsl:text>(</xsl:text><br>
-                <xsl:value-of select="$fieldName"/><br>
-                <xsl:text>)</xsl:text><br>
+ <xsl:text>(</xsl:text>xx<xsl:value-of <br>
select="$fieldName"/><xsl:text>)</xsl:text><br>
                  <xsl:call-template name="valueRestrictionCheck"><br>
                      <xsl:with-param name="fieldName" select="$fieldName"/><br>
                      <xsl:with-param name="indent"><xsl:text> <br>
</xsl:text></xsl:with-param><br>
@@ -2814,13 +2804,7 @@<br>
                  <xsl:choose><br>
                      <xsl:when test="(@type = 'SFNode') and <br>
(string-length($acceptableNodeTypes) > 0)"><br>
                          <xsl:text><br>
-        if not </xsl:text><br>
-                        <xsl:value-of select="$fieldName"/><br>
-                        <xsl:text> is None and not isinstance(</xsl:text><br>
-                        <xsl:value-of select="$fieldName"/><br>
-                        <xsl:text>,</xsl:text><br>
-                        <xsl:value-of select="$acceptableNodeTypes"/><br>
-                        <xsl:text>):<br>
+        if not </xsl:text>xx<xsl:value-of <br>
select="$fieldName"/><xsl:text> is None and not <br>
isinstance(</xsl:text>xx<xsl:value-of <br>
select="$fieldName"/><xsl:text>,</xsl:text><xsl:value-of <br>
select="$acceptableNodeTypes"/><xsl:text>):<br>
              # print(flush=True)<br>
              raise X3DTypeError(str(</xsl:text><br>
                          <xsl:value-of select="$fieldName"/><br>
@@ -2838,8 +2822,7 @@<br>
                  <xsl:text><br>
          self.__</xsl:text><br>
                  <xsl:value-of select="$fieldName"/><br>
-                <xsl:text> = </xsl:text><br>
-                <xsl:value-of select="$fieldName"/><br>
+                <xsl:text> = </xsl:text>xx<xsl:value-of <br>
select="$fieldName"/><br>
              </xsl:if><br>
<br>
          </xsl:for-each><br>
<br>
</div></div>