google-deepmind / tree

tree is a library for working with nested data structures
https://tree.readthedocs.io
Apache License 2.0
938 stars 59 forks source link

`PyUnicode_AsUTF8` was not declared in this scope; did you mean `PyUnicode_Type`? #74

Closed joshiayush closed 1 year ago

joshiayush commented 2 years ago

When building tree locally I get the following error saying PyUnicode_AsUTF8 was not declared in this scope; did you mean PyUnicode_Type?.

Environment information

/Python/tree/tree/tree.cc: In function ‘std::string tree::{anonymous}::PyObjectToString(PyObject*)’:
/Python/tree/tree/tree.cc:86:19: error: ‘PyUnicode_AsUTF8’ was not declared in this scope; did you mean ‘PyUnicode_Type’?
   86 |     std::string s(PyUnicode_AsUTF8(str));
      |                   ^~~~~~~~~~~~~~~~
      |                   PyUnicode_Type
make[2]: *** [CMakeFiles/_tree.dir/build.make:76: CMakeFiles/_tree.dir/tree.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:128: CMakeFiles/_tree.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Environment information

superbobry commented 1 year ago

PyUnicode_AsUTF8 is part of the official Python C API, so this should compile AFAICT.

I will close the issue for now, but feel free to reopen if this is still an issue.