Menu

#1206 Unused runtime function introduces Python Unicode dep

None
closed
szager
python (260)
5
2022-01-30
2011-11-18
Ben Webb
No

Recent SWIG releases include a runtime function, SWIG_Python_NonDynamicSetAttr. This calls a bunch of Python Unicode-handling functions (e.g. PyUnicode_Decode if Py_USING_UNICODE is defined, and PyUnicode_AsUTF8String even if it isn't). This is a nuisance because now when the extension is loaded, the linker tries to look up these functions in the Python .so, and since the Python library comes in both a UCS2 and UCS4 (wide Unicode) variant, the extension now only works if the users of our extension have the same Python variant that we do (or we distribute both UCS2 and UCS4 extensions). It actually turns out that this runtime function isn't called anywhere, at least in our use of SWIG, so we can remove the Python Unicode dependency (and thus not have to distribute two versions of the extension) by removing that function from the wrappers. Is it possible to have SWIG not include that function unless it is actually needed somewhere else, so we don't have to hack our wrappers in this fashion?

Discussion

  • William Fulton

    William Fulton - 2011-11-18

    Stefan, could you look at this please? Looks like it is only used with -builtin.

     
  • William Fulton

    William Fulton - 2011-11-18
    • assigned_to: nobody --> szager
     
  • szager

    szager - 2011-11-18

    Yes, I'll look at this. I remember that this implementation was uglier than I thought it should be. I'll see if I can fix it to avoid the encoding-specific stuff.

    Stefan

     
  • szager

    szager - 2011-11-23

    After some thought, I concluded that this issue isn't fixable when -builtin is used. But I added an #ifdef around SWIG_Python_NonDynamicSetAttr, so the issue goes away if you're not using -builtin.

    Committed as revision 12842, will go into version 2.0.5.

     
  • szager

    szager - 2011-11-23
    • status: open --> pending-fixed
     
  • Olly Betts

    Olly Betts - 2022-01-30
    • status: pending-fixed --> closed
    • Group: -->
     

Log in to post a comment.