소스 검색

add Sys.print/ln with UTF8 printing and use it from Log.trace

Simon Krajewski 11 년 전
부모
커밋
2abffabbb0
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      std/haxe/Log.hx
  2. 8 0
      std/python/_std/Sys.hx

+ 2 - 2
std/haxe/Log.hx

@@ -98,14 +98,14 @@ class Log {
 			var str:String = null;
 			if (infos != null) {
 				str = infos.fileName + ":" + Std.string(infos.lineNumber) + ": " + v;
-				if (python.lib.Builtin.hasattr(infos, "customParams"))
+				if (python.lib.Builtin.hasattr(infos, "customParams") && infos.customParams != null)
 				{
 					str += "," + infos.customParams.join(",");
 				}
 			} else {
 				str = v;
 			}
-			untyped __python__('print(str)');
+			Sys.println(str);
 		#end
 	}
 

+ 8 - 0
std/python/_std/Sys.hx

@@ -10,4 +10,12 @@ class Sys {
 	public static function exit(code:Int) {
 		python.lib.Sys.exit(code);
 	}
+	
+	public static function print(str:String) {
+		untyped __python__('sys.stdout.buffer.write(("%s"%str).encode(\'utf-8\'))');
+	}
+	
+	public static function println(str:String) {
+		untyped __python__('sys.stdout.buffer.write(("%s\\n"%str).encode(\'utf-8\'))');
+	}
 }