[Python-checkins] r85831 - in python/branches/pep-0384: Include/complexobject.h Include/floatobject.h Include/longobject.h Include/pyerrors.h Include/unicodeobject.h Modules/getpath.c Objects/funcobject.c Objects/unicodeobject.c Python/bltinmodule.c Python/import.c Python/pythonrun.c
martin.v.loewis
python-checkins at python.org
Sun Oct 24 23:17:11 CEST 2010
Author: martin.v.loewis
Date: Sun Oct 24 23:17:11 2010
New Revision: 85831
Log:
Hide Py_UNICODE.
Fix some callers of PyEval_EvalCodeEx.
Modified:
python/branches/pep-0384/Include/complexobject.h
python/branches/pep-0384/Include/floatobject.h
python/branches/pep-0384/Include/longobject.h
python/branches/pep-0384/Include/pyerrors.h
python/branches/pep-0384/Include/unicodeobject.h
python/branches/pep-0384/Modules/getpath.c
python/branches/pep-0384/Objects/funcobject.c
python/branches/pep-0384/Objects/unicodeobject.c
python/branches/pep-0384/Python/bltinmodule.c
python/branches/pep-0384/Python/import.c
python/branches/pep-0384/Python/pythonrun.c
Modified: python/branches/pep-0384/Include/complexobject.h
==============================================================================
--- python/branches/pep-0384/Include/complexobject.h (original)
+++ python/branches/pep-0384/Include/complexobject.h Sun Oct 24 23:17:11 2010
@@ -56,9 +56,11 @@
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
Py_UNICODE *format_spec,
Py_ssize_t format_spec_len);
+#endif
#ifdef __cplusplus
}
Modified: python/branches/pep-0384/Include/floatobject.h
==============================================================================
--- python/branches/pep-0384/Include/floatobject.h (original)
+++ python/branches/pep-0384/Include/floatobject.h Sun Oct 24 23:17:11 2010
@@ -107,9 +107,11 @@
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
Py_UNICODE *format_spec,
Py_ssize_t format_spec_len);
+#endif
#ifdef __cplusplus
}
Modified: python/branches/pep-0384/Include/longobject.h
==============================================================================
--- python/branches/pep-0384/Include/longobject.h (original)
+++ python/branches/pep-0384/Include/longobject.h Sun Oct 24 23:17:11 2010
@@ -83,7 +83,9 @@
#endif /* HAVE_LONG_LONG */
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
+#endif
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
v must not be NULL, and must be a normalized long.
@@ -156,9 +158,11 @@
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
Py_UNICODE *format_spec,
Py_ssize_t format_spec_len);
+#endif
/* These aren't really part of the long object, but they're handy. The
functions are in Python/mystrtoul.c.
Modified: python/branches/pep-0384/Include/pyerrors.h
==============================================================================
--- python/branches/pep-0384/Include/pyerrors.h (original)
+++ python/branches/pep-0384/Include/pyerrors.h Sun Oct 24 23:17:11 2010
@@ -179,7 +179,7 @@
PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
PyObject *, const char *);
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
PyObject *, const Py_UNICODE *);
#endif /* MS_WINDOWS */
@@ -191,15 +191,20 @@
int, const char *);
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
int, const char *);
+#ifndef Py_LIMITED_API
+/* XXX redeclare to use WSTRING */
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
int, const Py_UNICODE *);
+#endif
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
PyObject *,int, PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
PyObject *,int, const char *);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
PyObject *,int, const Py_UNICODE *);
+#endif
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
#endif /* MS_WINDOWS */
@@ -236,12 +241,16 @@
const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* create a UnicodeEncodeError object */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+#endif
/* create a UnicodeTranslateError object */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+#endif
/* get the encoding attribute */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
Modified: python/branches/pep-0384/Include/unicodeobject.h
==============================================================================
--- python/branches/pep-0384/Include/unicodeobject.h (original)
+++ python/branches/pep-0384/Include/unicodeobject.h Sun Oct 24 23:17:11 2010
@@ -130,7 +130,9 @@
Python and represents a single Unicode element in the Unicode
type. */
+#ifndef Py_LIMITED_API
typedef PY_UNICODE_TYPE Py_UNICODE;
+#endif
/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
@@ -315,6 +317,7 @@
configure Python using --with-wctype-functions. This reduces the
interpreter's code size. */
+#ifndef Py_LIMITED_API
#if defined(Py_UNICODE_WIDE) && defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS)
#include <wctype.h>
@@ -395,6 +398,7 @@
((*((string)->str + (offset)) == *((substring)->str)) && \
((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
!memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE)))
+#endif /* Py_LIMITED_API */
#ifdef __cplusplus
extern "C" {
@@ -402,6 +406,7 @@
/* --- Unicode Type ------------------------------------------------------- */
+#ifndef Py_LIMITED_API
typedef struct {
PyObject_HEAD
Py_ssize_t length; /* Length of raw Unicode data in buffer */
@@ -414,6 +419,7 @@
string, or NULL; this is used for
implementing the buffer protocol */
} PyUnicodeObject;
+#endif
PyAPI_DATA(PyTypeObject) PyUnicode_Type;
PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
@@ -427,6 +433,7 @@
#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type)
/* Fast access macros */
+#ifndef Py_LIMITED_API
#define PyUnicode_GET_SIZE(op) \
(assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length))
#define PyUnicode_GET_DATA_SIZE(op) \
@@ -435,6 +442,7 @@
(assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->str))
#define PyUnicode_AS_DATA(op) \
(assert(PyUnicode_Check(op)),((const char *)((PyUnicodeObject *)(op))->str))
+#endif
/* --- Constants ---------------------------------------------------------- */
@@ -459,10 +467,12 @@
The buffer is copied into the new object. */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
const Py_UNICODE *u, /* Unicode buffer */
Py_ssize_t size /* size of buffer */
);
+#endif
/* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */
PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize(
@@ -479,9 +489,11 @@
/* Return a read-only pointer to the Unicode object's internal
Py_UNICODE buffer. */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
PyObject *unicode /* Unicode object */
);
+#endif
/* Get the length of the Unicode object. */
@@ -489,8 +501,10 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
/* Get the maximum ordinal for a Unicode character. */
PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
+#endif
/* Resize an already allocated Unicode object to the new size length.
@@ -554,11 +568,13 @@
PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list);
PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...);
+#ifndef Py_LIMITED_API
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
Py_UNICODE *format_spec,
Py_ssize_t format_spec_len);
+#endif
PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **);
PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
@@ -595,7 +611,7 @@
error. */
PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
- PyUnicodeObject *unicode, /* Unicode object */
+ PyObject *unicode, /* Unicode object */
register wchar_t *w, /* wchar_t buffer */
Py_ssize_t size /* size of buffer */
);
@@ -751,12 +767,14 @@
/* Encodes a Py_UNICODE buffer of the given size and returns a
Python string object. */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_Encode(
const Py_UNICODE *s, /* Unicode char buffer */
Py_ssize_t size, /* number of Py_UNICODE chars to encode */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
+#endif
/* Encodes a Unicode object and returns the result as Python
object. */
@@ -806,6 +824,7 @@
Py_ssize_t *consumed /* bytes consumed */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
@@ -813,6 +832,7 @@
int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
const char *errors /* error handling */
);
+#endif
/* --- UTF-8 Codecs ------------------------------------------------------- */
@@ -833,11 +853,13 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
+#endif
/* --- UTF-32 Codecs ------------------------------------------------------ */
@@ -906,12 +928,14 @@
*/
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
);
+#endif
/* --- UTF-16 Codecs ------------------------------------------------------ */
@@ -984,12 +1008,14 @@
*/
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
);
+#endif
/* --- Unicode-Escape Codecs ---------------------------------------------- */
@@ -1003,10 +1029,12 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
);
+#endif
/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
@@ -1020,10 +1048,12 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
);
+#endif
/* --- Unicode Internal Codec ---------------------------------------------
@@ -1051,11 +1081,13 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
+#endif
/* --- ASCII Codecs -------------------------------------------------------
@@ -1073,11 +1105,13 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
+#endif
/* --- Character Map Codecs -----------------------------------------------
@@ -1115,6 +1149,7 @@
(unicode ordinal -> char ordinal) */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
@@ -1122,6 +1157,7 @@
(unicode ordinal -> char ordinal) */
const char *errors /* error handling */
);
+#endif
/* Translate a Py_UNICODE buffer of the given length by applying a
character mapping table to it and return the resulting Unicode
@@ -1136,12 +1172,14 @@
*/
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *table, /* Translate table */
const char *errors /* error handling */
);
+#endif
#ifdef MS_WIN32
@@ -1164,11 +1202,13 @@
PyObject *unicode /* Unicode object */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
+#endif
#endif /* MS_WIN32 */
@@ -1196,12 +1236,14 @@
*/
+#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Py_UNICODE *s, /* Unicode buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
char *output, /* Output buffer; must have size >= length */
const char *errors /* error handling */
);
+#endif
/* --- File system encoding ---------------------------------------------- */
@@ -1465,26 +1507,31 @@
PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s);
+#ifndef Py_LIMITED_API
/* Externally visible for str.strip(unicode) */
PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
PyUnicodeObject *self,
int striptype,
PyObject *sepobj
);
+#endif
/* Using the current locale, insert the thousands grouping
into the string pointed to by buffer. For the argument descriptions,
see Objects/stringlib/localeutil.h */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGroupingLocale(Py_UNICODE *buffer,
Py_ssize_t n_buffer,
Py_UNICODE *digits,
Py_ssize_t n_digits,
Py_ssize_t min_width);
+#endif
/* Using explicit passed-in values, insert the thousands grouping
into the string pointed to by buffer. For the argument descriptions,
see Objects/stringlib/localeutil.h */
+#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
Py_ssize_t n_buffer,
Py_UNICODE *digits,
@@ -1492,6 +1539,7 @@
Py_ssize_t min_width,
const char *grouping,
const char *thousands_sep);
+#endif
/* === Characters Type APIs =============================================== */
/* Helper array used by Py_UNICODE_ISSPACE(). */
@@ -1577,6 +1625,7 @@
Py_UCS4 ch /* Unicode character */
);
+#ifndef Py_LIMITED_API
PyAPI_FUNC(size_t) Py_UNICODE_strlen(
const Py_UNICODE *u
);
@@ -1610,6 +1659,7 @@
const Py_UNICODE *s,
Py_UNICODE c
);
+#endif
#ifdef __cplusplus
}
Modified: python/branches/pep-0384/Modules/getpath.c
==============================================================================
--- python/branches/pep-0384/Modules/getpath.c (original)
+++ python/branches/pep-0384/Modules/getpath.c Sun Oct 24 23:17:11 2010
@@ -421,7 +421,7 @@
fclose(f);
decoded = PyUnicode_DecodeUTF8(buf, n, "surrogateescape");
if (decoded != NULL) {
- n = PyUnicode_AsWideChar((PyUnicodeObject*)decoded,
+ n = PyUnicode_AsWideChar(decoded,
rel_builddir_path, MAXPATHLEN);
Py_DECREF(decoded);
if (n >= 0) {
Modified: python/branches/pep-0384/Objects/funcobject.c
==============================================================================
--- python/branches/pep-0384/Objects/funcobject.c (original)
+++ python/branches/pep-0384/Objects/funcobject.c Sun Oct 24 23:17:11 2010
@@ -628,7 +628,7 @@
}
result = PyEval_EvalCodeEx(
- (PyCodeObject *)PyFunction_GET_CODE(func),
+ PyFunction_GET_CODE(func),
PyFunction_GET_GLOBALS(func), (PyObject *)NULL,
&PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg),
k, nk, d, nd,
Modified: python/branches/pep-0384/Objects/unicodeobject.c
==============================================================================
--- python/branches/pep-0384/Objects/unicodeobject.c (original)
+++ python/branches/pep-0384/Objects/unicodeobject.c Sun Oct 24 23:17:11 2010
@@ -1154,10 +1154,11 @@
return ret;
}
-Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode,
+Py_ssize_t PyUnicode_AsWideChar(PyObject *_unicode,
wchar_t *w,
Py_ssize_t size)
{
+ PyUnicodeObject *unicode = (PyUnicodeObject*)_unicode;
if (unicode == NULL) {
PyErr_BadInternalCall();
return -1;
Modified: python/branches/pep-0384/Python/bltinmodule.c
==============================================================================
--- python/branches/pep-0384/Python/bltinmodule.c (original)
+++ python/branches/pep-0384/Python/bltinmodule.c Sun Oct 24 23:17:11 2010
@@ -722,7 +722,7 @@
"code object passed to eval() may not contain free variables");
return NULL;
}
- return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
+ return PyEval_EvalCode(cmd, globals, locals);
}
cf.cf_flags = PyCF_SOURCE_IS_UTF8;
@@ -798,7 +798,7 @@
"contain free variables");
return NULL;
}
- v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
+ v = PyEval_EvalCode(prog, globals, locals);
}
else {
char *str;
Modified: python/branches/pep-0384/Python/import.c
==============================================================================
--- python/branches/pep-0384/Python/import.c (original)
+++ python/branches/pep-0384/Python/import.c Sun Oct 24 23:17:11 2010
@@ -769,7 +769,7 @@
PyErr_Clear(); /* Not important enough to report */
Py_DECREF(v);
- v = PyEval_EvalCode((PyCodeObject *)co, d, d);
+ v = PyEval_EvalCode(co, d, d);
if (v == NULL)
goto error;
Py_DECREF(v);
Modified: python/branches/pep-0384/Python/pythonrun.c
==============================================================================
--- python/branches/pep-0384/Python/pythonrun.c (original)
+++ python/branches/pep-0384/Python/pythonrun.c Sun Oct 24 23:17:11 2010
@@ -1765,7 +1765,7 @@
co = PyAST_Compile(mod, filename, flags, arena);
if (co == NULL)
return NULL;
- v = PyEval_EvalCode(co, globals, locals);
+ v = PyEval_EvalCode((PyObject*)co, globals, locals);
Py_DECREF(co);
return v;
}
@@ -1795,7 +1795,7 @@
return NULL;
}
co = (PyCodeObject *)v;
- v = PyEval_EvalCode(co, globals, locals);
+ v = PyEval_EvalCode((PyObject*)co, globals, locals);
if (v && flags)
flags->cf_flags |= (co->co_flags & PyCF_MASK);
Py_DECREF(co);
More information about the Python-checkins
mailing list