pycrust1.zip pycrust 有自动补全功能,调试 python 代码片段很方便;
不过在调试django数据模型时, 查出来的数据都是unicode的,编码是utf-8,在WIN 下默认使用ascii时, 显示会不正常
去年就遇过的问题一直没人回答,自己又去看了下源码,发现在 Shell 和 Filling 两个stc控件 set 和 append text 时没有转码
打这个补丁就解决问题了
- diff -Nuar 1/filling.py 2/filling.py
-
--- 1/filling.py Sun Sep 25 16:56:54 2011
-
+++ 2/filling.py Sun Sep 25 18:39:52 2011
-
@@ -16,7 +16,6 @@
-
import types
-
from version import VERSION
-
-
-
-
COMMONTYPES = [getattr(types, t) for t in dir(types) \
-
if not t.startswith('_') \
-
and t not in ('ClassType', 'InstanceType', 'ModuleType')]
-
@@ -179,6 +178,10 @@
-
value = ''
-
if otype is types.StringType or otype is types.UnicodeType:
-
value = repr(obj)
-
+ try:
-
+ value = unicode(value)
-
+ except:
-
+ value = unicode(value, 'utf-8', errors='replace')
-
text += '\n\nValue: ' + value
-
if otype not in SIMPLETYPES:
-
try:
-
diff -Nuar 1/shell.py 2/shell.py
-
--- 1/shell.py Sun Sep 25 16:57:02 2011
-
+++ 2/shell.py Sun Sep 25 18:39:42 2011
-
@@ -1239,6 +1239,11 @@
-
-
def writeOut(self, text):
-
"""Replacement for stdout."""
-
+ if type(text) == type(''):
-
+ try:
-
+ text = unicode(text)
-
+ except:
-
+ text = unicode(text, 'utf-8', errors='replace')
-
self.write(text)
-
-
def writeErr(self, text):
end.
阅读(1966) | 评论(0) | 转发(0) |