Menu

#18 Problems with Non-Str-Strings

v1.0_(example)
closed
None
5
2014-07-28
2014-07-14
George
No

I'm converting some code from cx_Oracle to MSSQL via Adodbapi.

Some of the data has come from an XML file so is in "lxml.etree._ElementStringResult" variables. With cx_Oracle this wasn't a problem but Adodbapi crashes as it thinks it's an unknown variable type.

In my situation I've added

    try:
        import lxml
        typeMap[lxml.etree._ElementStringResult] = adc.adBSTR
    except:
        pass

To apibase.py to fix this but does having to do this go against Duck Typing?

Discussion

  • Vernon Cole

    Vernon Cole - 2014-07-28
    • status: open --> closed
    • assigned_to: Vernon Cole
     
  • Vernon Cole

    Vernon Cole - 2014-07-28

    I have added code to try introspecting the object itself when the type of the object is not recognized. It should work now if the object returns "True" to any of:

    isinstance(d, StringTypes)

    isinstance(d, number.Integral)

    isinstance(d, number.Float)

    Fixed in 2.6.1.0

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.