Skip to content

Commit 718df6d

Browse files
committed
remove deprecated APIs
1 parent 06fc65b commit 718df6d

File tree

7 files changed

+23
-381
lines changed

7 files changed

+23
-381
lines changed

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -571,133 +571,6 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
571571
Py_ssize_t start,
572572
Py_ssize_t end);
573573

574-
/* --- Legacy deprecated API ---------------------------------------------- */
575-
576-
/* Create a Unicode Object from the Py_UNICODE buffer u of the given
577-
size.
578-
579-
u may be NULL which causes the contents to be undefined. It is the
580-
user's responsibility to fill in the needed data afterwards. Note
581-
that modifying the Unicode object contents after construction is
582-
only allowed if u was set to NULL.
583-
584-
The buffer is copied into the new object. */
585-
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
586-
const Py_UNICODE *u, /* Unicode buffer */
587-
Py_ssize_t size /* size of buffer */
588-
);
589-
590-
/* Return a read-only pointer to the Unicode object's internal
591-
Py_UNICODE buffer.
592-
If the wchar_t/Py_UNICODE representation is not yet available, this
593-
function will calculate it. */
594-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
595-
PyObject *unicode /* Unicode object */
596-
);
597-
598-
/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
599-
contains null characters. */
600-
PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
601-
PyObject *unicode /* Unicode object */
602-
);
603-
604-
/* Return a read-only pointer to the Unicode object's internal
605-
Py_UNICODE buffer and save the length at size.
606-
If the wchar_t/Py_UNICODE representation is not yet available, this
607-
function will calculate it. */
608-
609-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
610-
PyObject *unicode, /* Unicode object */
611-
Py_ssize_t *size /* location where to save the length */
612-
);
613-
614-
615-
/* Fast access macros */
616-
617-
Py_DEPRECATED(3.3)
618-
static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op)
619-
{
620-
if (PyUnicode_IS_COMPACT_ASCII(op)) {
621-
return _PyASCIIObject_CAST(op)->length;
622-
}
623-
else {
624-
return _PyCompactUnicodeObject_CAST(op)->wstr_length;
625-
}
626-
}
627-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
628-
# define PyUnicode_WSTR_LENGTH(op) PyUnicode_WSTR_LENGTH(_PyObject_CAST(op))
629-
#endif
630-
631-
/* Returns the deprecated Py_UNICODE representation's size in code units
632-
(this includes surrogate pairs as 2 units).
633-
If the Py_UNICODE representation is not available, it will be computed
634-
on request. Use PyUnicode_GET_LENGTH() for the length in code points. */
635-
636-
Py_DEPRECATED(3.3)
637-
static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
638-
{
639-
_Py_COMP_DIAG_PUSH
640-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
641-
if (_PyASCIIObject_CAST(op)->wstr == _Py_NULL) {
642-
(void)PyUnicode_AsUnicode(op);
643-
assert(_PyASCIIObject_CAST(op)->wstr != _Py_NULL);
644-
}
645-
return PyUnicode_WSTR_LENGTH(op);
646-
_Py_COMP_DIAG_POP
647-
}
648-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
649-
# define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
650-
#endif
651-
652-
Py_DEPRECATED(3.3)
653-
static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
654-
{
655-
_Py_COMP_DIAG_PUSH
656-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
657-
return PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE;
658-
_Py_COMP_DIAG_POP
659-
}
660-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
661-
# define PyUnicode_GET_DATA_SIZE(op) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))
662-
#endif
663-
664-
/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
665-
representation on demand. Using this macro is very inefficient now,
666-
try to port your code to use the new PyUnicode_*BYTE_DATA() macros or
667-
use PyUnicode_WRITE() and PyUnicode_READ(). */
668-
669-
Py_DEPRECATED(3.3)
670-
static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
671-
{
672-
wchar_t *wstr = _PyASCIIObject_CAST(op)->wstr;
673-
if (wstr != _Py_NULL) {
674-
return wstr;
675-
}
676-
677-
_Py_COMP_DIAG_PUSH
678-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
679-
return PyUnicode_AsUnicode(op);
680-
_Py_COMP_DIAG_POP
681-
}
682-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
683-
# define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
684-
#endif
685-
686-
Py_DEPRECATED(3.3)
687-
static inline const char* PyUnicode_AS_DATA(PyObject *op)
688-
{
689-
_Py_COMP_DIAG_PUSH
690-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
691-
Py_UNICODE *data = PyUnicode_AS_UNICODE(op);
692-
// In C++, casting directly PyUnicode* to const char* is not valid
693-
return _Py_STATIC_CAST(const char*, _Py_STATIC_CAST(const void*, data));
694-
_Py_COMP_DIAG_POP
695-
}
696-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
697-
# define PyUnicode_AS_DATA(op) PyUnicode_AS_DATA(_PyObject_CAST(op))
698-
#endif
699-
700-
701574
/* --- _PyUnicodeWriter API ----------------------------------------------- */
702575

703576
typedef struct {

Lib/test/test_getargs2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ def test_skipitem_with_suffix(self):
11621162
dict_b = {'b':1}
11631163
keywords = ["a", "b"]
11641164

1165-
supported = ('s#', 's*', 'z#', 'z*', 'u#', 'Z#', 'y#', 'y*', 'w#', 'w*')
1165+
supported = ('s#', 's*', 'z#', 'z*', 'y#', 'y*', 'w#', 'w*')
11661166
for c in string.ascii_letters:
11671167
for c2 in '#*':
11681168
f = c + c2

Makefile.pre.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,7 @@ UNICODE_DEPS = \
14051405
$(srcdir)/Objects/stringlib/ucs2lib.h \
14061406
$(srcdir)/Objects/stringlib/ucs4lib.h \
14071407
$(srcdir)/Objects/stringlib/undef.h \
1408-
$(srcdir)/Objects/stringlib/unicode_format.h \
1409-
$(srcdir)/Objects/stringlib/unicodedefs.h
1408+
$(srcdir)/Objects/stringlib/unicode_format.h
14101409

14111410
Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS)
14121411
Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)

Objects/stringlib/eq.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
* unicode_eq() is called when the hash of two unicode objects is equal.
55
*/
66
Py_LOCAL_INLINE(int)
7-
unicode_eq(PyObject *aa, PyObject *bb)
7+
unicode_eq(PyObject *a, PyObject *b)
88
{
9-
assert(PyUnicode_Check(aa));
10-
assert(PyUnicode_Check(bb));
11-
assert(PyUnicode_IS_READY(aa));
12-
assert(PyUnicode_IS_READY(bb));
13-
14-
PyUnicodeObject *a = (PyUnicodeObject *)aa;
15-
PyUnicodeObject *b = (PyUnicodeObject *)bb;
9+
assert(PyUnicode_Check(a));
10+
assert(PyUnicode_Check(b));
1611

1712
if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
1813
return 0;

Objects/stringlib/unicodedefs.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)