VirtualBox

Changeset 86623 in vbox for trunk/src/libs/xpcom18a4/python


Ignore:
Timestamp:
Oct 19, 2020 9:00:23 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140997
Message:

xpcom/python: Update on PyUnicode_AsUTF8AndSize and Py_LIMITED_API. bugref:9840

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h

    r86333 r86623  
    138138#  define PyInt_AsLong(o) PyLong_AsLong(o)
    139139#  define PyNumber_Int(o) PyNumber_Long(o)
    140 #  ifndef PyUnicode_AsUTF8
    141 #   define PyUnicode_AsUTF8(o) _PyUnicode_AsString(o)
    142 #  endif
    143 #  ifndef PyUnicode_AsUTF8AndSize
    144 #   define PyUnicode_AsUTF8AndSize(o,s) _PyUnicode_AsStringAndSize(o,s)
     140#  if !defined(Py_LIMITED_API) && PY_VERSION_HEX <= 0x03030000 /* 3.3 added PyUnicode_AsUTF8AndSize */
     141#   ifndef PyUnicode_AsUTF8
     142#    define PyUnicode_AsUTF8(o) _PyUnicode_AsString(o)
     143#   endif
     144#   ifndef PyUnicode_AsUTF8AndSize
     145#    define PyUnicode_AsUTF8AndSize(o,s) _PyUnicode_AsStringAndSize(o,s)
     146#   endif
    145147#  endif
    146148typedef struct PyMethodChain
     
    175177#else /* Py_LIMITED_API */
    176178
     179# if PY_VERSION_HEX <= 0x03030000
     180#  error "Py_LIMITED_API mode only works for Python 3.3 and higher."
     181# endif
     182
    177183const char *PyXPCOMGetObTypeName(PyTypeObject *pTypeObj);
    178184# define PyXPCOM_ObTypeName(obj) PyXPCOMGetObTypeName(Py_TYPE(obj))
    179185
    180 /** @todo shouldn't be using PyUnicode_AsUTF8 from cpython/unicodeobject.h! */
    181 # undef PyUnicode_AsUTF8
    182 extern "C" PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *);
    183 
    184 /** @todo shouldn't be using PyUnicode_AsUTF8AndSize from cpython/unicodeobject.h! */
    185 # undef PyUnicode_AsUTF8AndSize
     186# if Py_LIMITED_API < 0x030A0000
     187/* Note! While we should not technically be using PyUnicode_AsUTF8AndSize, it was
     188   made part of the limited API in 3.10 (see https://bugs.python.org/issue41784 and
     189   https://github.com/python/cpython/commit/a05195ac61f1908ac5990cccb5aa82442bdaf15d). */
    186190extern "C" PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize(PyObject *, Py_ssize_t *);
     191# endif
     192
     193/* PyUnicode_AsUTF8 is just PyUnicode_AsUTF8AndSize without returning a size. */
     194# define PyUnicode_AsUTF8(o) PyUnicode_AsUTF8AndSize(o, NULL)
    187195
    188196DECLINLINE(int) PyRun_SimpleString(const char *pszCode)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette