Переглянути джерело

quick fix for print/println

frabbit 11 роки тому
батько
коміт
7e00e1f341
2 змінених файлів з 5 додано та 16 видалено
  1. 4 15
      std/python/Lib.hx
  2. 1 1
      std/python/_std/Sys.hx

+ 4 - 15
std/python/Lib.hx

@@ -50,30 +50,19 @@ class HaxeIterator<T>
 
   }
 }
-
+@:preCode("import sys as _hx_sys")
 class Lib
 {
-	/*
-    public static inline function assert(value:Dynamic)
-    {
-        untyped __assert__(value);
-    }
-
-    public static function random(max:Int)
-    {
-       var r = new dart.math.Random(); //TODO(av) benchmark / test caching Random instance as static
-       return r.nextInt(max);
-    }
-    */
 
   public static function print(v:Dynamic):Void {
     var str = Std.string(v);
-    untyped __python__('sys.stdout.buffer.write(("%s"%str).encode(\'utf-8\'))');
+
+    untyped __python__('_hx_sys.stdout.buffer.write(("%s"%str).encode(\'utf-8\'))');
   }
 
   public static function println(v:Dynamic):Void {
     var str = Std.string(v);
-    untyped __python__('sys.stdout.buffer.write(("%s\\n"%str).encode(\'utf-8\'))');
+    untyped __python__('_hx_sys.stdout.buffer.write(("%s\\n"%str).encode(\'utf-8\'))');
   }
 
     public static function toPythonIterable <T>(it:Iterable<T>):python.lib.Types.NativeIterable<T>

+ 1 - 1
std/python/_std/Sys.hx

@@ -1,6 +1,6 @@
 import python.lib.Time;
 
-@:preCode("import sys")
+
 @:coreApi
 class Sys {