PyCXX: In Python 3.9 Unicode API are being deprecated

Taken from https://sourceforge.net/p/cxx/code/430/
This commit is contained in:
wmayer
2020-12-22 13:05:59 +01:00
parent 04337034ce
commit 52c2e7eff6

View File

@@ -1975,7 +1975,7 @@ namespace Py
}
Char( const unicodestring &v )
: Object( PyUnicode_FromUnicode( const_cast<Py_UNICODE*>( v.data() ),1 ), true )
: Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
{
validate();
}
@@ -1995,20 +1995,20 @@ namespace Py
Char &operator=( const unicodestring &v )
{
set( PyUnicode_FromUnicode( const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
return *this;
}
Char &operator=( int v_ )
{
Py_UNICODE v( v_ );
set( PyUnicode_FromUnicode( &v, 1 ), true );
set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
return *this;
}
Char &operator=( Py_UNICODE v )
{
set( PyUnicode_FromUnicode( &v, 1 ), true );
set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
return *this;
}
@@ -2102,7 +2102,7 @@ namespace Py
}
String( const Py_UNICODE *s, int length )
: SeqBase<Char>( PyUnicode_FromUnicode( s, length ), true )
: SeqBase<Char>( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, s, length ), true )
{
validate();
}
@@ -2122,7 +2122,7 @@ namespace Py
String &operator=( const unicodestring &v )
{
set( PyUnicode_FromUnicode( const_cast<Py_UNICODE *>( v.data() ), v.length() ), true );
set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE *>( v.data() ), v.length() ), true );
return *this;
}