Previously neither the module nor the name of the module of
pyfunctions were registered. This commit passes the module and
its name when creating a new pyfunction.
PyModule::add_function and PyModule::add_module have been added and are
set to replace `add_wrapped` in a future release. `add_wrapped` is kept
for compatibility reasons during the transition.
Depending on whether a `PyModule` or `Python` is the argument for the
Python function-wrapper, the module will be registered with the function.
* Added a couple basic tests
* Implemented suggested change
* Fixed type inference
* cargo fmt
* Finished tests and removed warnings
* Include in CHANGELOG.md
* Moved test into separate file
* &'static str and function rename
* Mention in the book
* 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>
* Bump version to 0.10.0
* Apply suggestions from code review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Improve CHANGELOG completeness and messaging
* ObjectProtocol was in prelude
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Clarified documentation for implementing iteration.
* Updated example so that it compiles.
* Updated PyIterProtocol docs per discussion.
* Added link to Python docs on iterators.
* Improved language regarding iterables and PyIterProtocol.
* Fixed assertion calls.
* guide: fixes and some minor additions
I went through the guide and fixed some grammar/consistency issues,
and added some wording where I thought it appropriate.
I also reordered the chapters to what I feel is a more natural
flow of concepts.
* Apply suggestions from code review and fix tests
Co-Authored-By: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
Co-Authored-By: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Add `MODULE` const value to `PyTypeInfo` trait
* Allow setting module name in `pyclass` macro arguments
* Add `$module` argument to `pyobject_native_type` macro in `pyo3::types`
* Set the right module for builtin types in `pyo3::types`
* Add `module` argument to example `word_count.WordCounter` class
* Add `module` argument of `pyclass` macro to guide
* Reformat code using `rustfmt`
* Add tests and entry in CHANGELOG.md for `module` argument in `pyclass`
* Make `$module` parameter in `pyobject_native_type` optional
* Make `pyobject_native_type` declare module as `Some("builtins")` by default
* wip
* removed stuff
* removed another change
* implemented minimum amouth of ifdefs to make pypy3 hello world to compile
* implemented minimum amount of ifdefs to make pypy3 hello world to compile
* hacking on build.rs
* compiler is happy!
* few todos remain
* extracted build logic to seperate module
* added pypy test
* finally fixed pypy structs
* removed some todos
* test should now be machine independent
* fixed all pypy3 symbols
* added pypy feature
* removed `is_pypy`
* added pypy2 declerations also
* fix for cpython2
* improved libpypy detection
* added all pypy2 macros
* fixed errneous type
* more fixes
* fix python2 string macros
* modsupport symbol
* fix
* fixed and added many symbols
* fixes
* remove dup
* remove mac-specific config
* fix all name mangling macros
* unite imports
* missing symbol
* fix pybool
* implemented another missing symbol
* it works
* fix merge conflict
* uncomment non default features
* cargo.toml
* Cargo fmt
* small merge fixes
* use newer build version
* whoops
* fix build script
* more build hacks
* some random hiccups
* small fixes
* it builds!
* it builds and runs
* revert everything in FFI2
* revert changes to ffi2
* check python3 for pypy
* tiny fix
* revert ffi2 for real
* revert weird formatting changes
* bring back missing feature
* tiny error
* fix py3.7 issue
* add pypy3.5 6.0 to travis
* remove dbg!
* another tiny fix
* removed some useless annotations, and fixed inlines annotations
* removed `pretty_assertions`
* removed pypy feature from cargo.toml
* fix for Py_CompileStringFlags
* tox runs word_count!
* __dict__ changes are not supported for PyPy
* fix 3.7 and copy comment
* fix test script 😳
* transfer ownership of strings to cpython when possible
* remove cstr! macro
* added missing nuls
* as_bytes() -> b’’ string
* symbol removed by mistake
* properly shim pypy date time API, some tests are passing!
* extension_module tests now not crashing! (some still skipped)
* maybe travis has new pypy version?
* small error on windows (build script)
* fix conditional compilation
* try to make tests run on travis..
* invert condition
* added pytest-faulthandler to facilitate debugging
* correctly name dir
* use full paths
* say —yes to conda
* fix
* syntax error
* change PATH
* fixed a terrible bug with PyTypeObjects in PyPy
* fix PyTypeObject defs
* re-enabled tests!
* all tests are passing!
* make the fix ad-hoc for now
* removed build module
* revert changes that cause an additional GC bug
* prevented buggy test from failing pypy
* removed unused comment
* don’t run coverage on pypy
* removed some erroneous symbols from function calls which are actually macros
* restore py37 pyunicode missing def
* use only `link_name` in PyPy specific declarations
* only setup PyPy when testing against PyPy
* annotation that was eaten during merge
* remove change to comment by mistake + unnecessary changes to cargo.toml
* xfail dates test only on pypy
* changed comment to be a little more helpful
* cleaned up some warnings
* Update src/ffi3/ceval.rs
Co-Authored-By: omerbenamram <omerbenamram@gmail.com>
* @konstin PR notes
* rustfmt
* some documentation
* if configured via env var only, default to cpython
* remove extra unsafe
* refer users to guide for pypy
* Update guide/src/pypy.md
Co-Authored-By: omerbenamram <omerbenamram@gmail.com>
* Update guide/src/pypy.md
Co-Authored-By: omerbenamram <omerbenamram@gmail.com>
* @konstin applied patch
* check that pypy at least build
* search explicitly for libpypy
* added note about some known unsupported features
* use ld_version
* export PYTHON_SYS_EXECUTABLE to `cargo build` test
* inverted if
* always link pypy dynamically
* remove unused imports
* Apply @kngwyu’s suggestion
* fix tox configuration
* try conda virtualenv
* try to simply not install python at all inside pypy environment
* setup pypy before using “python"
* use system_site_packages
* revert change to .travis
* moved cpyext datetime documentation to module level, and revised it.
* Update src/ffi/datetime.rs
Co-Authored-By: omerbenamram <omerbenamram@gmail.com>
* rustfmt
* Update src/ffi/datetime.rs
Co-Authored-By: omerbenamram <omerbenamram@gmail.com>
* kept only notes that are relevant to users.
* invert if
* use bash and not sh