Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support xylib.load_stream in Python SWIG interface #8

Closed
perimosocordiae opened this issue Aug 20, 2016 · 5 comments
Closed

Support xylib.load_stream in Python SWIG interface #8

perimosocordiae opened this issue Aug 20, 2016 · 5 comments

Comments

@perimosocordiae
Copy link

Using the SWIG interface works great for xylib.load_file, but this usage fails:

import xylib
xylib.load_stream(open('some_file.txt'), 'text')

The resulting error message:

NotImplementedError: Wrong number or type of arguments for overloaded function 'load_stream'.
  Possible C/C++ prototypes are:
    xylib::load_stream(std::istream &,std::string const &,std::string const &)
    xylib::load_stream(std::istream &,std::string const &)

I believe the problem arises from the need to convert between a Python file object and the C++ std::istream& type. Apparently, SWIG doesn't do this automatically. I found some posts about this problem which might help:

@wojdyr
Copy link
Owner

wojdyr commented Aug 22, 2016

wow, someone is using it :-)

I didn't know if the python bindings will be used at all, so I didn't put much work into it (swig.i is minimal). I suppose load_stream is one of a few functions that are not handled automatically by SWIG. I'll look into it when I'm back from holidays, in a few days.

@wojdyr
Copy link
Owner

wojdyr commented Aug 23, 2016

Would it work for you if you had load_string() instead of load_stream()?
In addition to load_file().

@perimosocordiae
Copy link
Author

Yeah, that would fit my needs perfectly. (I'm parsing data that's being uploaded to a web server.)

wojdyr added a commit that referenced this issue Aug 25, 2016
@wojdyr
Copy link
Owner

wojdyr commented Sep 13, 2016

I've added load_string() that takes bytes as the first argument and uploaded new version to pypi.

@wojdyr wojdyr closed this as completed Sep 13, 2016
@perimosocordiae
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants