New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Restrict instance methods on extension types to the actual type #6127
Comments
Note that "regular" C extension classes do not exhibit this problem as their method implementations are automatically guarded by a type check: >>> import numpy as np
>>> np.ndarray.byteswap(0)
Traceback (most recent call last):
Cell In[5], line 1
np.ndarray.byteswap(0)
TypeError: descriptor 'byteswap' for 'numpy.ndarray' objects doesn't apply to a 'int' object |
This is probably why we don't check. This issue only applies to I suspect it would be worth adding the check. |
… for Cython 2 (#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in #40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in #40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
… for Cython 2 (#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in #40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in #40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
…_error for Cython 2 (apache#41059) ### Rationale for this change `test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976. ### What changes are included in this PR? Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#41043 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
Is your feature request related to a problem? Please describe.
Currently, it's possible to call instance methods of extension types with any
self
argument that's not of the desired type. For many extension types, this will result in a crash when accessing the C-level internals.Example in PyArrow:
Describe the solution you'd like.
Cython should, by default or when enabled through an option, guard against any call of extension type instance methods with a
self
that's not an instance of the type.Describe alternatives you've considered.
Additional context
No response
The text was updated successfully, but these errors were encountered: