diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-03 13:12:59 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-03 13:12:59 (GMT) |
commit | d505cab5b3c9074aa678a33f03f97623d3e5fd28 (patch) | |
tree | 4bdcb429d2418bddf2627eade3da5ab8572a3252 /Mac/Modules | |
parent | f00899866888408106fea4147a9d2cdc2f1e8dbc (diff) | |
download | cpython-d505cab5b3c9074aa678a33f03f97623d3e5fd28.zip cpython-d505cab5b3c9074aa678a33f03f97623d3e5fd28.tar.gz cpython-d505cab5b3c9074aa678a33f03f97623d3e5fd28.tar.bz2 |
Accept only the system default encoding when converting Python
strings to CF strings. Fixes 682215.
Diffstat (limited to 'Mac/Modules')
-rw-r--r-- | Mac/Modules/cf/_CFmodule.c | 8 | ||||
-rw-r--r-- | Mac/Modules/cf/cfsupport.py | 6 | ||||
-rw-r--r-- | Mac/Modules/cf/pycfbridge.c | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index 4f5d935..8473eb5 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -14,9 +14,9 @@ /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ - PyErr_SetString(PyExc_NotImplementedError, \ - "Not available in this shared library/OS version"); \ - return NULL; \ + PyErr_SetString(PyExc_NotImplementedError, \ + "Not available in this shared library/OS version"); \ + return NULL; \ }} while(0) @@ -1458,7 +1458,7 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) if (v == Py_None) { *p_itself = NULL; return 1; } if (PyString_Check(v)) { char *cStr = PyString_AsString(v); - *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0); + *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); return 1; } if (PyUnicode_Check(v)) { diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index 973c4d4..bb0ac40 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -359,8 +359,10 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition): Out(""" if (v == Py_None) { *p_itself = NULL; return 1; } if (PyString_Check(v)) { - char *cStr = PyString_AsString(v); - *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0); + char *cStr; + if (!PyArg_Parse(v, "et", "ascii", &cStr)) + return NULL; + *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); return 1; } if (PyUnicode_Check(v)) { diff --git a/Mac/Modules/cf/pycfbridge.c b/Mac/Modules/cf/pycfbridge.c index 00efa72..d4466ac 100644 --- a/Mac/Modules/cf/pycfbridge.c +++ b/Mac/Modules/cf/pycfbridge.c @@ -292,8 +292,9 @@ PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) { UniChar *unichars; if (PyString_Check(src)) { - if ((chars = PyString_AsString(src)) == NULL ) goto err; - *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, 0); + if (!PyArg_Parse(src, "es", NULL, &chars)) + return NULL; /* This error is more descriptive than the general one below */ + *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII); return 1; } if (PyUnicode_Check(src)) { |