#1026 std::vector iterator in Python

closed-fixed
szager
python (259)
5
2011-04-29
2009-06-24
MarkoK
No

I have "VectorBYTE" declared as

%template(VectorBYTE) std::vector<unsigned char>;

The following used to work with SWIG 1.3.33:
>>> byBuf = VectorBYTE()
>>> byBuf.erase(byBuf.begin())

When SWIG 1.3.39 is used, the following error is generated:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "d:\apps32\Python25\lib\site-packages\isystem\connect.py", line 198, in erase
def erase(self, *args): return _connect.VectorBYTE_erase(self, *args)
NotImplementedError: Wrong number of arguments for overloaded function 'VectorBYTE_erase'.
Possible C/C++ prototypes are:
erase(std::vector< unsigned char > *,std::vector< unsigned char >::iterator)
erase(std::vector< unsigned char > *,std::vector< unsigned char >::iterator, std::vector< unsigned char >::iterator)

It seems that cast in the following line in "_wrap_VectorBYTE_erase(PyObject *self, PyObject *args)" fails:

_v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< unsigned char >::iterator > *>(iter) != 0));

Debugger shows that res = 0 and iter != NULL.
Windows XP, Visual Studio 2008, Python 2.5

Discussion

  • William Fulton

    William Fulton - 2011-02-17

    Possibly related to #2380788

     
  • szager

    szager - 2011-04-29
    • assigned_to: nobody --> szager
    • status: open --> closed-fixed
     
  • szager

    szager - 2011-04-29

    The problem is that begin() returns a const_iterator, but erase() expects a non-const iterator.

    I fixed this in the file Lib/std/std_container.i, revision 12645, by making begin(), end(), rbegin(), and rend() return non-const iterators.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks