[Patches] [Patch #103685] Printing unicode
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 09 Feb 2001 05:45:08 -0800
Patch #103685 has been updated.
Project: python
Category: core (C code)
Status: Open
Submitted by: nobody
Assigned to : lemburg
Summary: Printing unicode
Follow-Ups:
Date: 2001-Feb-09 05:45
By: lemburg
Comment:
I'd rather break some code here and then get this done right once
and for all. I wouldn't want to carry along a special attribute
which needs to be checked before every .write() operation. This
costs performance and adds unnecessary convolution to the file
API. Since Unicode is still very new, I doubt that the impact of
this will cause people too much trouble.
IMHO, the correct way to deal with this is to let the
file object write methods deal with the problem in an application
specific way.
cStringIO.c (and all other file-like objects) should be fixed to
use the s# parser markers instead of requiring a real string
object. This will also enhance interoperability with other data storage
types.
-------------------------------------------------------
Date: 2001-Feb-09 04:54
By: nobody
Comment:
waaah - without https I cant upload a new version of the patch.
The original patch fails to clear the exception if
getattr('__str__before_write__') fails... that inner part of
PyFile_WriteObject needs to be:
stringize = PyObject_GetAttrString(f, "__str_before_write__");
if(!stringize) PyErr_Clear();
if(!stringize || PyObject_IsTrue(stringize))
value = PyObject_Str(v);
else {
Py_INCREF(v);
value = v;
}
my appologies for the extra trouble.
-------------------------------------------------------
Date: 2001-Feb-09 04:02
By: nobody
Comment:
I hadnt seen that original discussion, and cant find it in the archives now
:-(
However, your summary matches exactly what this patch achieves for files
have __str_before_write__=0
I think we have to require this extra flag to enable the new behaviour. For
example, this prevents breakage of old code that prints to a StringIO
instance.
(Toby Dickenson, tdickenson@geminidataloggers.com)
-------------------------------------------------------
Date: 2001-Feb-08 08:02
By: lemburg
Comment:
I don't remember the details, but there was a discussion about this
problem on python-dev. The outcome was to let Unicode objects
pass through as-is to the file object and then have it apply
whatever conversion it takes.
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=103685&group_id=5470