diff options
author | Gianluca Montecchi <gian@grys.it> | 2009-10-02 23:46:24 +0200 |
---|---|---|
committer | Gianluca Montecchi <gian@grys.it> | 2009-10-02 23:46:24 +0200 |
commit | b0b3c9473e3a4b728ea72a2876e39fe41284a9ed (patch) | |
tree | 533a389e877b4b1a9c4099bb419eb221b2f12ada /libbe/editor.py | |
parent | 071fef7c351c4fc23696aa6db693411b78da2edb (diff) | |
download | bugseverywhere-b0b3c9473e3a4b728ea72a2876e39fe41284a9ed.tar.gz |
Merged with Trevor's -rr branch
Diffstat (limited to 'libbe/editor.py')
-rw-r--r-- | libbe/editor.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libbe/editor.py b/libbe/editor.py index 93144b8..ec41006 100644 --- a/libbe/editor.py +++ b/libbe/editor.py @@ -15,6 +15,11 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" +Define editor_string(), a function that invokes an editor to accept +user-produced text as a string. +""" + import codecs import locale import os @@ -22,6 +27,7 @@ import sys import tempfile import doctest + default_encoding = sys.getfilesystemencoding() or locale.getpreferredencoding() comment_marker = u"== Anything below this line will be ignored\n" @@ -62,7 +68,8 @@ def editor_string(comment=None, encoding=None): fhandle, fname = tempfile.mkstemp() try: if comment is not None: - os.write(fhandle, '\n'+comment_string(comment)) + cstring = u'\n'+comment_string(comment) + os.write(fhandle, cstring.encode(encoding)) os.close(fhandle) oldmtime = os.path.getmtime(fname) os.system("%s %s" % (editor, fname)) |