* Add (failing) tests for issue #1064
* Return NotImplemented when richcmp doesn't match the expected type.
* Fix tests that expect TypeError when richcmp returns NotImplemented.
- The python code 'class Other: pass; c2 {} Other()' was raising a NameError:
c2 not found
- eq and ne never raise a TypeError, so I split the those cases.
* Return NotImplemented for number-like binary operations.
* Add dummy impl PyNumberProtocol for the test struct.
* Rework tests of NotImplemented.
* Make py_ternary_num_func return NotImplemented when type mismatches.
* Return NotImplement for type mismatches in binary inplace operators.
* Reduce boilerplate with `extract_or_return_not_implemented!`
* Extract common definition 'Other' into a function.
* Test explicitly for NotImplemented in the __ipow__ test.
* Add entry in CHANGELOG for PR #1072.
* Add the section 'Emulating numeric types' to the guide.
* Ensure we're returning NotImplemented in tests.
* Simplify the tests: only test we return NotImplemented.
Our previous test were rather indirect: were relying that Python
behaves correctly when we return NotImplemented.
Now we only test that calling a pyclass dunder method returns NotImplemented
when the argument doesn't match the type signature. This is the expected
behavior.
* Remove reverse operators in tests of NotImplemented
The won't be used because of #844.
* Apply suggestions from code review
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
* Add a note about #844 below the list of reflected operations.
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
* Added Rust initialisation of Python-allocated bytes
* Added unsafe PyBytes::new_with_unit constructor
* Added examples to PyBytes::new_with and PyBytes::new_with_uninit (now with MaybeUninit<u8>)
* Fixed doc test imports for PyBytes::new_with and PyBytes::new_with_uninit
* Fixed clippy error in PyBytes::new_with_uninit test
* Added PyByteArray::new_with and Removed PyBytes::new_with_uninit
* Small doc fixes + FnOnce init closure for PyBytes::new_with and PyByteArray::new_with
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Fixed where clause formatting in PyBytes::new_with and PyByteArray::new_with
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Offsets for dict and weakref are calculated from the end of the
PyCell struct. When using the non-dummy ThreadChecker, the offsets
were invalid since the `ThreadCheckerImpl` is not zero-sized.