aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/editor.py
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2009-10-05 23:15:39 -0400
committerChris Ball <cjb@laptop.org>2009-10-05 23:15:39 -0400
commitb6a50c703369467132876f21efa8e4ffc672afae (patch)
tree905a9ae34efa2bce47d754893093b016d18d0162 /libbe/editor.py
parent6a639574fa95e50f82fa3052e5524b961295a7ab (diff)
parente35ccf95ea89b6e622202caae30d3b8cca3f2473 (diff)
downloadbugseverywhere-b6a50c703369467132876f21efa8e4ffc672afae.tar.gz
Large merge from W. Trevor King, including Gianluca's HTML export.
Diffstat (limited to 'libbe/editor.py')
-rw-r--r--libbe/editor.py9
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))