2
0
Эх сурвалжийг харах

compatibility fix for latest cython version, inspect.isfunction behaviour is different

frabbit 10 жил өмнө
parent
commit
dda4aa4b0d

+ 4 - 1
genpy.ml

@@ -2138,7 +2138,10 @@ module Generator = struct
 					","
 				in
 				let k_enc = Base64.str_encode k in
-				print ctx "%s\"%s\": open('%%s.%%s'%%(__file__,'%s'),'rb').read()" prefix (Ast.s_escape k) k_enc;
+				let slash_index = try (String.rindex ctx.com.file '/')+1 with Not_found -> 0 in
+				let len = String.length ctx.com.file - slash_index in
+				let file_name = String.sub ctx.com.file slash_index len in
+				print ctx "%s\"%s\": open('%%s.%%s'%%('%s','%s'),'rb').read()" prefix (Ast.s_escape k) file_name k_enc;
 				Std.output_file (ctx.com.file ^ "." ^ k_enc) v
 			) ctx.com.resources;
 			spr ctx "}"

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

@@ -82,7 +82,7 @@ class Reflect {
 
 	public static function isFunction( f : Dynamic ) : Bool
 	{
-		return Inspect.isfunction(f) || Inspect.ismethod(f);
+		return Inspect.isfunction(f) || Inspect.ismethod(f) || Builtin.hasattr(f, "func_code");
 	}
 
 	public static function compare<T>( a : T, b : T ) : Int {