From c5434ecd1d9215e7e1dc885f61172d6b78e6d1b5 Mon Sep 17 00:00:00 2001 From: dodo Date: Tue, 14 Feb 2017 14:13:55 +0100 Subject: [PATCH] 0.2.2 : fixed str->Pystr and not Pybytes --- _oasis | 2 +- myocamlbuild.ml | 9 +++------ setup.ml | 24 +++++++++++------------- srcs/META | 4 ++-- srcs/lymp.ml | 2 +- srcs/lymp.py | 11 +++++++---- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/_oasis b/_oasis index 6ef8fa0..e1e1df8 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.3 Name: lymp -Version: 0.2.1 +Version: 0.2.2 Synopsis: Use Python functions and objects from OCaml Authors: Dominik Bousquet License: MIT diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 67a1b9f..2ca3222 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: c02d186aa90742a3a64fb550dc83c43c) *) +(* DO NOT EDIT (digest: 67d8be4d2a457d862735fddf9d745e61) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -746,9 +746,6 @@ module MyOCamlbuildBase = struct (* # 110 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) - let env_filename = Pathname.basename BaseEnvLight.default_filename - - let dispatch_combine lst = fun e -> List.iter @@ -881,7 +878,7 @@ module MyOCamlbuildBase = struct end -# 884 "myocamlbuild.ml" +# 881 "myocamlbuild.ml" open Ocamlbuild_plugin;; let package_default = { @@ -896,6 +893,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false} let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;; -# 900 "myocamlbuild.ml" +# 897 "myocamlbuild.ml" (* OASIS_STOP *) Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/setup.ml b/setup.ml index 0c78151..c1ad1ad 100644 --- a/setup.ml +++ b/setup.ml @@ -1,9 +1,9 @@ (* setup.ml generated for the first time by OASIS v0.4.7 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 3040b69b28b4e2c418d50938ddb1ddba) *) +(* DO NOT EDIT (digest: 927f2b8050520ed68536832beac9e0bf) *) (* - Regenerated by OASIS v0.4.8 + Regenerated by OASIS v0.4.7 Visit http://oasis.forge.ocamlcore.org for more information and documentation about functions used in this file. *) @@ -658,7 +658,6 @@ module OASISContext = struct ignore_unknown_fields: bool; printf: level -> string -> unit; srcfs: source OASISFileSystem.fs; - load_oasis_plugin: string -> bool; } @@ -683,7 +682,6 @@ module OASISContext = struct ignore_unknown_fields = false; printf = printf; srcfs = new OASISFileSystem.host_fs(Sys.getcwd ()); - load_oasis_plugin = (fun _ -> false); } @@ -3162,7 +3160,7 @@ module OASISFileUtil = struct end -# 3165 "setup.ml" +# 3163 "setup.ml" module BaseEnvLight = struct (* # 22 "src/base/BaseEnvLight.ml" *) @@ -3242,7 +3240,7 @@ module BaseEnvLight = struct end -# 3245 "setup.ml" +# 3243 "setup.ml" module BaseContext = struct (* # 22 "src/base/BaseContext.ml" *) @@ -5665,7 +5663,7 @@ module BaseCompat = struct end -# 5668 "setup.ml" +# 5666 "setup.ml" module InternalConfigurePlugin = struct (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *) @@ -6471,7 +6469,7 @@ module InternalInstallPlugin = struct end -# 6474 "setup.ml" +# 6472 "setup.ml" module OCamlbuildCommon = struct (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *) @@ -6844,7 +6842,7 @@ module OCamlbuildDocPlugin = struct end -# 6847 "setup.ml" +# 6845 "setup.ml" open OASISTypes;; let setup_t = @@ -6865,7 +6863,7 @@ let setup_t = { oasis_version = "0.3"; ocaml_version = None; - version = "0.2.1"; + version = "0.2.2"; license = OASISLicense.DEP5License (OASISLicense.DEP5Unit @@ -7078,8 +7076,8 @@ let setup_t = plugin_data = [] }; oasis_fn = Some "_oasis"; - oasis_version = "0.4.8"; - oasis_digest = Some "\183\209\b\218\214D\187\250\149~j=\006\148\243R"; + oasis_version = "0.4.7"; + oasis_digest = Some "\206\169LEMb\021\197\247\204y7\171z\025\252"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -7087,7 +7085,7 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7091 "setup.ml" +# 7089 "setup.ml" let setup_t = BaseCompat.Compat_0_3.adapt_setup_t setup_t open BaseCompat.Compat_0_3 (* OASIS_STOP *) diff --git a/srcs/META b/srcs/META index fa17ae8..0a50419 100644 --- a/srcs/META +++ b/srcs/META @@ -1,6 +1,6 @@ # OASIS_START -# DO NOT EDIT (digest: 2038362c7c546da70db0f48e752a04ac) -version = "0.2.1" +# DO NOT EDIT (digest: 931b1bc95e7203f20003ff83e3a48a3e) +version = "0.2.2" description = "Use Python functions and objects from OCaml" requires = "bson unix threads" archive(byte) = "lymp.cma" diff --git a/srcs/lymp.ml b/srcs/lymp.ml index f3345bd..03e8139 100644 --- a/srcs/lymp.ml +++ b/srcs/lymp.ml @@ -178,7 +178,7 @@ and deserialize py doc = | "l" -> Pylist (deserialize_list py (Bson.get_list element)) | "f" -> Pyfloat (Bson.get_double element) | "b" -> Pybool (Bson.get_boolean element) - | "B" -> Pybytes (Bson.get_user_binary element) + | "B" -> Pybytes (Bson.get_generic_binary element) | "r" -> let r = {py = py ; ref_nb = int_of_string (Bson.get_jscode element) ; released = false} in Gc.finalise release_reference r ; Pyref (Pyreference r) diff --git a/srcs/lymp.py b/srcs/lymp.py index af1dda3..2f24891 100644 --- a/srcs/lymp.py +++ b/srcs/lymp.py @@ -12,6 +12,8 @@ def int_to_int64_bytes(i): def py_to_bson(val): if type(val) is int: return bson.int64.Int64(val) + if sys.version_info.major == 2 and type(val) is str: + return bson.binary.Binary(val) return val def exit_lymp(): @@ -63,9 +65,10 @@ class ExecutionHandler: bool: "b", bytes: "B" } - # for python 2, unicode is str + # for python 2, unicode is str and str is bytes if sys.version_info.major == 2: to_ret_types[unicode] = "s" + to_ret_types[str] = "B" def __init__(self, reader_writer): self.reader_writer = reader_writer @@ -94,9 +97,6 @@ def loop(self): def ret_to_msg(self, ret, ret_ref): msg = {} - # if python 2 and type is str, convert to unicode and send as string (assume utf-8) - if sys.version_info.major == 2 and type(ret) is str: - ret = ret.decode('utf-8') # reference (type not supported or explicitely asked to) if ret_ref or (type(ret) not in self.to_ret_types): self.ref_nb += 1 @@ -137,6 +137,9 @@ def resolve_args(self, args): named[str(arg[0])[1:]] = self.resolve_args(arg[1])[0] del args[i] continue + # if bytes + if type(arg) is bson.binary.Binary: + args[i] = bytes(arg) # resolve reference args (using bson jscode) if type(arg) is bson.code.Code: args[i] = self.objs[int(arg)]