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

Fix compilation error #49

Merged
merged 3 commits into from
Sep 8, 2018
Merged

Fix compilation error #49

merged 3 commits into from
Sep 8, 2018

Conversation

ptzz
Copy link
Contributor

@ptzz ptzz commented Jun 30, 2018

Fixes #48.

@maxnordlund
Copy link
Contributor

I also encountered this today, and unfortunately the Travis build fails on python 2. It seems like they may have changed the type with 3.7

@ptzz
Copy link
Contributor Author

ptzz commented Jul 2, 2018

Ah, didn’t check CI results 😕. I’m without computer access for a couple of weeks, anyone feel free to push fixes to this PR meanwhile.

@ptzz
Copy link
Contributor Author

ptzz commented Jul 2, 2018

Turns out I forgot to remove the initial hacky cast solution in the PR. But keeping that (line 48) and removing the rest probably makes CI happy. The cast is probably required anyway to stay compatible with Python < 3.7. The return type of PyUnicode_AsUTF8 did indeed change from char* to const char*.

@maxnordlund
Copy link
Contributor

Can I push to your branch? Or could you give me access to your fork; I could take a stab at it.

@ptzz
Copy link
Contributor Author

ptzz commented Jul 2, 2018

@maxnordlund Sure, did you try? Not sure how it works with permissions, some guy pushed to a PR of mine the other day without me giving explicit permissions. Pushed to my fork that is.

@maxnordlund
Copy link
Contributor

I think that only works for members of the original repo, i.e. nixprime.

@ptzz
Copy link
Contributor Author

ptzz commented Jul 2, 2018

@maxnordlund I’ve sent you a collaborator invite.

@maxnordlund
Copy link
Contributor

maxnordlund commented Jul 2, 2018

Thank you, I've accepted and will try some stuff.

If just the cast won't work, I'm going for the full blown PY_MAJOR_VERSION/PY_MINOR_VERSION conditional compilation changing the signature of PyVimString_AsStringAndSize for ≥ 3.7

@maxnordlund
Copy link
Contributor

Well, that went smoothly. Now it's ready I think, if @nixprime agrees. (Also you can just squash away my commit)

@ptzz
Copy link
Contributor Author

ptzz commented Jul 2, 2018

@maxnordlund 🎉💪👍

@@ -45,7 +45,7 @@ typedef std::unique_ptr<PyObject, PyObjectDeleter> PyObjPtr;
inline bool PyVimString_AsStringAndSize(PyObject* obj, char** data,
Py_ssize_t* size) {
#if PY_MAJOR_VERSION >= 3
*data = PyUnicode_AsUTF8AndSize(obj, size);
*data = (char*)PyUnicode_AsUTF8AndSize(obj, size);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const_cast<char *>(PyUnicode_AsUTF8AndSize(obj, size)) would be more idiomatic for C++.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll change it.

@Shougo
Copy link

Shougo commented Aug 19, 2018

@nixprime Ping. I have encountered the problem today..

@danarnold
Copy link

This PR fixes the issue for me with nvim and python 3.7.0-3. Thanks @ptzz and @maxnordlund !

astyagun added a commit to astyagun/.vim that referenced this pull request Sep 6, 2018
After manually patching the plugin according to
nixprime/cpsm#49
@nixprime nixprime merged commit 3fd5fb9 into nixprime:master Sep 8, 2018
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

Successfully merging this pull request may close these issues.

6 participants