Repository navigation
GH-39942: [Python] Make capsule name check more lenient - #39977
Conversation
|
|
jorisvandenbossche
left a comment
There was a problem hiding this comment.
I am personally fine with not testing it on CI, as long as you verified locally it works (and add a comment in the code why "r_extptr" is also tested)
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
| elif PyCapsule_CheckExact(v): | ||
| c_ptr = PyCapsule_GetPointer(v, NULL) | ||
| capsule_name = PyCapsule_GetName(v) | ||
| if capsule_name == NULL or capsule_name == "r_extptr": |
There was a problem hiding this comment.
Did you check that capsule_name == "r_extptr" works as expected?
There was a problem hiding this comment.
I still need to check!
There was a problem hiding this comment.
| if capsule_name == NULL or capsule_name == "r_extptr": | |
| if capsule_name == NULL or capsule_name == b"r_extptr": |
I suspect it should be compared with bytes when comparing directly (our frombytes helper converts from the bytes to string)
There was a problem hiding this comment.
I wrapped this into another change, but good call! capsule_name == "r_extptr" always returns false but capsule_name == b"r_extptr" seems to do the trick 🤷
| PyCapsule_IsValid | ||
| ) | ||
|
|
||
| from libc.string cimport strcmp |
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
|
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit abf4fbf. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them. |
…#39977) ### Rationale for this change While apache#39969 fixed the immediate issue caused by the update of the capsule name used by reticulate whilst converting an R "external pointer", it will still result in an error if somebody is using an older version of the Arrow R package. ### What changes are included in this PR? The pyarrow Cython code was modified to accept capsules with the name NULL or "r_extptr". ### Are these changes tested? Not sure where the best place for this is, but: CRAN arrow + released pyarrow + new reticulate (errors): ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "15.0.0" reticulate::r_to_py(arrow::int32()) #> PyCapsule_GetPointer called with incorrect name ``` CRAN arrow + pyarrow from this PR + old reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.34.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` CRAN arrow + pyarrow from this PR + new reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` ### Are there any user-facing changes? No * Closes: apache#39942 Lead-authored-by: Dewey Dunnington <dewey@fishandwhistle.net> Co-authored-by: Dewey Dunnington <dewey@voltrondata.com> Co-authored-by: Antoine Pitrou <pitrou@free.fr> Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com> Signed-off-by: Dewey Dunnington <dewey@voltrondata.com>
### Rationale for this change While #39969 fixed the immediate issue caused by the update of the capsule name used by reticulate whilst converting an R "external pointer", it will still result in an error if somebody is using an older version of the Arrow R package. ### What changes are included in this PR? The pyarrow Cython code was modified to accept capsules with the name NULL or "r_extptr". ### Are these changes tested? Not sure where the best place for this is, but: CRAN arrow + released pyarrow + new reticulate (errors): ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "15.0.0" reticulate::r_to_py(arrow::int32()) #> PyCapsule_GetPointer called with incorrect name ``` CRAN arrow + pyarrow from this PR + old reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.34.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` CRAN arrow + pyarrow from this PR + new reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` ### Are there any user-facing changes? No * Closes: #39942 Lead-authored-by: Dewey Dunnington <dewey@fishandwhistle.net> Co-authored-by: Dewey Dunnington <dewey@voltrondata.com> Co-authored-by: Antoine Pitrou <pitrou@free.fr> Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com> Signed-off-by: Dewey Dunnington <dewey@voltrondata.com>
### Rationale for this change While #39969 fixed the immediate issue caused by the update of the capsule name used by reticulate whilst converting an R "external pointer", it will still result in an error if somebody is using an older version of the Arrow R package. ### What changes are included in this PR? The pyarrow Cython code was modified to accept capsules with the name NULL or "r_extptr". ### Are these changes tested? Not sure where the best place for this is, but: CRAN arrow + released pyarrow + new reticulate (errors): ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "15.0.0" reticulate::r_to_py(arrow::int32()) #> PyCapsule_GetPointer called with incorrect name ``` CRAN arrow + pyarrow from this PR + old reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.34.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` CRAN arrow + pyarrow from this PR + new reticulate: ``` r library(arrow, warn.conflicts = FALSE) reticulate::use_virtualenv("~/Desktop/rscratch/arrow/.venv") packageVersion("arrow") #> [1] '14.0.0.2' packageVersion("reticulate") #> [1] '1.35.0' pa <- reticulate::import("pyarrow") pa[["__version__"]] #> [1] "16.0.0.dev92+geafcff7a5" reticulate::r_to_py(arrow::int32()) #> DataType(int32) ``` ### Are there any user-facing changes? No * Closes: #39942 Lead-authored-by: Dewey Dunnington <dewey@fishandwhistle.net> Co-authored-by: Dewey Dunnington <dewey@voltrondata.com> Co-authored-by: Antoine Pitrou <pitrou@free.fr> Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com> Signed-off-by: Dewey Dunnington <dewey@voltrondata.com>
Rationale for this change
While #39969 fixed the immediate issue caused by the update of the capsule name used by reticulate whilst converting an R "external pointer", it will still result in an error if somebody is using an older version of the Arrow R package.
What changes are included in this PR?
The pyarrow Cython code was modified to accept capsules with the name NULL or "r_extptr".
Are these changes tested?
Not sure where the best place for this is, but:
CRAN arrow + released pyarrow + new reticulate (errors):
CRAN arrow + pyarrow from this PR + old reticulate:
CRAN arrow + pyarrow from this PR + new reticulate:
Are there any user-facing changes?
No