Chinaunix首页 | 论坛 | 博客
  • 博客访问: 658156
  • 博文数量: 102
  • 博客积分: 2241
  • 博客等级: 大尉
  • 技术积分: 1670
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-08 10:08
文章分类

全部博文(102)

文章存档

2013年(6)

2012年(15)

2011年(81)

分类: Python/Ruby

2011-09-30 21:45:24

 pycrust1.zip   
pycrust 有自动补全功能,调试 python 代码片段很方便;

不过在调试django数据模型时, 查出来的数据都是unicode的,编码是utf-8,在WIN 下默认使用ascii时, 显示会不正常

去年就遇过的问题一直没人回答,自己又去看了下源码,发现在 Shell 和 Filling 两个stc控件 set 和 append text 时没有转码

打这个补丁就解决问题了


  1. diff -Nuar 1/filling.py 2/filling.py
  2. --- 1/filling.py    Sun Sep 25 16:56:54 2011
  3. +++ 2/filling.py    Sun Sep 25 18:39:52 2011
  4. @@ -16,7 +16,6 @@
  5.  import types
  6.  from version import VERSION
  7.  
  8. -
  9.  COMMONTYPES = [getattr(types, t) for t in dir(types) \
  10.                 if not t.startswith('_') \
  11.                 and t not in ('ClassType', 'InstanceType', 'ModuleType')]
  12. @@ -179,6 +178,10 @@
  13.              value = ''
  14.          if otype is types.StringType or otype is types.UnicodeType:
  15.              value = repr(obj)
  16. + try:
  17. + value = unicode(value)
  18. + except:
  19. + value = unicode(value, 'utf-8', errors='replace')
  20.          text += '\n\nValue: ' + value
  21.          if otype not in SIMPLETYPES:
  22.              try:
  23. diff -Nuar 1/shell.py 2/shell.py
  24. --- 1/shell.py    Sun Sep 25 16:57:02 2011
  25. +++ 2/shell.py    Sun Sep 25 18:39:42 2011
  26. @@ -1239,6 +1239,11 @@
  27.  
  28.      def writeOut(self, text):
  29.          """Replacement for stdout."""
  30. + if type(text) == type(''):
  31. + try:
  32. + text = unicode(text)
  33. + except:
  34. + text = unicode(text, 'utf-8', errors='replace')
  35.          self.write(text)
  36.  
  37.      def writeErr(self, text):

end. 
阅读(1923) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~