sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

ARBSubscriptionType issue with Python 3.8

Open countach74 opened this issue 5 years ago • 6 comments

When updating from Python 3.7 => 3.8, I've started to receive the following complaint from Authorize.net / PyXB:

TypeError: function takes 3 arguments plus optional tzinfo (8 given)
  File "authorizenet/apicontrollersbase.py", line 134, in execute
    xmlRequest = self.buildrequest()
  File "authorizenet/apicontrollersbase.py", line 105, in buildrequest
    xmlRequest = self._request.toxml(encoding=constants.xml_encoding, element_name=self.getrequesttype())
  File "pyxb/binding/basis.py", line 555, in toxml
    dom = self.toDOM(bds, element_name=element_name)
  File "pyxb/binding/basis.py", line 527, in toDOM
    self._toDOM_csc(bds, element)
  File "pyxb/binding/basis.py", line 2675, in _toDOM_csc
    content.elementDeclaration.toDOM(dom_support, parent, content.value)
  File "pyxb/binding/content.py", line 1101, in toDOM
    value._toDOM_csc(dom_support, element)
  File "pyxb/binding/basis.py", line 2675, in _toDOM_csc
    content.elementDeclaration.toDOM(dom_support, parent, content.value)
  File "pyxb/binding/content.py", line 1101, in toDOM
    value._toDOM_csc(dom_support, element)
  File "pyxb/binding/basis.py", line 2675, in _toDOM_csc
    content.elementDeclaration.toDOM(dom_support, parent, content.value)
  File "pyxb/binding/content.py", line 1101, in toDOM
    value._toDOM_csc(dom_support, element)
  File "pyxb/binding/basis.py", line 1119, in _toDOM_csc
    dom_support.appendTextChild(self, parent)
  File "pyxb/utils/domutils.py", line 584, in appendTextChild
    return parent.appendChild(self.document().createTextNode(self.valueAsText(text)))
  File "pyxb/utils/domutils.py", line 402, in valueAsText
    return value.xsdLiteral()
  File "pyxb/binding/basis.py", line 992, in xsdLiteral
    return self.XsdLiteral(self)
  File "pyxb/binding/datatypes.py", line 738, in XsdLiteral
    value += datetime.timedelta(minutes=cls.__MinutesPerHalfDay)
  File "pyxb/binding/datatypes.py", line 662, in __new__
    raise TypeError('function takes %d arguments plus optional tzinfo (%d given)' % (len(cls._ValidFields), len(args)))

It seems to be related to the paymentScheduleType.startDate property. I've tried setting it to a pyxb date, a python datetime.date, and a string. None of these work. And if I roll back to Python 3.7, the issue goes away. Any thoughts or suggestions? Is this a mistake on my end?

countach74 avatar Dec 16 '19 20:12 countach74

I've encoutered the same problem. I've created an issue directly on PyXB and also found an temporary solution: https://github.com/pabigot/pyxb/issues/123

AntonDeMeester avatar Mar 16 '20 08:03 AntonDeMeester

Reproducable in 3.9.

I've tried many things, including @AntonDeMeester's solution but nothing is working. Any help would be greatly appreciated as this is holding up a production release.

Sharpienero avatar Jun 03 '21 19:06 Sharpienero

I'm pretty sure I found a solution but for the life of me I actually can't find what it was. Been so long ago now, I can't even remember what project I ran into this on.

countach74 avatar Jun 04 '21 02:06 countach74

I'm pretty sure I found a solution but for the life of me I actually can't find what it was. Been so long ago now, I can't even remember what project I ran into this on.

The solution above by @AntonDeMeester did end up working with 3.9. Just had to set startDate = customdate(datetime object) and it ended up posting the ARB correctly.

This is a clear issue with pyxb and Authorize.net, but I don't see any real resolution coming for this. Shame, really.

Thanks for everyone's help.

Sharpienero avatar Jun 04 '21 02:06 Sharpienero

Facing the same issue with Python 3.10, the custom date is also not working. Any recommendations will be helpful. Thank you.

ghost avatar Oct 18 '23 05:10 ghost

@anmolmonga-kiwi Are you sure? I use this solution on 3.10.

Sharpienero avatar Oct 18 '23 05:10 Sharpienero

TCS-Dev Dhanashree- If I try to execute the file, I am not able to reproduce the error because we have replaced the offending serialization library with a newer one, which will hopefully not cause more issues like this.

This issue has been fixed in v1.1.5.

dhanashreeyadav1 avatar Sep 30 '24 11:09 dhanashreeyadav1