[Patches] [ python-Patches-1214889 ] file.encoding support for file.write and file.writelines

SourceForge.net noreply at sourceforge.net
Sun Jun 5 14:17:03 CEST 2005


Patches item #1214889, was opened at 2005-06-04 19:45
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1214889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Reinhold Birkenfeld (birkenfeld)
Assigned to: Nobody/Anonymous (nobody)
Summary: file.encoding support for file.write and file.writelines

Initial Comment:
Here is a patch that allows Unicode strings written to
a file being automatically encoded. It enables Python
code to set file.encoding and obeys this encoding when
writing Unicode strings with write() or writelines().

It is my first core hackery, so forgive me one leaked
ref or the other. I hope I got the error handling
right; it is kind of confusing...

(btw: Bug #967986 will be fixed with this)

----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-05 14:17

Message:
Logged In: YES 
user_id=1188172

Thanks! Corrected in patch #4.

----------------------------------------------------------------------

Comment By: George Yoshida (quiver)
Date: 2005-06-05 14:09

Message:
Logged In: YES 
user_id=671362

Reinhold, libstdtypes.tex needs two fixes.

 \versionadded{2.3}
+\versionchanged[The encoding attribute is now writable and 
is used
+for encoding Unicode strings given to \method{write()} and 
+\method{writelines()}.]{
                      ~~~
First, versionchanged tag does not have a trailing brace and it 
resuls in compile error.

Second(really trivial), versionchanged macro automatically 
appends a period at the end of the sentence(see the link [*]), 
so you don't need to put it by hand.

Then the above line would become:

+\method{writelines()}]{2.5}

[*]: http://docs.python.org/doc/inline-markup.html


----------------------------------------------------------------------

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-05 09:56

Message:
Logged In: YES 
user_id=1188172

Third revision; adds new documentation and allows Python
code to set the encoding to Py_None.

----------------------------------------------------------------------

Comment By: Hye-Shik Chang (perky)
Date: 2005-06-05 04:26

Message:
Logged In: YES 
user_id=55188

The idea looks good to me.
I attached a revised patch fixed code style, C99-style local
variable declaration and added a regrtest.
I think some documentation update will be needed also.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1214889&group_id=5470


More information about the Patches mailing list