From 3e43e99fc796fe1730dcb0fa47f6bd0b8d8e9a0a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 09:44:09 +0100 Subject: [PATCH 1/9] Bump versions --- Cargo.lock | 209 ++++++++++++++++++++++++++---------------------- rust/Cargo.toml | 6 +- 2 files changed, 118 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24127c6540f..59d43ece2d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,30 +4,30 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "arc-swap" -version = "1.5.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" @@ -37,9 +37,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake2" @@ -52,9 +52,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -115,9 +115,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -125,9 +125,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -191,15 +191,15 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" @@ -218,15 +218,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -240,15 +240,15 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.6.3" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -261,15 +261,15 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "once_cell" -version = "1.15.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -277,15 +277,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-targets", ] [[package]] @@ -302,18 +302,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ "anyhow", "cfg-if", @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" dependencies = [ "once_cell", "target-lexicon", @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" dependencies = [ "libc", "pyo3-build-config", @@ -350,9 +350,9 @@ dependencies = [ [[package]] name = "pyo3-log" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c10808ee7250403bedb24bc30c32493e93875fef7ba3e4292226fe924f398bd" +checksum = "2af49834b8d2ecd555177e63b273b708dea75150abc6f5341d0a6e1a9623976c" dependencies = [ "arc-swap", "log", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -373,9 +373,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" dependencies = [ "heck", "proc-macro2", @@ -386,9 +386,9 @@ dependencies = [ [[package]] name = "pythonize" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffd1c3ef39c725d63db5f9bc455461bafd80540cb7824c61afb823501921a850" +checksum = "9d0664248812c38cc55a4ed07f88e4df516ce82604b93b1ffdc041aa77a6cb3c" dependencies = [ "pyo3", "serde", @@ -396,9 +396,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ "bitflags", ] @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -467,36 +467,36 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -516,9 +516,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -538,21 +538,21 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", @@ -585,15 +585,15 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.4" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "typenum" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ulid" @@ -608,9 +608,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unindent" @@ -695,44 +695,65 @@ dependencies = [ ] [[package]] -name = "windows-sys" -version = "0.36.1" +name = "windows-targets" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ + "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", + "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d41a216d1cc..026487275c4 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -30,14 +30,14 @@ http = "1.1.0" lazy_static = "1.4.0" log = "0.4.17" mime = "0.3.17" -pyo3 = { version = "0.20.0", features = [ +pyo3 = { version = "0.21.0", features = [ "macros", "anyhow", "abi3", "abi3-py38", ] } -pyo3-log = "0.9.0" -pythonize = "0.20.0" +pyo3-log = "0.10.0" +pythonize = "0.21.0" regex = "1.6.0" sha2 = "0.10.8" serde = { version = "1.0.144", features = ["derive"] } From 3436178254472fd33e55a3ad0250b0784b90cea0 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 09:46:57 +0100 Subject: [PATCH 2/9] Fix errors --- rust/Cargo.toml | 1 + rust/src/events/internal_metadata.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 026487275c4..41c7e6ed644 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,6 +35,7 @@ pyo3 = { version = "0.21.0", features = [ "anyhow", "abi3", "abi3-py38", + "gil-refs", ] } pyo3-log = "0.10.0" pythonize = "0.21.0" diff --git a/rust/src/events/internal_metadata.rs b/rust/src/events/internal_metadata.rs index 53c7b1ba610..8d82e46ace9 100644 --- a/rust/src/events/internal_metadata.rs +++ b/rust/src/events/internal_metadata.rs @@ -40,7 +40,7 @@ use pyo3::{ exceptions::PyAttributeError, pyclass, pymethods, types::{PyDict, PyString}, - IntoPy, PyAny, PyObject, PyResult, Python, + Bound, IntoPy, PyAny, PyObject, PyResult, Python, }; /// Definitions of the various fields of the internal metadata. @@ -59,7 +59,7 @@ enum EventInternalMetadataData { impl EventInternalMetadataData { /// Convert the field to its name and python object. - fn to_python_pair<'a>(&self, py: Python<'a>) -> (&'a PyString, PyObject) { + fn to_python_pair<'a>(&self, py: Python<'a>) -> (&'a Bound<'a, PyString>, PyObject) { match self { EventInternalMetadataData::OutOfBandMembership(o) => { (pyo3::intern!(py, "out_of_band_membership"), o.into_py(py)) From 37ada5d4646e3bdb936c5adf3216d490b1dd521b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 09:52:56 +0100 Subject: [PATCH 3/9] Fix some warnings --- rust/src/push/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/src/push/mod.rs b/rust/src/push/mod.rs index 7dedbf10b6a..8dc50cef6d2 100644 --- a/rust/src/push/mod.rs +++ b/rust/src/push/mod.rs @@ -271,12 +271,12 @@ pub enum SimpleJsonValue { impl<'source> FromPyObject<'source> for SimpleJsonValue { fn extract(ob: &'source PyAny) -> PyResult { - if let Ok(s) = ::try_from(ob) { + if let Ok(s) = ob.downcast::() { Ok(SimpleJsonValue::Str(Cow::Owned(s.to_string()))) // A bool *is* an int, ensure we try bool first. - } else if let Ok(b) = ::try_from(ob) { + } else if let Ok(b) = ob.downcast::() { Ok(SimpleJsonValue::Bool(b.extract()?)) - } else if let Ok(i) = ::try_from(ob) { + } else if let Ok(i) = ob.downcast::() { Ok(SimpleJsonValue::Int(i.extract()?)) } else if ob.is_none() { Ok(SimpleJsonValue::Null) @@ -299,7 +299,7 @@ pub enum JsonValue { impl<'source> FromPyObject<'source> for JsonValue { fn extract(ob: &'source PyAny) -> PyResult { - if let Ok(l) = ::try_from(ob) { + if let Ok(l) = ob.downcast::() { match l.iter().map(SimpleJsonValue::extract).collect() { Ok(a) => Ok(JsonValue::Array(a)), Err(e) => Err(PyTypeError::new_err(format!( From 5a5642ca6fbaace0b00e9413565c018dffe61490 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:00:29 +0100 Subject: [PATCH 4/9] Remove migration feature --- rust/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 41c7e6ed644..026487275c4 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,7 +35,6 @@ pyo3 = { version = "0.21.0", features = [ "anyhow", "abi3", "abi3-py38", - "gil-refs", ] } pyo3-log = "0.10.0" pythonize = "0.21.0" From 07aab5c1d67447eebac9011a54fd40319bf182d4 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:00:34 +0100 Subject: [PATCH 5/9] Fix errors --- rust/src/acl/mod.rs | 6 +++--- rust/src/events/internal_metadata.rs | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rust/src/acl/mod.rs b/rust/src/acl/mod.rs index 286574fb498..2958cbf67e4 100644 --- a/rust/src/acl/mod.rs +++ b/rust/src/acl/mod.rs @@ -25,7 +25,7 @@ use std::net::Ipv4Addr; use std::str::FromStr; use anyhow::Error; -use pyo3::prelude::*; +use pyo3::{prelude::*, pybacked::PyBackedStr}; use regex::Regex; use crate::push::utils::{glob_to_regex, GlobMatchType}; @@ -59,8 +59,8 @@ impl ServerAclEvaluator { #[new] pub fn py_new( allow_ip_literals: bool, - allow: Vec<&str>, - deny: Vec<&str>, + allow: Vec, + deny: Vec, ) -> Result { let allow = allow .iter() diff --git a/rust/src/events/internal_metadata.rs b/rust/src/events/internal_metadata.rs index 8d82e46ace9..3e8bfcbdda5 100644 --- a/rust/src/events/internal_metadata.rs +++ b/rust/src/events/internal_metadata.rs @@ -38,6 +38,7 @@ use anyhow::Context; use log::warn; use pyo3::{ exceptions::PyAttributeError, + pybacked::PyBackedStr, pyclass, pymethods, types::{PyDict, PyString}, Bound, IntoPy, PyAny, PyObject, PyResult, Python, @@ -91,9 +92,9 @@ impl EventInternalMetadataData { /// /// Returns `None` if the key is a valid but unrecognized string. fn from_python_pair(key: &PyAny, value: &PyAny) -> PyResult> { - let key_str: &str = key.extract()?; + let key_str: PyBackedStr = key.extract()?; - let e = match key_str { + let e = match &*key_str { "out_of_band_membership" => EventInternalMetadataData::OutOfBandMembership( value .extract() From 123e4a26b0bed47012ea65db11785a9be036cd1b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:18:48 +0100 Subject: [PATCH 6/9] Convert to use Bound<> --- rust/src/events/internal_metadata.rs | 11 +++++---- rust/src/http.rs | 35 +++++++++++++++++----------- rust/src/push/mod.rs | 6 ++--- rust/src/rendezvous/mod.rs | 26 +++++++++++++++------ 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/rust/src/events/internal_metadata.rs b/rust/src/events/internal_metadata.rs index 3e8bfcbdda5..1dd4770bfe8 100644 --- a/rust/src/events/internal_metadata.rs +++ b/rust/src/events/internal_metadata.rs @@ -40,7 +40,7 @@ use pyo3::{ exceptions::PyAttributeError, pybacked::PyBackedStr, pyclass, pymethods, - types::{PyDict, PyString}, + types::{PyAnyMethods, PyDict, PyDictMethods, PyString}, Bound, IntoPy, PyAny, PyObject, PyResult, Python, }; @@ -91,7 +91,10 @@ impl EventInternalMetadataData { /// Converts from python key/values to the field. /// /// Returns `None` if the key is a valid but unrecognized string. - fn from_python_pair(key: &PyAny, value: &PyAny) -> PyResult> { + fn from_python_pair( + key: &Bound<'_, PyAny>, + value: &Bound<'_, PyAny>, + ) -> PyResult> { let key_str: PyBackedStr = key.extract()?; let e = match &*key_str { @@ -211,11 +214,11 @@ pub struct EventInternalMetadata { #[pymethods] impl EventInternalMetadata { #[new] - fn new(dict: &PyDict) -> PyResult { + fn new(dict: &Bound<'_, PyDict>) -> PyResult { let mut data = Vec::with_capacity(dict.len()); for (key, value) in dict.iter() { - match EventInternalMetadataData::from_python_pair(key, value) { + match EventInternalMetadataData::from_python_pair(&key, &value) { Ok(Some(entry)) => data.push(entry), Ok(None) => {} Err(err) => { diff --git a/rust/src/http.rs b/rust/src/http.rs index 74098f4c8ba..af052ab7214 100644 --- a/rust/src/http.rs +++ b/rust/src/http.rs @@ -17,8 +17,8 @@ use headers::{Header, HeaderMapExt}; use http::{HeaderName, HeaderValue, Method, Request, Response, StatusCode, Uri}; use pyo3::{ exceptions::PyValueError, - types::{PyBytes, PySequence, PyTuple}, - PyAny, PyResult, + types::{PyAnyMethods, PyBytes, PyBytesMethods, PySequence, PyTuple}, + Bound, PyAny, PyResult, }; use crate::errors::SynapseError; @@ -28,10 +28,11 @@ use crate::errors::SynapseError; /// # Errors /// /// Returns an error if calling the `read` on the Python object failed -fn read_io_body(body: &PyAny, chunk_size: usize) -> PyResult { +fn read_io_body(body: &Bound<'_, PyAny>, chunk_size: usize) -> PyResult { let mut buf = BytesMut::new(); loop { - let bytes: &PyBytes = body.call_method1("read", (chunk_size,))?.downcast()?; + let bound = &body.call_method1("read", (chunk_size,))?; + let bytes: &Bound<'_, PyBytes> = bound.downcast()?; if bytes.as_bytes().is_empty() { return Ok(buf.into()); } @@ -50,17 +51,19 @@ fn read_io_body(body: &PyAny, chunk_size: usize) -> PyResult { /// # Errors /// /// Returns an error if the Python object doesn't properly implement `IRequest` -pub fn http_request_from_twisted(request: &PyAny) -> PyResult> { +pub fn http_request_from_twisted(request: &Bound<'_, PyAny>) -> PyResult> { let content = request.getattr("content")?; - let body = read_io_body(content, 4096)?; + let body = read_io_body(&content, 4096)?; let mut req = Request::new(body); - let uri: &PyBytes = request.getattr("uri")?.downcast()?; + let bound = &request.getattr("uri")?; + let uri: &Bound<'_, PyBytes> = bound.downcast()?; *req.uri_mut() = Uri::try_from(uri.as_bytes()).map_err(|_| PyValueError::new_err("invalid uri"))?; - let method: &PyBytes = request.getattr("method")?.downcast()?; + let bound = &request.getattr("method")?; + let method: &Bound<'_, PyBytes> = bound.downcast()?; *req.method_mut() = Method::from_bytes(method.as_bytes()) .map_err(|_| PyValueError::new_err("invalid method"))?; @@ -71,14 +74,17 @@ pub fn http_request_from_twisted(request: &PyAny) -> PyResult> { for header in headers_iter { let header = header?; - let header: &PyTuple = header.downcast()?; - let name: &PyBytes = header.get_item(0)?.downcast()?; + let header: &Bound<'_, PyTuple> = header.downcast()?; + let bound = &header.get_item(0)?; + let name: &Bound<'_, PyBytes> = bound.downcast()?; let name = HeaderName::from_bytes(name.as_bytes()) .map_err(|_| PyValueError::new_err("invalid header name"))?; - let values: &PySequence = header.get_item(1)?.downcast()?; + let bound = &header.get_item(1)?; + let values: &Bound<'_, PySequence> = bound.downcast()?; for index in 0..values.len()? { - let value: &PyBytes = values.get_item(index)?.downcast()?; + let bound = &values.get_item(index)?; + let value: &Bound<'_, PyBytes> = bound.downcast()?; let value = HeaderValue::from_bytes(value.as_bytes()) .map_err(|_| PyValueError::new_err("invalid header value"))?; req.headers_mut().append(name.clone(), value); @@ -100,7 +106,10 @@ pub fn http_request_from_twisted(request: &PyAny) -> PyResult> { /// # Errors /// /// Returns an error if the Python object doesn't properly implement `IRequest` -pub fn http_response_to_twisted(request: &PyAny, response: Response) -> PyResult<()> +pub fn http_response_to_twisted( + request: &Bound<'_, PyAny>, + response: Response, +) -> PyResult<()> where B: Buf, { diff --git a/rust/src/push/mod.rs b/rust/src/push/mod.rs index 8dc50cef6d2..953d2334db2 100644 --- a/rust/src/push/mod.rs +++ b/rust/src/push/mod.rs @@ -66,7 +66,7 @@ use log::warn; use pyo3::exceptions::PyTypeError; use pyo3::prelude::*; use pyo3::types::{PyBool, PyList, PyLong, PyString}; -use pythonize::{depythonize, pythonize}; +use pythonize::{depythonize_bound, pythonize}; use serde::de::Error as _; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -370,8 +370,8 @@ impl IntoPy for Condition { } impl<'source> FromPyObject<'source> for Condition { - fn extract(ob: &'source PyAny) -> PyResult { - Ok(depythonize(ob)?) + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { + Ok(depythonize_bound(ob.clone())?) } } diff --git a/rust/src/rendezvous/mod.rs b/rust/src/rendezvous/mod.rs index c0f5d8b6000..a5d017599ed 100644 --- a/rust/src/rendezvous/mod.rs +++ b/rust/src/rendezvous/mod.rs @@ -26,8 +26,10 @@ use headers::{ use http::{header::ETAG, HeaderMap, Response, StatusCode, Uri}; use mime::Mime; use pyo3::{ - exceptions::PyValueError, pyclass, pymethods, types::PyModule, Py, PyAny, PyObject, PyResult, - Python, ToPyObject, + exceptions::PyValueError, + pyclass, pymethods, + types::{PyAnyMethods, PyModule}, + Bound, Py, PyAny, PyObject, PyResult, Python, ToPyObject, }; use ulid::Ulid; @@ -109,7 +111,7 @@ impl RendezvousHandler { #[pyo3(signature = (homeserver, /, capacity=100, max_content_length=4*1024, eviction_interval=60*1000, ttl=60*1000))] fn new( py: Python<'_>, - homeserver: &PyAny, + homeserver: &Bound<'_, PyAny>, capacity: usize, max_content_length: u64, eviction_interval: u64, @@ -158,7 +160,7 @@ impl RendezvousHandler { Ok(()) } - fn handle_post(&mut self, py: Python<'_>, twisted_request: &PyAny) -> PyResult<()> { + fn handle_post(&mut self, py: Python<'_>, twisted_request: &Bound<'_, PyAny>) -> PyResult<()> { let request = http_request_from_twisted(twisted_request)?; let content_type = self.check_input_headers(request.headers())?; @@ -197,7 +199,12 @@ impl RendezvousHandler { Ok(()) } - fn handle_get(&mut self, py: Python<'_>, twisted_request: &PyAny, id: &str) -> PyResult<()> { + fn handle_get( + &mut self, + py: Python<'_>, + twisted_request: &Bound<'_, PyAny>, + id: &str, + ) -> PyResult<()> { let request = http_request_from_twisted(twisted_request)?; let if_none_match: Option = request.headers().typed_get_optional()?; @@ -233,7 +240,12 @@ impl RendezvousHandler { Ok(()) } - fn handle_put(&mut self, py: Python<'_>, twisted_request: &PyAny, id: &str) -> PyResult<()> { + fn handle_put( + &mut self, + py: Python<'_>, + twisted_request: &Bound<'_, PyAny>, + id: &str, + ) -> PyResult<()> { let request = http_request_from_twisted(twisted_request)?; let content_type = self.check_input_headers(request.headers())?; @@ -281,7 +293,7 @@ impl RendezvousHandler { Ok(()) } - fn handle_delete(&mut self, twisted_request: &PyAny, id: &str) -> PyResult<()> { + fn handle_delete(&mut self, twisted_request: &Bound<'_, PyAny>, id: &str) -> PyResult<()> { let _request = http_request_from_twisted(twisted_request)?; let id: Ulid = id.parse().map_err(|_| NotFoundError::new())?; From adb24890dc1f28c06a37eaf33094e415da7c5e65 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:22:44 +0100 Subject: [PATCH 7/9] Convert module definitions to use Bound<> --- rust/src/acl/mod.rs | 8 ++++---- rust/src/events/mod.rs | 13 ++++++++----- rust/src/lib.rs | 2 +- rust/src/push/mod.rs | 8 ++++---- rust/src/rendezvous/mod.rs | 10 +++++----- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/rust/src/acl/mod.rs b/rust/src/acl/mod.rs index 2958cbf67e4..982720ba909 100644 --- a/rust/src/acl/mod.rs +++ b/rust/src/acl/mod.rs @@ -31,15 +31,15 @@ use regex::Regex; use crate::push::utils::{glob_to_regex, GlobMatchType}; /// Called when registering modules with python. -pub fn register_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "acl")?; +pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { + let child_module = PyModule::new_bound(py, "acl")?; child_module.add_class::()?; - m.add_submodule(child_module)?; + m.add_submodule(&child_module)?; // We need to manually add the module to sys.modules to make `from // synapse.synapse_rust import acl` work. - py.import("sys")? + py.import_bound("sys")? .getattr("modules")? .set_item("synapse.synapse_rust.acl", child_module)?; diff --git a/rust/src/events/mod.rs b/rust/src/events/mod.rs index ee857b3d72a..a4ade1a1786 100644 --- a/rust/src/events/mod.rs +++ b/rust/src/events/mod.rs @@ -20,20 +20,23 @@ //! Classes for representing Events. -use pyo3::{types::PyModule, PyResult, Python}; +use pyo3::{ + types::{PyAnyMethods, PyModule, PyModuleMethods}, + Bound, PyResult, Python, +}; mod internal_metadata; /// Called when registering modules with python. -pub fn register_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "events")?; +pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { + let child_module = PyModule::new_bound(py, "events")?; child_module.add_class::()?; - m.add_submodule(child_module)?; + m.add_submodule(&child_module)?; // We need to manually add the module to sys.modules to make `from // synapse.synapse_rust import events` work. - py.import("sys")? + py.import_bound("sys")? .getattr("modules")? .set_item("synapse.synapse_rust.events", child_module)?; diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 9bd1f17ad97..06477880b94 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -38,7 +38,7 @@ fn reset_logging_config() { /// The entry point for defining the Python module. #[pymodule] -fn synapse_rust(py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn synapse_rust(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; m.add_function(wrap_pyfunction!(get_rust_file_digest, m)?)?; m.add_function(wrap_pyfunction!(reset_logging_config, m)?)?; diff --git a/rust/src/push/mod.rs b/rust/src/push/mod.rs index 953d2334db2..2a452b69a3c 100644 --- a/rust/src/push/mod.rs +++ b/rust/src/push/mod.rs @@ -78,19 +78,19 @@ pub mod evaluator; pub mod utils; /// Called when registering modules with python. -pub fn register_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "push")?; +pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { + let child_module = PyModule::new_bound(py, "push")?; child_module.add_class::()?; child_module.add_class::()?; child_module.add_class::()?; child_module.add_class::()?; child_module.add_function(wrap_pyfunction!(get_base_rule_ids, m)?)?; - m.add_submodule(child_module)?; + m.add_submodule(&child_module)?; // We need to manually add the module to sys.modules to make `from // synapse.synapse_rust import push` work. - py.import("sys")? + py.import_bound("sys")? .getattr("modules")? .set_item("synapse.synapse_rust.push", child_module)?; diff --git a/rust/src/rendezvous/mod.rs b/rust/src/rendezvous/mod.rs index a5d017599ed..c352f665cb7 100644 --- a/rust/src/rendezvous/mod.rs +++ b/rust/src/rendezvous/mod.rs @@ -28,7 +28,7 @@ use mime::Mime; use pyo3::{ exceptions::PyValueError, pyclass, pymethods, - types::{PyAnyMethods, PyModule}, + types::{PyAnyMethods, PyModule, PyModuleMethods}, Bound, Py, PyAny, PyObject, PyResult, Python, ToPyObject, }; use ulid::Ulid; @@ -310,16 +310,16 @@ impl RendezvousHandler { } } -pub fn register_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "rendezvous")?; +pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { + let child_module = PyModule::new_bound(py, "rendezvous")?; child_module.add_class::()?; - m.add_submodule(child_module)?; + m.add_submodule(&child_module)?; // We need to manually add the module to sys.modules to make `from // synapse.synapse_rust import rendezvous` work. - py.import("sys")? + py.import_bound("sys")? .getattr("modules")? .set_item("synapse.synapse_rust.rendezvous", child_module)?; From 697e30e1ffc0716ea5d4b4bbc099270d609a6590 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:23:42 +0100 Subject: [PATCH 8/9] Fix the rest of warnings --- rust/src/events/internal_metadata.rs | 2 +- rust/src/rendezvous/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/src/events/internal_metadata.rs b/rust/src/events/internal_metadata.rs index 1dd4770bfe8..63774fbd547 100644 --- a/rust/src/events/internal_metadata.rs +++ b/rust/src/events/internal_metadata.rs @@ -244,7 +244,7 @@ impl EventInternalMetadata { /// /// Note that `outlier` and `stream_ordering` are stored in separate columns so are not returned here. fn get_dict(&self, py: Python<'_>) -> PyResult { - let dict = PyDict::new(py); + let dict = PyDict::new_bound(py); for entry in &self.data { let (key, value) = entry.to_python_pair(py); diff --git a/rust/src/rendezvous/mod.rs b/rust/src/rendezvous/mod.rs index c352f665cb7..f69f45490f0 100644 --- a/rust/src/rendezvous/mod.rs +++ b/rust/src/rendezvous/mod.rs @@ -152,7 +152,7 @@ impl RendezvousHandler { } fn _evict(&mut self, py: Python<'_>) -> PyResult<()> { - let clock = self.clock.as_ref(py); + let clock = self.clock.bind(py); let now: u64 = clock.call_method0("time_msec")?.extract()?; let now = SystemTime::UNIX_EPOCH + Duration::from_millis(now); self.evict(now); @@ -165,7 +165,7 @@ impl RendezvousHandler { let content_type = self.check_input_headers(request.headers())?; - let clock = self.clock.as_ref(py); + let clock = self.clock.bind(py); let now: u64 = clock.call_method0("time_msec")?.extract()?; let now = SystemTime::UNIX_EPOCH + Duration::from_millis(now); From 2db94bc32e210857f29e8468175b9c75ba4660e6 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 7 May 2024 10:25:01 +0100 Subject: [PATCH 9/9] Newsfile --- changelog.d/17162.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17162.misc diff --git a/changelog.d/17162.misc b/changelog.d/17162.misc new file mode 100644 index 00000000000..5cbc086e04c --- /dev/null +++ b/changelog.d/17162.misc @@ -0,0 +1 @@ +Update dependency PyO3 to 0.21.