Menu

#45 Python 3.13 and Py_UNICODE

None
closed
None
5
2024-12-30
2024-12-28
No

PyCXX provides interface for Py_UNICODE but the type is deprecated since Python 3.13, so that massive of warnings will be yield.

e.g.

/home/***/FreeCAD/src/CXX/Python3/Objects.hxx:1787:31: warning: Py_UNICODE is deprecated [-Wdeprecated-declarations]                                                                                                                        
 1787 |     typedef std::basic_string<Py_UNICODE> unicodestring;                                                                                                                                                                              
      |                               ^~~~~~~~~~                                                                       
In file included from /usr/include/python3.13/unicodeobject.h:1014,                                                    
                 from /usr/include/python3.13/Python.h:79,                                                             
                 from /home/***/FreeCAD/src/CXX/WrapPython.h:58,                                                       
                 from /home/***/FreeCAD/src/CXX/Objects.hxx:37:                                                                                                                                                                               
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here                                             
   10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;                                                                                                                                                                                       
      |                                     ^~~~~~~~~~                                                                                                                                                                                        /home/***/FreeCAD/src/CXX/Python3/Objects.hxx:1788:44: warning: Py_UNICODE is deprecated [-Wdeprecated-declarations]                                                                                                                         1788 |     extern Py_UNICODE unicode_null_string[1];                                                                                                                                                                                         
      |                                            ^                                                                   
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here                                                                                                                                                                    
   10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;                                                                                                                                                                                       
      |                                     ^~~~~~~~~~
/home/***/FreeCAD/src/CXX/Python3/Objects.hxx:1983:28: warning: Py_UNICODE is deprecated [-Wdeprecated-declarations]
 1983 |         Char( Py_UNICODE v )                                                                                                                                                                                                          
      |                            ^                                                                                                                                                                                                          
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here                                                                                                                                                                       10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;                                                                                                                                                                                       
      |                                     ^~~~~~~~~~                                                                                                                                                                                        
/home/***/FreeCAD/src/CXX/Python3/Objects.hxx:2029:39: warning: Py_UNICODE is deprecated [-Wdeprecated-declarations] 
 2029 |         Char &operator=( Py_UNICODE v )                                                                                                                                                                                               
      |                                       ^                                                                        
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here                                                                                                                                                                    
   10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE; 

Discussion

  • Barry Alan Scott

    There is code that uses Py_UNICODE which means that the warning are expected.
    Once Py_UNICODE is removed from the API then I will #if use of Py_UNICODE to older python versions that support it.

    But until then the warning will be present unless you know a way to supress them?

     
  • Kohei Takahashi

    Kohei Takahashi - 2024-12-30

    But until then the warning will be present unless you know a way to supress them?

    Yes, the warnings are always appeared and very noisy even if the program doesn't use Py_UNICODE interface. It is very helpful if adding #if switch to suppress them.

     
  • Barry Alan Scott

    • status: open --> closed
    • assigned_to: Barry Alan Scott
    • Group: -->
     
  • Barry Alan Scott

    There are compiler options to disable reporting deprecation warning.
    Check your compiler docs to see what the option is and add it to your build.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.