This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyUnicode_FromEncodedObject
Type: Stage:
Components: None Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: david_abrahams, georg.brandl
Priority: normal Keywords:

Created on 2003-09-12 11:39 by david_abrahams, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (2)
msg18138 - (view) Author: David Abrahams (david_abrahams) Date: 2003-09-12 11:39
There's a bug, either in the code or docs for
PyUnicode_FromEncodedObject.  The docs read:

  "Unicode objects are passed back as-is with 
incremented
  refcount. Note: These cannot be decoded; passing a 
non-NULL value
  for encoding will result in a TypeError."


'tain't so; the following shows that the error is 
unconditional.



    if (obj == NULL) {
	PyErr_BadInternalCall();
	return NULL;
    }

#if 0
    /* For b/w compatibility we also accept Unicode 
objects provided
       that no encodings is given and then redirect to
       PyObject_Unicode() which then applies the 
additional logic for
       Unicode subclasses.

       NOTE: This API should really only be used for 
object which
             represent *encoded* Unicode !

    */
	if (PyUnicode_Check(obj)) {
	    if (encoding) {
		PyErr_SetString(PyExc_TypeError,
				"decoding Unicode 
is not supported");
	    return NULL;
	    }
	return PyObject_Unicode(obj);
	    }
#else
    if (PyUnicode_Check(obj)) {
	PyErr_SetString(PyExc_TypeError,
			"decoding Unicode is not 
supported");
	return NULL;
	}
#endif
msg18139 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-14 16:46
Logged In: YES 
user_id=849994

Fixed in rev. 46961.
History
Date User Action Args
2022-04-10 16:11:07adminsetgithub: 39219
2003-09-12 11:39:32david_abrahamscreate