index
int64
0
0
repo_id
stringclasses
596 values
file_path
stringlengths
31
168
content
stringlengths
1
6.2M
0
lc_public_repos/langsmith-sdk/vendor/pyo3/tests
lc_public_repos/langsmith-sdk/vendor/pyo3/tests/ui/invalid_cancel_handle.rs
use pyo3::prelude::*; #[pyfunction] async fn cancel_handle_repeated(#[pyo3(cancel_handle, cancel_handle)] _param: String) {} #[pyfunction] async fn cancel_handle_repeated2( #[pyo3(cancel_handle)] _param: String, #[pyo3(cancel_handle)] _param2: String, ) { } #[pyfunction] fn cancel_handle_synchronous(#[pyo3(cancel_handle)] _param: String) {} #[pyfunction] async fn cancel_handle_wrong_type(#[pyo3(cancel_handle)] _param: String) {} #[pyfunction] async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} #[pyfunction] async fn cancel_handle_and_from_py_with( #[pyo3(cancel_handle, from_py_with = "cancel_handle")] _param: pyo3::coroutine::CancelHandle, ) { } fn main() {}
0
lc_public_repos/langsmith-sdk/vendor/pyo3/tests
lc_public_repos/langsmith-sdk/vendor/pyo3/tests/ui/abi3_nativetype_inheritance.stderr
error[E0277]: pyclass `PyDict` cannot be subclassed --> tests/ui/abi3_nativetype_inheritance.rs:5:19 | 5 | #[pyclass(extends=PyDict)] | ^^^^^^ required for `#[pyclass(extends=PyDict)]` | = help: the trait `PyClassBaseType` is not implemented for `PyDict` = note: `PyDict` must have `#[pyclass(subclass)]` to be eligible for subclassing = note: with the `abi3` feature enabled, PyO3 does not support subclassing native types = help: the trait `PyClassBaseType` is implemented for `PyAny` note: required by a bound in `PyClassImpl::BaseType` --> src/impl_/pyclass.rs | | type BaseType: PyTypeInfo + PyClassBaseType; | ^^^^^^^^^^^^^^^ required by this bound in `PyClassImpl::BaseType` error[E0277]: pyclass `PyDict` cannot be subclassed --> tests/ui/abi3_nativetype_inheritance.rs:5:1 | 5 | #[pyclass(extends=PyDict)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required for `#[pyclass(extends=PyDict)]` | = help: the trait `PyClassBaseType` is not implemented for `PyDict` = note: `PyDict` must have `#[pyclass(subclass)]` to be eligible for subclassing = note: with the `abi3` feature enabled, PyO3 does not support subclassing native types = help: the trait `PyClassBaseType` is implemented for `PyAny` = note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info)
0
lc_public_repos/langsmith-sdk/vendor/pyo3/tests
lc_public_repos/langsmith-sdk/vendor/pyo3/tests/ui/invalid_pyclass_enum.rs
use pyo3::prelude::*; #[pyclass(subclass)] enum NotBaseClass { X, Y, } #[pyclass(extends = PyList)] enum NotDrivedClass { X, Y, } #[pyclass] enum NoEmptyEnum {} #[pyclass] enum NoUnitVariants { StructVariant { field: i32 }, UnitVariant, } #[pyclass] enum SimpleNoSignature { #[pyo3(constructor = (a, b))] A, B, } #[pyclass(eq, eq_int)] enum SimpleEqOptRequiresPartialEq { A, B, } #[pyclass(eq)] enum ComplexEqOptRequiresPartialEq { A(i32), B { msg: String }, } #[pyclass(eq_int)] enum SimpleEqIntWithoutEq { A, B, } #[pyclass(eq_int)] enum NoEqInt { A(i32), B { msg: String }, } #[pyclass(frozen, eq, eq_int, hash)] #[derive(PartialEq)] enum SimpleHashOptRequiresHash { A, B, } #[pyclass(frozen, eq, hash)] #[derive(PartialEq)] enum ComplexHashOptRequiresHash { A(i32), B { msg: String }, } #[pyclass(hash)] #[derive(Hash)] enum SimpleHashOptRequiresFrozenAndEq { A, B, } #[pyclass(hash)] #[derive(Hash)] enum ComplexHashOptRequiresEq { A(i32), B { msg: String }, } #[pyclass(ord)] enum InvalidOrderedComplexEnum { VariantA (i32), VariantB { msg: String } } #[pyclass(eq,ord)] #[derive(PartialEq)] enum InvalidOrderedComplexEnum2 { VariantA (i32), VariantB { msg: String } } #[pyclass(eq)] #[derive(PartialEq)] enum AllEnumVariantsDisabled { #[cfg(any())] DisabledA, #[cfg(not(all()))] DisabledB, } fn main() {}
0
lc_public_repos/langsmith-sdk/vendor/pyo3/tests
lc_public_repos/langsmith-sdk/vendor/pyo3/tests/ui/invalid_pymethods_duplicates.rs
//! These tests are located in a separate file because they cause conflicting implementation //! errors, which means other errors such as typechecking errors are not reported. use pyo3::prelude::*; #[pyclass] struct TwoNew {} #[pymethods] impl TwoNew { #[new] fn new_1() -> Self { Self {} } #[new] fn new_2() -> Self { Self {} } } #[pyclass] struct DuplicateMethod {} #[pymethods] impl DuplicateMethod { #[pyo3(name = "func")] fn func_a(&self) {} #[pyo3(name = "func")] fn func_b(&self) {} } fn main() {}
0
lc_public_repos/langsmith-sdk/vendor/pyo3/tests
lc_public_repos/langsmith-sdk/vendor/pyo3/tests/ui/traverse.stderr
error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic. --> tests/ui/traverse.rs:10:27 | 10 | fn __traverse__(_slf: PyRef<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> { | ^^^^^ error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic. --> tests/ui/traverse.rs:20:27 | 20 | fn __traverse__(_slf: PyRefMut<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> { | ^^^^^^^^ error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic. --> tests/ui/traverse.rs:30:27 | 30 | fn __traverse__(_slf: Bound<'_, Self>, _visit: PyVisit) -> Result<(), PyTraverseError> { | ^^^^^ error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic. --> tests/ui/traverse.rs:40:21 | 40 | fn __traverse__(&mut self, _visit: PyVisit) -> Result<(), PyTraverseError> { | ^ error: __traverse__ may not take `Python`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic. --> tests/ui/traverse.rs:60:33 | 60 | fn __traverse__(&self, _py: Python<'_>, _visit: PyVisit<'_>) -> Result<(), PyTraverseError> { | ^^^^^^^^^^
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/LICENSE-APACHE
Copyright (c) 2017-present PyO3 Project and Contributors. https://github.com/PyO3 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/Cargo.toml
[package] name = "pyo3-ffi" version = "0.23.0-dev" description = "Python-API bindings for the PyO3 ecosystem" authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"] keywords = ["pyo3", "python", "cpython", "ffi"] homepage = "https://github.com/pyo3/pyo3" repository = "https://github.com/pyo3/pyo3" categories = ["api-bindings", "development-tools::ffi"] license = "MIT OR Apache-2.0" edition = "2021" links = "python" [dependencies] libc = "0.2.62" [features] default = [] # Use this feature when building an extension module. # It tells the linker to keep the python symbols unresolved, # so that the module can also be used with statically linked python interpreters. extension-module = ["pyo3-build-config/extension-module"] # Use the Python limited API. See https://www.python.org/dev/peps/pep-0384/ for more. abi3 = ["pyo3-build-config/abi3"] # With abi3, we can manually set the minimum Python version. abi3-py37 = ["abi3-py38", "pyo3-build-config/abi3-py37"] abi3-py38 = ["abi3-py39", "pyo3-build-config/abi3-py38"] abi3-py39 = ["abi3-py310", "pyo3-build-config/abi3-py39"] abi3-py310 = ["abi3-py311", "pyo3-build-config/abi3-py310"] abi3-py311 = ["abi3-py312", "pyo3-build-config/abi3-py311"] abi3-py312 = ["abi3", "pyo3-build-config/abi3-py312"] # Automatically generates `python3.dll` import libraries for Windows targets. generate-import-lib = ["pyo3-build-config/python3-dll-a"] [dev-dependencies] paste = "1" [build-dependencies] pyo3-build-config = { path = "../pyo3-build-config", version = "=0.23.0-dev", features = ["resolve-config"] } [lints] workspace = true
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/build.rs
use pyo3_build_config::{ bail, ensure, print_feature_cfgs, pyo3_build_script_impl::{ cargo_env_var, env_var, errors::Result, is_linking_libpython, resolve_interpreter_config, InterpreterConfig, PythonVersion, }, warn, BuildFlag, PythonImplementation, }; /// Minimum Python version PyO3 supports. struct SupportedVersions { min: PythonVersion, max: PythonVersion, } const SUPPORTED_VERSIONS_CPYTHON: SupportedVersions = SupportedVersions { min: PythonVersion { major: 3, minor: 7 }, max: PythonVersion { major: 3, minor: 13, }, }; const SUPPORTED_VERSIONS_PYPY: SupportedVersions = SupportedVersions { min: PythonVersion { major: 3, minor: 9 }, max: PythonVersion { major: 3, minor: 10, }, }; const SUPPORTED_VERSIONS_GRAALPY: SupportedVersions = SupportedVersions { min: PythonVersion { major: 3, minor: 10, }, max: PythonVersion { major: 3, minor: 11, }, }; fn ensure_python_version(interpreter_config: &InterpreterConfig) -> Result<()> { // This is an undocumented env var which is only really intended to be used in CI / for testing // and development. if std::env::var("UNSAFE_PYO3_SKIP_VERSION_CHECK").as_deref() == Ok("1") { return Ok(()); } match interpreter_config.implementation { PythonImplementation::CPython => { let versions = SUPPORTED_VERSIONS_CPYTHON; ensure!( interpreter_config.version >= versions.min, "the configured Python interpreter version ({}) is lower than PyO3's minimum supported version ({})", interpreter_config.version, versions.min, ); ensure!( interpreter_config.version <= versions.max || env_var("PYO3_USE_ABI3_FORWARD_COMPATIBILITY").map_or(false, |os_str| os_str == "1"), "the configured Python interpreter version ({}) is newer than PyO3's maximum supported version ({})\n\ = help: please check if an updated version of PyO3 is available. Current version: {}\n\ = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI", interpreter_config.version, versions.max, std::env::var("CARGO_PKG_VERSION").unwrap(), ); } PythonImplementation::PyPy => { let versions = SUPPORTED_VERSIONS_PYPY; ensure!( interpreter_config.version >= versions.min, "the configured PyPy interpreter version ({}) is lower than PyO3's minimum supported version ({})", interpreter_config.version, versions.min, ); // PyO3 does not support abi3, so we cannot offer forward compatibility ensure!( interpreter_config.version <= versions.max, "the configured PyPy interpreter version ({}) is newer than PyO3's maximum supported version ({})\n\ = help: please check if an updated version of PyO3 is available. Current version: {}", interpreter_config.version, versions.max, std::env::var("CARGO_PKG_VERSION").unwrap() ); } PythonImplementation::GraalPy => { let versions = SUPPORTED_VERSIONS_GRAALPY; ensure!( interpreter_config.version >= versions.min, "the configured GraalPy interpreter version ({}) is lower than PyO3's minimum supported version ({})", interpreter_config.version, versions.min, ); // GraalPy does not support abi3, so we cannot offer forward compatibility ensure!( interpreter_config.version <= versions.max, "the configured GraalPy interpreter version ({}) is newer than PyO3's maximum supported version ({})\n\ = help: please check if an updated version of PyO3 is available. Current version: {}", interpreter_config.version, versions.max, std::env::var("CARGO_PKG_VERSION").unwrap() ); } } if interpreter_config.abi3 { match interpreter_config.implementation { PythonImplementation::CPython => { if interpreter_config .build_flags .0 .contains(&BuildFlag::Py_GIL_DISABLED) { warn!( "The free-threaded build of CPython does not yet support abi3 so the build artifacts will be version-specific." ) } } PythonImplementation::PyPy => warn!( "PyPy does not yet support abi3 so the build artifacts will be version-specific. \ See https://github.com/pypy/pypy/issues/3397 for more information." ), PythonImplementation::GraalPy => warn!( "GraalPy does not support abi3 so the build artifacts will be version-specific." ), } } Ok(()) } fn ensure_target_pointer_width(interpreter_config: &InterpreterConfig) -> Result<()> { if let Some(pointer_width) = interpreter_config.pointer_width { // Try to check whether the target architecture matches the python library let rust_target = match cargo_env_var("CARGO_CFG_TARGET_POINTER_WIDTH") .unwrap() .as_str() { "64" => 64, "32" => 32, x => bail!("unexpected Rust target pointer width: {}", x), }; ensure!( rust_target == pointer_width, "your Rust target architecture ({}-bit) does not match your python interpreter ({}-bit)", rust_target, pointer_width ); } Ok(()) } fn emit_link_config(interpreter_config: &InterpreterConfig) -> Result<()> { let target_os = cargo_env_var("CARGO_CFG_TARGET_OS").unwrap(); println!( "cargo:rustc-link-lib={link_model}{alias}{lib_name}", link_model = if interpreter_config.shared { "" } else { "static=" }, alias = if target_os == "windows" { "pythonXY:" } else { "" }, lib_name = interpreter_config.lib_name.as_ref().ok_or( "attempted to link to Python shared library but config does not contain lib_name" )?, ); if let Some(lib_dir) = &interpreter_config.lib_dir { println!("cargo:rustc-link-search=native={}", lib_dir); } Ok(()) } /// Prepares the PyO3 crate for compilation. /// /// This loads the config from pyo3-build-config and then makes some additional checks to improve UX /// for users. /// /// Emits the cargo configuration based on this config as well as a few checks of the Rust compiler /// version to enable features which aren't supported on MSRV. fn configure_pyo3() -> Result<()> { let interpreter_config = resolve_interpreter_config()?; if env_var("PYO3_PRINT_CONFIG").map_or(false, |os_str| os_str == "1") { print_config_and_exit(&interpreter_config); } ensure_python_version(&interpreter_config)?; ensure_target_pointer_width(&interpreter_config)?; // Serialize the whole interpreter config into DEP_PYTHON_PYO3_CONFIG env var. interpreter_config.to_cargo_dep_env()?; if is_linking_libpython() && !interpreter_config.suppress_build_script_link_lines { emit_link_config(&interpreter_config)?; } for cfg in interpreter_config.build_script_outputs() { println!("{}", cfg) } // Extra lines come last, to support last write wins. for line in &interpreter_config.extra_build_script_lines { println!("{}", line); } // Emit cfgs like `invalid_from_utf8_lint` print_feature_cfgs(); Ok(()) } fn print_config_and_exit(config: &InterpreterConfig) { println!("\n-- PYO3_PRINT_CONFIG=1 is set, printing configuration and halting compile --"); config .to_writer(std::io::stdout()) .expect("failed to print config to stdout"); println!("\nnote: unset the PYO3_PRINT_CONFIG environment variable and retry to compile with the above config"); std::process::exit(101); } fn main() { pyo3_build_config::print_expected_cfgs(); if let Err(e) = configure_pyo3() { eprintln!("error: {}", e.report()); std::process::exit(1) } }
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/README.md
# pyo3-ffi This crate provides [Rust](https://www.rust-lang.org/) FFI declarations for Python 3. It supports both the stable and the unstable component of the ABI through the use of cfg flags. Python Versions 3.7+ are supported. It is meant for advanced users only - regular PyO3 users shouldn't need to interact with this crate at all. The contents of this crate are not documented here, as it would entail basically copying the documentation from CPython. Consult the [Python/C API Reference Manual][capi] for up-to-date documentation. # Minimum supported Rust and Python versions Requires Rust 1.63 or greater. `pyo3-ffi` supports the following Python distributions: - CPython 3.7 or greater - PyPy 7.3 (Python 3.9+) - GraalPy 24.0 or greater (Python 3.10+) # Example: Building Python Native modules PyO3 can be used to generate a native Python module. The easiest way to try this out for the first time is to use [`maturin`]. `maturin` is a tool for building and publishing Rust-based Python packages with minimal configuration. The following steps set up some files for an example Python module, install `maturin`, and then show how to build and import the Python module. First, create a new folder (let's call it `string_sum`) containing the following two files: **`Cargo.toml`** ```toml [lib] name = "string_sum" # "cdylib" is necessary to produce a shared library for Python to import from. # # Downstream Rust code (including code in `bin/`, `examples/`, and `tests/`) will not be able # to `use string_sum;` unless the "rlib" or "lib" crate type is also included, e.g.: # crate-type = ["cdylib", "rlib"] crate-type = ["cdylib"] [dependencies.pyo3-ffi] version = "*" features = ["extension-module"] ``` **`src/lib.rs`** ```rust use std::os::raw::c_char; use std::ptr; use pyo3_ffi::*; static mut MODULE_DEF: PyModuleDef = PyModuleDef { m_base: PyModuleDef_HEAD_INIT, m_name: c_str!("string_sum").as_ptr(), m_doc: c_str!("A Python module written in Rust.").as_ptr(), m_size: 0, m_methods: unsafe { METHODS.as_mut_ptr().cast() }, m_slots: std::ptr::null_mut(), m_traverse: None, m_clear: None, m_free: None, }; static mut METHODS: [PyMethodDef; 2] = [ PyMethodDef { ml_name: c_str!("sum_as_string").as_ptr(), ml_meth: PyMethodDefPointer { PyCFunctionFast: sum_as_string, }, ml_flags: METH_FASTCALL, ml_doc: c_str!("returns the sum of two integers as a string").as_ptr(), }, // A zeroed PyMethodDef to mark the end of the array. PyMethodDef::zeroed() ]; // The module initialization function, which must be named `PyInit_<your_module>`. #[allow(non_snake_case)] #[no_mangle] pub unsafe extern "C" fn PyInit_string_sum() -> *mut PyObject { PyModule_Create(ptr::addr_of_mut!(MODULE_DEF)) } pub unsafe extern "C" fn sum_as_string( _self: *mut PyObject, args: *mut *mut PyObject, nargs: Py_ssize_t, ) -> *mut PyObject { if nargs != 2 { PyErr_SetString( PyExc_TypeError, c_str!("sum_as_string() expected 2 positional arguments").as_ptr(), ); return std::ptr::null_mut(); } let arg1 = *args; if PyLong_Check(arg1) == 0 { PyErr_SetString( PyExc_TypeError, c_str!("sum_as_string() expected an int for positional argument 1").as_ptr(), ); return std::ptr::null_mut(); } let arg1 = PyLong_AsLong(arg1); if !PyErr_Occurred().is_null() { return ptr::null_mut(); } let arg2 = *args.add(1); if PyLong_Check(arg2) == 0 { PyErr_SetString( PyExc_TypeError, c_str!("sum_as_string() expected an int for positional argument 2").as_ptr(), ); return std::ptr::null_mut(); } let arg2 = PyLong_AsLong(arg2); if !PyErr_Occurred().is_null() { return ptr::null_mut(); } match arg1.checked_add(arg2) { Some(sum) => { let string = sum.to_string(); PyUnicode_FromStringAndSize(string.as_ptr().cast::<c_char>(), string.len() as isize) } None => { PyErr_SetString( PyExc_OverflowError, c_str!("arguments too large to add").as_ptr(), ); std::ptr::null_mut() } } } ``` With those two files in place, now `maturin` needs to be installed. This can be done using Python's package manager `pip`. First, load up a new Python `virtualenv`, and install `maturin` into it: ```bash $ cd string_sum $ python -m venv .env $ source .env/bin/activate $ pip install maturin ``` Now build and execute the module: ```bash $ maturin develop # lots of progress output as maturin runs the compilation... $ python >>> import string_sum >>> string_sum.sum_as_string(5, 20) '25' ``` As well as with `maturin`, it is possible to build using [setuptools-rust] or [manually][manual_builds]. Both offer more flexibility than `maturin` but require further configuration. While most projects use the safe wrapper provided by PyO3, you can take a look at the [`orjson`] library as an example on how to use `pyo3-ffi` directly. For those well versed in C and Rust the [tutorials] from the CPython documentation can be easily converted to rust as well. [tutorials]: https://docs.python.org/3/extending/ [`orjson`]: https://github.com/ijl/orjson [capi]: https://docs.python.org/3/c-api/index.html [`maturin`]: https://github.com/PyO3/maturin "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages" [`pyo3-build-config`]: https://docs.rs/pyo3-build-config [feature flags]: https://doc.rust-lang.org/cargo/reference/features.html "Features - The Cargo Book" [manual_builds]: https://pyo3.rs/latest/building-and-distribution.html#manual-builds "Manual builds - Building and Distribution - PyO3 user guide" [setuptools-rust]: https://github.com/PyO3/setuptools-rust "Setuptools plugin for Rust extensions" [PEP 384]: https://www.python.org/dev/peps/pep-0384 "PEP 384 -- Defining a Stable ABI" [Features chapter of the guide]: https://pyo3.rs/latest/features.html#features-reference "Features Reference - PyO3 user guide"
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/LICENSE-MIT
Copyright (c) 2023-present PyO3 Project and Contributors. https://github.com/PyO3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0
lc_public_repos/langsmith-sdk/vendor/pyo3
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/ACKNOWLEDGEMENTS
This is a Rust reimplementation of the CPython public header files as necessary for binary compatibility, with additional metadata to support PyPy. For original implementations please see: - https://github.com/python/cpython - https://github.com/pypy/pypy
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/README.md
# `pyo3-ffi` Examples These example crates are a collection of toy extension modules built with `pyo3-ffi`. They are all tested using `nox` in PyO3's CI. Below is a brief description of each of these: | Example | Description | | `word-count` | Illustrates how to use pyo3-ffi to write a static rust extension | | `sequential` | Illustrates how to use pyo3-ffi to write subinterpreter-safe modules using multi-phase module initialization | ## Creating new projects from these examples To copy an example, use [`cargo-generate`](https://crates.io/crates/cargo-generate). Follow the commands below, replacing `<example>` with the example to start from: ```bash $ cargo install cargo-generate $ cargo generate --git https://github.com/PyO3/pyo3 examples/<example> ``` (`cargo generate` will take a little while to clone the PyO3 repo first; be patient when waiting for the command to run.)
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/noxfile.py
import nox @nox.session def python(session: nox.Session): session.env["MATURIN_PEP517_ARGS"] = "--profile=dev" session.install(".[dev]") session.run("pytest")
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/Cargo.toml
[package] name = "string_sum" version = "0.1.0" edition = "2021" [lib] name = "string_sum" crate-type = ["cdylib"] [dependencies] pyo3-ffi = { path = "../../", features = ["extension-module"] } [build-dependencies] pyo3-build-config = { path = "../../../pyo3-build-config" } [workspace]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/MANIFEST.in
include pyproject.toml Cargo.toml recursive-include src *
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/build.rs
fn main() { pyo3_build_config::use_pyo3_cfgs(); }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/README.md
# string_sum A project built using only `pyo3_ffi`, without any of PyO3's safe api. ## Building and Testing To build this package, first install `maturin`: ```shell pip install maturin ``` To build and test use `maturin develop`: ```shell pip install -r requirements-dev.txt maturin develop pytest ``` Alternatively, install nox and run the tests inside an isolated environment: ```shell nox ``` ## Copying this example Use [`cargo-generate`](https://crates.io/crates/cargo-generate): ```bash $ cargo install cargo-generate $ cargo generate --git https://github.com/PyO3/pyo3 examples/string_sum ``` (`cargo generate` will take a little while to clone the PyO3 repo first; be patient when waiting for the command to run.)
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/pyproject.toml
[build-system] requires = ["maturin>=1,<2"] build-backend = "maturin" [project] name = "string_sum" version = "0.1.0" classifiers = [ "License :: OSI Approved :: MIT License", "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Rust", "Operating System :: POSIX", "Operating System :: MacOS :: MacOS X", ] [project.optional-dependencies] dev = ["pytest"]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/cargo-generate.toml
[template] ignore = [".nox"] [hooks] pre = [".template/pre-script.rhai"]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/tests/test_.py
import pytest from string_sum import sum_as_string def test_sum(): a, b = 12, 42 added = sum_as_string(a, b) assert added == "54" def test_err1(): a, b = "abc", 42 with pytest.raises( TypeError, match="sum_as_string expected an int for positional argument 1" ): sum_as_string(a, b) def test_err2(): a, b = 0, {} with pytest.raises( TypeError, match="sum_as_string expected an int for positional argument 2" ): sum_as_string(a, b) def test_overflow1(): a, b = 0, 1 << 43 with pytest.raises(OverflowError, match="cannot fit 8796093022208 in 32 bits"): sum_as_string(a, b) def test_overflow2(): a, b = 1 << 30, 1 << 30 with pytest.raises(OverflowError, match="arguments too large to add"): sum_as_string(a, b)
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/src/lib.rs
use std::os::raw::{c_char, c_long}; use std::ptr; use pyo3_ffi::*; static mut MODULE_DEF: PyModuleDef = PyModuleDef { m_base: PyModuleDef_HEAD_INIT, m_name: c_str!("string_sum").as_ptr(), m_doc: c_str!("A Python module written in Rust.").as_ptr(), m_size: 0, m_methods: unsafe { METHODS as *const [PyMethodDef] as *mut PyMethodDef }, m_slots: std::ptr::null_mut(), m_traverse: None, m_clear: None, m_free: None, }; static mut METHODS: &[PyMethodDef] = &[ PyMethodDef { ml_name: c_str!("sum_as_string").as_ptr(), ml_meth: PyMethodDefPointer { PyCFunctionFast: sum_as_string, }, ml_flags: METH_FASTCALL, ml_doc: c_str!("returns the sum of two integers as a string").as_ptr(), }, // A zeroed PyMethodDef to mark the end of the array. PyMethodDef::zeroed(), ]; // The module initialization function, which must be named `PyInit_<your_module>`. #[allow(non_snake_case)] #[no_mangle] pub unsafe extern "C" fn PyInit_string_sum() -> *mut PyObject { let module = PyModule_Create(ptr::addr_of_mut!(MODULE_DEF)); if module.is_null() { return module; } #[cfg(Py_GIL_DISABLED)] { if PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED) < 0 { Py_DECREF(module); return std::ptr::null_mut(); } } module } /// A helper to parse function arguments /// If we used PyO3's proc macros they'd handle all of this boilerplate for us :) unsafe fn parse_arg_as_i32(obj: *mut PyObject, n_arg: usize) -> Option<i32> { if PyLong_Check(obj) == 0 { let msg = format!( "sum_as_string expected an int for positional argument {}\0", n_arg ); PyErr_SetString(PyExc_TypeError, msg.as_ptr().cast::<c_char>()); return None; } // Let's keep the behaviour consistent on platforms where `c_long` is bigger than 32 bits. // In particular, it is an i32 on Windows but i64 on most Linux systems let mut overflow = 0; let i_long: c_long = PyLong_AsLongAndOverflow(obj, &mut overflow); #[allow(irrefutable_let_patterns)] // some platforms have c_long equal to i32 if overflow != 0 { raise_overflowerror(obj); None } else if let Ok(i) = i_long.try_into() { Some(i) } else { raise_overflowerror(obj); None } } unsafe fn raise_overflowerror(obj: *mut PyObject) { let obj_repr = PyObject_Str(obj); if !obj_repr.is_null() { let mut size = 0; let p = PyUnicode_AsUTF8AndSize(obj_repr, &mut size); if !p.is_null() { let s = std::str::from_utf8_unchecked(std::slice::from_raw_parts( p.cast::<u8>(), size as usize, )); let msg = format!("cannot fit {} in 32 bits\0", s); PyErr_SetString(PyExc_OverflowError, msg.as_ptr().cast::<c_char>()); } Py_DECREF(obj_repr); } } pub unsafe extern "C" fn sum_as_string( _self: *mut PyObject, args: *mut *mut PyObject, nargs: Py_ssize_t, ) -> *mut PyObject { if nargs != 2 { PyErr_SetString( PyExc_TypeError, c_str!("sum_as_string expected 2 positional arguments").as_ptr(), ); return std::ptr::null_mut(); } let (first, second) = (*args, *args.add(1)); let first = match parse_arg_as_i32(first, 1) { Some(x) => x, None => return std::ptr::null_mut(), }; let second = match parse_arg_as_i32(second, 2) { Some(x) => x, None => return std::ptr::null_mut(), }; match first.checked_add(second) { Some(sum) => { let string = sum.to_string(); PyUnicode_FromStringAndSize(string.as_ptr().cast::<c_char>(), string.len() as isize) } None => { PyErr_SetString( PyExc_OverflowError, c_str!("arguments too large to add").as_ptr(), ); std::ptr::null_mut() } } }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/.template/Cargo.toml
[package] authors = ["{{authors}}"] name = "{{project-name}}" version = "0.1.0" edition = "2021" [lib] name = "string_sum" crate-type = ["cdylib"] [dependencies] pyo3-ffi = { version = "{{PYO3_VERSION}}", features = ["extension-module"] }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/.template/pyproject.toml
[build-system] requires = ["maturin>=1,<2"] build-backend = "maturin" [project] name = "{{project-name}}" version = "0.1.0" [project.optional-dependencies] dev = ["pytest"]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/string-sum/.template/pre-script.rhai
variable::set("PYO3_VERSION", "0.19.2"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::delete(".template");
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/noxfile.py
import sys import nox @nox.session def python(session): if sys.version_info < (3, 12): session.skip("Python 3.12+ is required") session.env["MATURIN_PEP517_ARGS"] = "--profile=dev" session.install(".[dev]") session.run("pytest")
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/Cargo.toml
[package] name = "sequential" version = "0.1.0" edition = "2021" [lib] name = "sequential" crate-type = ["cdylib", "lib"] [dependencies] pyo3-ffi = { path = "../../", features = ["extension-module"] } [build-dependencies] pyo3-build-config = { path = "../../../pyo3-build-config" } [workspace]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/MANIFEST.in
include pyproject.toml Cargo.toml recursive-include src *
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/build.rs
fn main() { pyo3_build_config::use_pyo3_cfgs(); }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/README.md
# sequential A project built using only `pyo3_ffi`, without any of PyO3's safe api. It can be executed by subinterpreters that have their own GIL. ## Building and Testing To build this package, first install `maturin`: ```shell pip install maturin ``` To build and test use `maturin develop`: ```shell pip install -r requirements-dev.txt maturin develop pytest ``` Alternatively, install nox and run the tests inside an isolated environment: ```shell nox ``` ## Copying this example Use [`cargo-generate`](https://crates.io/crates/cargo-generate): ```bash $ cargo install cargo-generate $ cargo generate --git https://github.com/PyO3/pyo3 examples/sequential ``` (`cargo generate` will take a little while to clone the PyO3 repo first; be patient when waiting for the command to run.)
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/pyproject.toml
[build-system] requires = ["maturin>=1,<2"] build-backend = "maturin" [project] name = "sequential" version = "0.1.0" classifiers = [ "License :: OSI Approved :: MIT License", "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Rust", "Operating System :: POSIX", "Operating System :: MacOS :: MacOS X", ] requires-python = ">=3.12" [project.optional-dependencies] dev = ["pytest"]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/cargo-generate.toml
[template] ignore = [".nox"] [hooks] pre = [".template/pre-script.rhai"]
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/tests/test_.py
import pytest from sequential import Id def test_make_some(): for x in range(12): i = Id() assert x == int(i) def test_args(): with pytest.raises(TypeError, match="Id\\(\\) takes no arguments"): Id(3, 4) def test_cmp(): a = Id() b = Id() assert a <= b assert a < b assert a == a
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/tests/test.rs
use core::ffi::{c_char, CStr}; use core::ptr; use std::thread; use pyo3_ffi::*; use sequential::PyInit_sequential; static COMMAND: &'static str = c_str!( " from sequential import Id s = sum(int(Id()) for _ in range(12)) " ); // Newtype to be able to pass it to another thread. struct State(*mut PyThreadState); unsafe impl Sync for State {} unsafe impl Send for State {} #[test] fn lets_go_fast() -> Result<(), String> { unsafe { let ret = PyImport_AppendInittab(c_str!("sequential").as_ptr(), Some(PyInit_sequential)); if ret == -1 { return Err("could not add module to inittab".into()); } Py_Initialize(); let main_state = PyThreadState_Swap(ptr::null_mut()); const NULL: State = State(ptr::null_mut()); let mut subs = [NULL; 12]; let config = PyInterpreterConfig { use_main_obmalloc: 0, allow_fork: 0, allow_exec: 0, allow_threads: 1, allow_daemon_threads: 0, check_multi_interp_extensions: 1, gil: PyInterpreterConfig_OWN_GIL, }; for State(state) in &mut subs { let status = Py_NewInterpreterFromConfig(state, &config); if PyStatus_IsError(status) == 1 { let msg = if status.err_msg.is_null() { "no error message".into() } else { CStr::from_ptr(status.err_msg).to_string_lossy() }; PyThreadState_Swap(main_state); Py_FinalizeEx(); return Err(format!("could not create new subinterpreter: {msg}")); } } PyThreadState_Swap(main_state); let main_state = PyEval_SaveThread(); // a PyInterpreterConfig with shared gil would deadlock otherwise let ints: Vec<_> = thread::scope(move |s| { let mut handles = vec![]; for state in subs { let handle = s.spawn(move || { let state = state; PyEval_RestoreThread(state.0); let ret = run_code(); Py_EndInterpreter(state.0); ret }); handles.push(handle); } handles.into_iter().map(|h| h.join().unwrap()).collect() }); PyEval_RestoreThread(main_state); let ret = Py_FinalizeEx(); if ret == -1 { return Err("could not finalize interpreter".into()); } let mut sum: u64 = 0; for i in ints { let i = i?; sum += i; } assert_eq!(sum, (0..).take(12 * 12).sum()); } Ok(()) } unsafe fn fetch() -> String { let err = PyErr_GetRaisedException(); let err_repr = PyObject_Str(err); if !err_repr.is_null() { let mut size = 0; let p = PyUnicode_AsUTF8AndSize(err_repr, &mut size); if !p.is_null() { let s = std::str::from_utf8_unchecked(std::slice::from_raw_parts( p.cast::<u8>(), size as usize, )); let s = String::from(s); Py_DECREF(err_repr); return s; } } String::from("could not get error") } fn run_code() -> Result<u64, String> { unsafe { let code_obj = Py_CompileString(COMMAND.as_ptr(), c_str!("program").as_ptr(), Py_file_input); if code_obj.is_null() { return Err(fetch()); } let globals = PyDict_New(); let res_ptr = PyEval_EvalCode(code_obj, globals, ptr::null_mut()); Py_DECREF(code_obj); if res_ptr.is_null() { return Err(fetch()); } else { Py_DECREF(res_ptr); } let sum = PyDict_GetItemString(globals, c_str!("s").as_ptr()); /* borrowed reference */ if sum.is_null() { Py_DECREF(globals); return Err("globals did not have `s`".into()); } let int = PyLong_AsUnsignedLongLong(sum) as u64; Py_DECREF(globals); Ok(int) } }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/src/lib.rs
use std::ptr; use pyo3_ffi::*; mod id; mod module; use crate::module::MODULE_DEF; // The module initialization function, which must be named `PyInit_<your_module>`. #[allow(non_snake_case)] #[no_mangle] pub unsafe extern "C" fn PyInit_sequential() -> *mut PyObject { PyModuleDef_Init(ptr::addr_of_mut!(MODULE_DEF)) }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/src/id.rs
use core::sync::atomic::{AtomicU64, Ordering}; use core::{mem, ptr}; use std::ffi::CString; use std::os::raw::{c_char, c_int, c_uint, c_ulonglong, c_void}; use pyo3_ffi::*; #[repr(C)] pub struct PyId { _ob_base: PyObject, id: Id, } static COUNT: AtomicU64 = AtomicU64::new(0); #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub struct Id(u64); impl Id { fn new() -> Self { Id(COUNT.fetch_add(1, Ordering::Relaxed)) } } unsafe extern "C" fn id_new( subtype: *mut PyTypeObject, args: *mut PyObject, kwds: *mut PyObject, ) -> *mut PyObject { if PyTuple_Size(args) != 0 || !kwds.is_null() { // We use pyo3-ffi's `c_str!` macro to create null-terminated literals because // Rust's string literals are not null-terminated // On Rust 1.77 or newer you can use `c"text"` instead. PyErr_SetString(PyExc_TypeError, c_str!("Id() takes no arguments").as_ptr()); return ptr::null_mut(); } let f: allocfunc = (*subtype).tp_alloc.unwrap_or(PyType_GenericAlloc); let slf = f(subtype, 0); if slf.is_null() { return ptr::null_mut(); } else { let id = Id::new(); let slf = slf.cast::<PyId>(); ptr::addr_of_mut!((*slf).id).write(id); } slf } unsafe extern "C" fn id_repr(slf: *mut PyObject) -> *mut PyObject { let slf = slf.cast::<PyId>(); let id = (*slf).id.0; let string = format!("Id({})", id); PyUnicode_FromStringAndSize(string.as_ptr().cast::<c_char>(), string.len() as Py_ssize_t) } unsafe extern "C" fn id_int(slf: *mut PyObject) -> *mut PyObject { let slf = slf.cast::<PyId>(); let id = (*slf).id.0; PyLong_FromUnsignedLongLong(id as c_ulonglong) } unsafe extern "C" fn id_richcompare( slf: *mut PyObject, other: *mut PyObject, op: c_int, ) -> *mut PyObject { let pytype = Py_TYPE(slf); // guaranteed to be `sequential.Id` if Py_TYPE(other) != pytype { return Py_NewRef(Py_NotImplemented()); } let slf = (*slf.cast::<PyId>()).id; let other = (*other.cast::<PyId>()).id; let cmp = match op { pyo3_ffi::Py_LT => slf < other, pyo3_ffi::Py_LE => slf <= other, pyo3_ffi::Py_EQ => slf == other, pyo3_ffi::Py_NE => slf != other, pyo3_ffi::Py_GT => slf > other, pyo3_ffi::Py_GE => slf >= other, unrecognized => { let msg = CString::new(&*format!( "unrecognized richcompare opcode {}", unrecognized )) .unwrap(); PyErr_SetString(PyExc_SystemError, msg.as_ptr()); return ptr::null_mut(); } }; if cmp { Py_NewRef(Py_True()) } else { Py_NewRef(Py_False()) } } static mut SLOTS: &[PyType_Slot] = &[ PyType_Slot { slot: Py_tp_new, pfunc: id_new as *mut c_void, }, PyType_Slot { slot: Py_tp_doc, pfunc: c_str!("An id that is increased every time an instance is created").as_ptr() as *mut c_void, }, PyType_Slot { slot: Py_tp_repr, pfunc: id_repr as *mut c_void, }, PyType_Slot { slot: Py_nb_int, pfunc: id_int as *mut c_void, }, PyType_Slot { slot: Py_tp_richcompare, pfunc: id_richcompare as *mut c_void, }, PyType_Slot { slot: 0, pfunc: ptr::null_mut(), }, ]; pub static mut ID_SPEC: PyType_Spec = PyType_Spec { name: c_str!("sequential.Id").as_ptr(), basicsize: mem::size_of::<PyId>() as c_int, itemsize: 0, flags: (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE) as c_uint, slots: unsafe { SLOTS as *const [PyType_Slot] as *mut PyType_Slot }, };
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/src/module.rs
use core::{mem, ptr}; use pyo3_ffi::*; use std::os::raw::{c_int, c_void}; pub static mut MODULE_DEF: PyModuleDef = PyModuleDef { m_base: PyModuleDef_HEAD_INIT, m_name: c_str!("sequential").as_ptr(), m_doc: c_str!("A library for generating sequential ids, written in Rust.").as_ptr(), m_size: mem::size_of::<sequential_state>() as Py_ssize_t, m_methods: std::ptr::null_mut(), m_slots: unsafe { SEQUENTIAL_SLOTS as *const [PyModuleDef_Slot] as *mut PyModuleDef_Slot }, m_traverse: Some(sequential_traverse), m_clear: Some(sequential_clear), m_free: Some(sequential_free), }; static mut SEQUENTIAL_SLOTS: &[PyModuleDef_Slot] = &[ PyModuleDef_Slot { slot: Py_mod_exec, value: sequential_exec as *mut c_void, }, PyModuleDef_Slot { slot: Py_mod_multiple_interpreters, value: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED, }, #[cfg(Py_GIL_DISABLED)] PyModuleDef_Slot { slot: Py_mod_gil, value: Py_MOD_GIL_NOT_USED, }, PyModuleDef_Slot { slot: 0, value: ptr::null_mut(), }, ]; unsafe extern "C" fn sequential_exec(module: *mut PyObject) -> c_int { let state: *mut sequential_state = PyModule_GetState(module).cast(); let id_type = PyType_FromModuleAndSpec( module, ptr::addr_of_mut!(crate::id::ID_SPEC), ptr::null_mut(), ); if id_type.is_null() { PyErr_SetString( PyExc_SystemError, c_str!("cannot locate type object").as_ptr(), ); return -1; } (*state).id_type = id_type.cast::<PyTypeObject>(); PyModule_AddObjectRef(module, c_str!("Id").as_ptr(), id_type) } unsafe extern "C" fn sequential_traverse( module: *mut PyObject, visit: visitproc, arg: *mut c_void, ) -> c_int { let state: *mut sequential_state = PyModule_GetState(module.cast()).cast(); let id_type: *mut PyObject = (*state).id_type.cast(); if id_type.is_null() { 0 } else { (visit)(id_type, arg) } } unsafe extern "C" fn sequential_clear(module: *mut PyObject) -> c_int { let state: *mut sequential_state = PyModule_GetState(module.cast()).cast(); Py_CLEAR(ptr::addr_of_mut!((*state).id_type).cast()); 0 } unsafe extern "C" fn sequential_free(module: *mut c_void) { sequential_clear(module.cast()); } #[repr(C)] struct sequential_state { id_type: *mut PyTypeObject, }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/.template/Cargo.toml
[package] authors = ["{{authors}}"] name = "{{project-name}}" version = "0.1.0" edition = "2021" [lib] name = "sequential" crate-type = ["cdylib", "lib"] [dependencies] pyo3-ffi = { version = "{{PYO3_VERSION}}", features = ["extension-module"] }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/.template/pyproject.toml
[build-system] requires = ["maturin>=1,<2"] build-backend = "maturin" [project] name = "{{project-name}}" version = "0.1.0"
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/examples/sequential/.template/pre-script.rhai
variable::set("PYO3_VERSION", "0.19.2"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::delete(".template");
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pyhash.rs
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] use crate::pyport::{Py_hash_t, Py_ssize_t}; #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] use std::os::raw::{c_char, c_void}; use std::os::raw::{c_int, c_ulong}; extern "C" { // skipped non-limited _Py_HashDouble // skipped non-limited _Py_HashPointer // skipped non-limited _Py_HashPointerRaw #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t; } pub const _PyHASH_MULTIPLIER: c_ulong = 1000003; // skipped _PyHASH_BITS // skipped non-limited _Py_HashSecret_t #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] #[repr(C)] #[derive(Copy, Clone)] pub struct PyHash_FuncDef { pub hash: Option<extern "C" fn(arg1: *const c_void, arg2: Py_ssize_t) -> Py_hash_t>, pub name: *const c_char, pub hash_bits: c_int, pub seed_bits: c_int, } #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] impl Default for PyHash_FuncDef { #[inline] fn default() -> Self { unsafe { std::mem::zeroed() } } } extern "C" { #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] pub fn PyHash_GetFuncDef() -> *mut PyHash_FuncDef; } // skipped Py_HASH_CUTOFF pub const Py_HASH_EXTERNAL: c_int = 0; pub const Py_HASH_SIPHASH24: c_int = 1; pub const Py_HASH_FNV: c_int = 2; // skipped Py_HASH_ALGORITHM
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/context.rs
use crate::object::{PyObject, PyTypeObject, Py_TYPE}; use std::os::raw::{c_char, c_int}; use std::ptr::addr_of_mut; extern "C" { pub static mut PyContext_Type: PyTypeObject; // skipped non-limited opaque PyContext pub static mut PyContextVar_Type: PyTypeObject; // skipped non-limited opaque PyContextVar pub static mut PyContextToken_Type: PyTypeObject; // skipped non-limited opaque PyContextToken } #[inline] pub unsafe fn PyContext_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyContext_Type)) as c_int } #[inline] pub unsafe fn PyContextVar_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyContextVar_Type)) as c_int } #[inline] pub unsafe fn PyContextToken_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyContextToken_Type)) as c_int } extern "C" { pub fn PyContext_New() -> *mut PyObject; pub fn PyContext_Copy(ctx: *mut PyObject) -> *mut PyObject; pub fn PyContext_CopyCurrent() -> *mut PyObject; pub fn PyContext_Enter(ctx: *mut PyObject) -> c_int; pub fn PyContext_Exit(ctx: *mut PyObject) -> c_int; pub fn PyContextVar_New(name: *const c_char, def: *mut PyObject) -> *mut PyObject; pub fn PyContextVar_Get( var: *mut PyObject, default_value: *mut PyObject, value: *mut *mut PyObject, ) -> c_int; pub fn PyContextVar_Set(var: *mut PyObject, value: *mut PyObject) -> *mut PyObject; pub fn PyContextVar_Reset(var: *mut PyObject, token: *mut PyObject) -> c_int; // skipped non-limited _PyContext_NewHamtForTests }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pystate.rs
use crate::moduleobject::PyModuleDef; use crate::object::PyObject; use std::os::raw::c_int; #[cfg(not(PyPy))] use std::os::raw::c_long; pub const MAX_CO_EXTRA_USERS: c_int = 255; opaque_struct!(PyThreadState); opaque_struct!(PyInterpreterState); extern "C" { #[cfg(not(PyPy))] pub fn PyInterpreterState_New() -> *mut PyInterpreterState; #[cfg(not(PyPy))] pub fn PyInterpreterState_Clear(arg1: *mut PyInterpreterState); #[cfg(not(PyPy))] pub fn PyInterpreterState_Delete(arg1: *mut PyInterpreterState); #[cfg(all(Py_3_9, not(PyPy)))] pub fn PyInterpreterState_Get() -> *mut PyInterpreterState; #[cfg(all(Py_3_8, not(PyPy)))] pub fn PyInterpreterState_GetDict(arg1: *mut PyInterpreterState) -> *mut PyObject; #[cfg(not(PyPy))] pub fn PyInterpreterState_GetID(arg1: *mut PyInterpreterState) -> i64; #[cfg_attr(PyPy, link_name = "PyPyState_AddModule")] pub fn PyState_AddModule(arg1: *mut PyObject, arg2: *mut PyModuleDef) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyState_RemoveModule")] pub fn PyState_RemoveModule(arg1: *mut PyModuleDef) -> c_int; // only has PyPy prefix since 3.10 #[cfg_attr(all(PyPy, Py_3_10), link_name = "PyPyState_FindModule")] pub fn PyState_FindModule(arg1: *mut PyModuleDef) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyThreadState_New")] pub fn PyThreadState_New(arg1: *mut PyInterpreterState) -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyThreadState_Clear")] pub fn PyThreadState_Clear(arg1: *mut PyThreadState); #[cfg_attr(PyPy, link_name = "PyPyThreadState_Delete")] pub fn PyThreadState_Delete(arg1: *mut PyThreadState); #[cfg_attr(PyPy, link_name = "PyPyThreadState_Get")] pub fn PyThreadState_Get() -> *mut PyThreadState; } #[inline] pub unsafe fn PyThreadState_GET() -> *mut PyThreadState { PyThreadState_Get() } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyThreadState_Swap")] pub fn PyThreadState_Swap(arg1: *mut PyThreadState) -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyThreadState_GetDict")] pub fn PyThreadState_GetDict() -> *mut PyObject; #[cfg(not(PyPy))] pub fn PyThreadState_SetAsyncExc(arg1: c_long, arg2: *mut PyObject) -> c_int; } // skipped non-limited / 3.9 PyThreadState_GetInterpreter // skipped non-limited / 3.9 PyThreadState_GetFrame // skipped non-limited / 3.9 PyThreadState_GetID #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum PyGILState_STATE { PyGILState_LOCKED, PyGILState_UNLOCKED, } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyGILState_Ensure")] pub fn PyGILState_Ensure() -> PyGILState_STATE; #[cfg_attr(PyPy, link_name = "PyPyGILState_Release")] pub fn PyGILState_Release(arg1: PyGILState_STATE); #[cfg(not(PyPy))] pub fn PyGILState_GetThisThreadState() -> *mut PyThreadState; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/setobject.rs
use crate::object::*; #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] use crate::pyport::Py_hash_t; use crate::pyport::Py_ssize_t; use std::os::raw::c_int; use std::ptr::addr_of_mut; pub const PySet_MINSIZE: usize = 8; #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] #[repr(C)] #[derive(Debug)] pub struct setentry { pub key: *mut PyObject, pub hash: Py_hash_t, } #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] #[repr(C)] #[derive(Debug)] pub struct PySetObject { pub ob_base: PyObject, pub fill: Py_ssize_t, pub used: Py_ssize_t, pub mask: Py_ssize_t, pub table: *mut setentry, pub hash: Py_hash_t, pub finger: Py_ssize_t, pub smalltable: [setentry; PySet_MINSIZE], pub weakreflist: *mut PyObject, } // skipped #[inline] #[cfg(all(not(any(PyPy, GraalPy)), not(Py_LIMITED_API)))] pub unsafe fn PySet_GET_SIZE(so: *mut PyObject) -> Py_ssize_t { debug_assert_eq!(PyAnySet_Check(so), 1); let so = so.cast::<PySetObject>(); (*so).used } #[cfg(not(Py_LIMITED_API))] #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut _PySet_Dummy: *mut PyObject; } extern "C" { #[cfg(not(Py_LIMITED_API))] #[cfg_attr(PyPy, link_name = "_PyPySet_NextEntry")] pub fn _PySet_NextEntry( set: *mut PyObject, pos: *mut Py_ssize_t, key: *mut *mut PyObject, hash: *mut super::Py_hash_t, ) -> c_int; // skipped non-limited _PySet_Update } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPySet_Type")] pub static mut PySet_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyFrozenSet_Type")] pub static mut PyFrozenSet_Type: PyTypeObject; pub static mut PySetIter_Type: PyTypeObject; } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySet_New")] pub fn PySet_New(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFrozenSet_New")] pub fn PyFrozenSet_New(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySet_Add")] pub fn PySet_Add(set: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySet_Clear")] pub fn PySet_Clear(set: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySet_Contains")] pub fn PySet_Contains(anyset: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySet_Discard")] pub fn PySet_Discard(set: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySet_Pop")] pub fn PySet_Pop(set: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySet_Size")] pub fn PySet_Size(anyset: *mut PyObject) -> Py_ssize_t; #[cfg(PyPy)] #[link_name = "PyPyFrozenSet_CheckExact"] pub fn PyFrozenSet_CheckExact(ob: *mut PyObject) -> c_int; } #[inline] #[cfg(not(any(PyPy, GraalPy)))] pub unsafe fn PyFrozenSet_CheckExact(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == addr_of_mut!(PyFrozenSet_Type)) as c_int } extern "C" { #[cfg(PyPy)] #[link_name = "PyPyFrozenSet_Check"] pub fn PyFrozenSet_Check(ob: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyFrozenSet_Check(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == addr_of_mut!(PyFrozenSet_Type) || PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PyFrozenSet_Type)) != 0) as c_int } extern "C" { #[cfg(PyPy)] #[link_name = "PyPyAnySet_CheckExact"] pub fn PyAnySet_CheckExact(ob: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyAnySet_CheckExact(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == addr_of_mut!(PySet_Type) || Py_TYPE(ob) == addr_of_mut!(PyFrozenSet_Type)) as c_int } #[inline] pub unsafe fn PyAnySet_Check(ob: *mut PyObject) -> c_int { (PyAnySet_CheckExact(ob) != 0 || PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PySet_Type)) != 0 || PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PyFrozenSet_Type)) != 0) as c_int } #[inline] #[cfg(Py_3_10)] pub unsafe fn PySet_CheckExact(op: *mut PyObject) -> c_int { crate::Py_IS_TYPE(op, addr_of_mut!(PySet_Type)) } extern "C" { #[cfg(PyPy)] #[link_name = "PyPySet_Check"] pub fn PySet_Check(ob: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PySet_Check(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == addr_of_mut!(PySet_Type) || PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PySet_Type)) != 0) as c_int }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/ceval.rs
use crate::object::PyObject; use crate::pystate::PyThreadState; use std::os::raw::{c_char, c_int, c_void}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyEval_EvalCode")] pub fn PyEval_EvalCode( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject, ) -> *mut PyObject; pub fn PyEval_EvalCodeEx( co: *mut PyObject, globals: *mut PyObject, locals: *mut PyObject, args: *const *mut PyObject, argc: c_int, kwds: *const *mut PyObject, kwdc: c_int, defs: *const *mut PyObject, defc: c_int, kwdefs: *mut PyObject, closure: *mut PyObject, ) -> *mut PyObject; #[cfg(not(Py_3_13))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[cfg_attr(PyPy, link_name = "PyPyEval_CallObjectWithKeywords")] pub fn PyEval_CallObjectWithKeywords( func: *mut PyObject, obj: *mut PyObject, kwargs: *mut PyObject, ) -> *mut PyObject; } #[cfg(not(Py_3_13))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[inline] pub unsafe fn PyEval_CallObject(func: *mut PyObject, arg: *mut PyObject) -> *mut PyObject { #[allow(deprecated)] PyEval_CallObjectWithKeywords(func, arg, std::ptr::null_mut()) } extern "C" { #[cfg(not(Py_3_13))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[cfg_attr(PyPy, link_name = "PyPyEval_CallFunction")] pub fn PyEval_CallFunction(obj: *mut PyObject, format: *const c_char, ...) -> *mut PyObject; #[cfg(not(Py_3_13))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[cfg_attr(PyPy, link_name = "PyPyEval_CallMethod")] pub fn PyEval_CallMethod( obj: *mut PyObject, methodname: *const c_char, format: *const c_char, ... ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_GetBuiltins")] pub fn PyEval_GetBuiltins() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_GetGlobals")] pub fn PyEval_GetGlobals() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_GetLocals")] pub fn PyEval_GetLocals() -> *mut PyObject; pub fn PyEval_GetFrame() -> *mut crate::PyFrameObject; #[cfg_attr(PyPy, link_name = "PyPy_AddPendingCall")] pub fn Py_AddPendingCall( func: Option<extern "C" fn(arg1: *mut c_void) -> c_int>, arg: *mut c_void, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPy_MakePendingCalls")] pub fn Py_MakePendingCalls() -> c_int; #[cfg_attr(PyPy, link_name = "PyPy_SetRecursionLimit")] pub fn Py_SetRecursionLimit(arg1: c_int); #[cfg_attr(PyPy, link_name = "PyPy_GetRecursionLimit")] pub fn Py_GetRecursionLimit() -> c_int; fn _Py_CheckRecursiveCall(_where: *mut c_char) -> c_int; } extern "C" { #[cfg(Py_3_9)] #[cfg_attr(PyPy, link_name = "PyPy_EnterRecursiveCall")] pub fn Py_EnterRecursiveCall(arg1: *const c_char) -> c_int; #[cfg(Py_3_9)] #[cfg_attr(PyPy, link_name = "PyPy_LeaveRecursiveCall")] pub fn Py_LeaveRecursiveCall(); } extern "C" { pub fn PyEval_GetFuncName(arg1: *mut PyObject) -> *const c_char; pub fn PyEval_GetFuncDesc(arg1: *mut PyObject) -> *const c_char; pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject; pub fn PyEval_EvalFrame(arg1: *mut crate::PyFrameObject) -> *mut PyObject; pub fn PyEval_EvalFrameEx(f: *mut crate::PyFrameObject, exc: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_SaveThread")] pub fn PyEval_SaveThread() -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyEval_RestoreThread")] pub fn PyEval_RestoreThread(arg1: *mut PyThreadState); } extern "C" { #[cfg(not(Py_3_13))] #[cfg_attr(PyPy, link_name = "PyPyEval_ThreadsInitialized")] #[cfg_attr( Py_3_9, deprecated( note = "Deprecated in Python 3.9, this function always returns true in Python 3.7 or newer." ) )] pub fn PyEval_ThreadsInitialized() -> c_int; #[cfg_attr(PyPy, link_name = "PyPyEval_InitThreads")] #[cfg_attr( Py_3_9, deprecated( note = "Deprecated in Python 3.9, this function does nothing in Python 3.7 or newer." ) )] pub fn PyEval_InitThreads(); pub fn PyEval_AcquireLock(); pub fn PyEval_ReleaseLock(); #[cfg_attr(PyPy, link_name = "PyPyEval_AcquireThread")] pub fn PyEval_AcquireThread(tstate: *mut PyThreadState); #[cfg_attr(PyPy, link_name = "PyPyEval_ReleaseThread")] pub fn PyEval_ReleaseThread(tstate: *mut PyThreadState); #[cfg(not(Py_3_8))] pub fn PyEval_ReInitThreads(); } // skipped Py_BEGIN_ALLOW_THREADS // skipped Py_BLOCK_THREADS // skipped Py_UNBLOCK_THREADS // skipped Py_END_ALLOW_THREADS // skipped FVC_MASK // skipped FVC_NONE // skipped FVC_STR // skipped FVC_REPR // skipped FVC_ASCII // skipped FVS_MASK // skipped FVS_HAVE_SPEC
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/bytesobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyBytes_Type")] pub static mut PyBytes_Type: PyTypeObject; pub static mut PyBytesIter_Type: PyTypeObject; } #[inline] pub unsafe fn PyBytes_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS) } #[inline] pub unsafe fn PyBytes_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyBytes_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyBytes_FromStringAndSize")] pub fn PyBytes_FromStringAndSize(arg1: *const c_char, arg2: Py_ssize_t) -> *mut PyObject; pub fn PyBytes_FromString(arg1: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyBytes_FromObject")] pub fn PyBytes_FromObject(arg1: *mut PyObject) -> *mut PyObject; // skipped PyBytes_FromFormatV //#[cfg_attr(PyPy, link_name = "PyPyBytes_FromFormatV")] //pub fn PyBytes_FromFormatV(arg1: *const c_char, arg2: va_list) // -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyBytes_FromFormat")] pub fn PyBytes_FromFormat(arg1: *const c_char, ...) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyBytes_Size")] pub fn PyBytes_Size(arg1: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyBytes_AsString")] pub fn PyBytes_AsString(arg1: *mut PyObject) -> *mut c_char; pub fn PyBytes_Repr(arg1: *mut PyObject, arg2: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyBytes_Concat")] pub fn PyBytes_Concat(arg1: *mut *mut PyObject, arg2: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyBytes_ConcatAndDel")] pub fn PyBytes_ConcatAndDel(arg1: *mut *mut PyObject, arg2: *mut PyObject); pub fn PyBytes_DecodeEscape( arg1: *const c_char, arg2: Py_ssize_t, arg3: *const c_char, arg4: Py_ssize_t, arg5: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyBytes_AsStringAndSize")] pub fn PyBytes_AsStringAndSize( obj: *mut PyObject, s: *mut *mut c_char, len: *mut Py_ssize_t, ) -> c_int; } // skipped F_LJUST // skipped F_SIGN // skipped F_BLANK // skipped F_ALT // skipped F_ZERO
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/compile.rs
use std::os::raw::c_int; pub const Py_single_input: c_int = 256; pub const Py_file_input: c_int = 257; pub const Py_eval_input: c_int = 258; #[cfg(Py_3_8)] pub const Py_func_type_input: c_int = 345; #[cfg(Py_3_9)] pub const Py_fstring_input: c_int = 800;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/sliceobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::c_int; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg(not(GraalPy))] #[cfg_attr(PyPy, link_name = "_PyPy_EllipsisObject")] static mut _Py_EllipsisObject: PyObject; #[cfg(GraalPy)] static mut _Py_EllipsisObjectReference: *mut PyObject; } #[inline] pub unsafe fn Py_Ellipsis() -> *mut PyObject { #[cfg(not(GraalPy))] return addr_of_mut!(_Py_EllipsisObject); #[cfg(GraalPy)] return _Py_EllipsisObjectReference; } #[cfg(not(Py_LIMITED_API))] #[repr(C)] pub struct PySliceObject { pub ob_base: PyObject, #[cfg(not(GraalPy))] pub start: *mut PyObject, #[cfg(not(GraalPy))] pub stop: *mut PyObject, #[cfg(not(GraalPy))] pub step: *mut PyObject, } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPySlice_Type")] pub static mut PySlice_Type: PyTypeObject; pub static mut PyEllipsis_Type: PyTypeObject; } #[inline] pub unsafe fn PySlice_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PySlice_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySlice_New")] pub fn PySlice_New( start: *mut PyObject, stop: *mut PyObject, step: *mut PyObject, ) -> *mut PyObject; // skipped non-limited _PySlice_FromIndices // skipped non-limited _PySlice_GetLongIndices #[cfg_attr(PyPy, link_name = "PyPySlice_GetIndices")] pub fn PySlice_GetIndices( r: *mut PyObject, length: Py_ssize_t, start: *mut Py_ssize_t, stop: *mut Py_ssize_t, step: *mut Py_ssize_t, ) -> c_int; } #[inline] pub unsafe fn PySlice_GetIndicesEx( slice: *mut PyObject, length: Py_ssize_t, start: *mut Py_ssize_t, stop: *mut Py_ssize_t, step: *mut Py_ssize_t, slicelength: *mut Py_ssize_t, ) -> c_int { if PySlice_Unpack(slice, start, stop, step) < 0 { *slicelength = 0; -1 } else { *slicelength = PySlice_AdjustIndices(length, start, stop, *step); 0 } } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySlice_Unpack")] pub fn PySlice_Unpack( slice: *mut PyObject, start: *mut Py_ssize_t, stop: *mut Py_ssize_t, step: *mut Py_ssize_t, ) -> c_int; #[cfg_attr(all(PyPy, Py_3_10), link_name = "PyPySlice_AdjustIndices")] pub fn PySlice_AdjustIndices( length: Py_ssize_t, start: *mut Py_ssize_t, stop: *mut Py_ssize_t, step: Py_ssize_t, ) -> Py_ssize_t; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/typeslots.rs
use std::os::raw::c_int; pub const Py_bf_getbuffer: c_int = 1; pub const Py_bf_releasebuffer: c_int = 2; pub const Py_mp_ass_subscript: c_int = 3; pub const Py_mp_length: c_int = 4; pub const Py_mp_subscript: c_int = 5; pub const Py_nb_absolute: c_int = 6; pub const Py_nb_add: c_int = 7; pub const Py_nb_and: c_int = 8; pub const Py_nb_bool: c_int = 9; pub const Py_nb_divmod: c_int = 10; pub const Py_nb_float: c_int = 11; pub const Py_nb_floor_divide: c_int = 12; pub const Py_nb_index: c_int = 13; pub const Py_nb_inplace_add: c_int = 14; pub const Py_nb_inplace_and: c_int = 15; pub const Py_nb_inplace_floor_divide: c_int = 16; pub const Py_nb_inplace_lshift: c_int = 17; pub const Py_nb_inplace_multiply: c_int = 18; pub const Py_nb_inplace_or: c_int = 19; pub const Py_nb_inplace_power: c_int = 20; pub const Py_nb_inplace_remainder: c_int = 21; pub const Py_nb_inplace_rshift: c_int = 22; pub const Py_nb_inplace_subtract: c_int = 23; pub const Py_nb_inplace_true_divide: c_int = 24; pub const Py_nb_inplace_xor: c_int = 25; pub const Py_nb_int: c_int = 26; pub const Py_nb_invert: c_int = 27; pub const Py_nb_lshift: c_int = 28; pub const Py_nb_multiply: c_int = 29; pub const Py_nb_negative: c_int = 30; pub const Py_nb_or: c_int = 31; pub const Py_nb_positive: c_int = 32; pub const Py_nb_power: c_int = 33; pub const Py_nb_remainder: c_int = 34; pub const Py_nb_rshift: c_int = 35; pub const Py_nb_subtract: c_int = 36; pub const Py_nb_true_divide: c_int = 37; pub const Py_nb_xor: c_int = 38; pub const Py_sq_ass_item: c_int = 39; pub const Py_sq_concat: c_int = 40; pub const Py_sq_contains: c_int = 41; pub const Py_sq_inplace_concat: c_int = 42; pub const Py_sq_inplace_repeat: c_int = 43; pub const Py_sq_item: c_int = 44; pub const Py_sq_length: c_int = 45; pub const Py_sq_repeat: c_int = 46; pub const Py_tp_alloc: c_int = 47; pub const Py_tp_base: c_int = 48; pub const Py_tp_bases: c_int = 49; pub const Py_tp_call: c_int = 50; pub const Py_tp_clear: c_int = 51; pub const Py_tp_dealloc: c_int = 52; pub const Py_tp_del: c_int = 53; pub const Py_tp_descr_get: c_int = 54; pub const Py_tp_descr_set: c_int = 55; pub const Py_tp_doc: c_int = 56; pub const Py_tp_getattr: c_int = 57; pub const Py_tp_getattro: c_int = 58; pub const Py_tp_hash: c_int = 59; pub const Py_tp_init: c_int = 60; pub const Py_tp_is_gc: c_int = 61; pub const Py_tp_iter: c_int = 62; pub const Py_tp_iternext: c_int = 63; pub const Py_tp_methods: c_int = 64; pub const Py_tp_new: c_int = 65; pub const Py_tp_repr: c_int = 66; pub const Py_tp_richcompare: c_int = 67; pub const Py_tp_setattr: c_int = 68; pub const Py_tp_setattro: c_int = 69; pub const Py_tp_str: c_int = 70; pub const Py_tp_traverse: c_int = 71; pub const Py_tp_members: c_int = 72; pub const Py_tp_getset: c_int = 73; pub const Py_tp_free: c_int = 74; pub const Py_nb_matrix_multiply: c_int = 75; pub const Py_nb_inplace_matrix_multiply: c_int = 76; pub const Py_am_await: c_int = 77; pub const Py_am_aiter: c_int = 78; pub const Py_am_anext: c_int = 79; pub const Py_tp_finalize: c_int = 80;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/listobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::c_int; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyList_Type")] pub static mut PyList_Type: PyTypeObject; pub static mut PyListIter_Type: PyTypeObject; pub static mut PyListRevIter_Type: PyTypeObject; } #[inline] pub unsafe fn PyList_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) } #[inline] pub unsafe fn PyList_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyList_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyList_New")] pub fn PyList_New(size: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyList_Size")] pub fn PyList_Size(arg1: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyList_GetItem")] pub fn PyList_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyList_GetItemRef")] pub fn PyList_GetItemRef(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyList_SetItem")] pub fn PyList_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_Insert")] pub fn PyList_Insert(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_Append")] pub fn PyList_Append(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_GetSlice")] pub fn PyList_GetSlice( arg1: *mut PyObject, arg2: Py_ssize_t, arg3: Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyList_SetSlice")] pub fn PyList_SetSlice( arg1: *mut PyObject, arg2: Py_ssize_t, arg3: Py_ssize_t, arg4: *mut PyObject, ) -> c_int; #[cfg(Py_3_13)] pub fn PyList_Extend(list: *mut PyObject, iterable: *mut PyObject) -> c_int; #[cfg(Py_3_13)] pub fn PyList_Clear(list: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_Sort")] pub fn PyList_Sort(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_Reverse")] pub fn PyList_Reverse(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyList_AsTuple")] pub fn PyList_AsTuple(arg1: *mut PyObject) -> *mut PyObject; // CPython macros exported as functions on PyPy or GraalPy #[cfg(any(PyPy, GraalPy))] #[cfg_attr(PyPy, link_name = "PyPyList_GET_ITEM")] #[cfg_attr(GraalPy, link_name = "PyList_GetItem")] pub fn PyList_GET_ITEM(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; #[cfg(PyPy)] #[cfg_attr(PyPy, link_name = "PyPyList_GET_SIZE")] pub fn PyList_GET_SIZE(arg1: *mut PyObject) -> Py_ssize_t; #[cfg(any(PyPy, GraalPy))] #[cfg_attr(PyPy, link_name = "PyPyList_SET_ITEM")] #[cfg_attr(GraalPy, link_name = "_PyList_SET_ITEM")] pub fn PyList_SET_ITEM(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject); }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/methodobject.rs
use crate::object::{PyObject, PyTypeObject, Py_TYPE}; #[cfg(Py_3_9)] use crate::PyObject_TypeCheck; use std::os::raw::{c_char, c_int, c_void}; use std::{mem, ptr}; #[cfg(all(Py_3_9, not(Py_LIMITED_API), not(GraalPy)))] pub struct PyCFunctionObject { pub ob_base: PyObject, pub m_ml: *mut PyMethodDef, pub m_self: *mut PyObject, pub m_module: *mut PyObject, pub m_weakreflist: *mut PyObject, #[cfg(not(PyPy))] pub vectorcall: Option<crate::vectorcallfunc>, } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCFunction_Type")] pub static mut PyCFunction_Type: PyTypeObject; } #[cfg(Py_3_9)] #[inline] pub unsafe fn PyCFunction_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == ptr::addr_of_mut!(PyCFunction_Type)) as c_int } #[cfg(Py_3_9)] #[inline] pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, ptr::addr_of_mut!(PyCFunction_Type)) } #[cfg(not(Py_3_9))] #[inline] pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == ptr::addr_of_mut!(PyCFunction_Type)) as c_int } pub type PyCFunction = unsafe extern "C" fn(slf: *mut PyObject, args: *mut PyObject) -> *mut PyObject; #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] pub type PyCFunctionFast = unsafe extern "C" fn( slf: *mut PyObject, args: *mut *mut PyObject, nargs: crate::pyport::Py_ssize_t, ) -> *mut PyObject; #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[deprecated(note = "renamed to `PyCFunctionFast`")] pub type _PyCFunctionFast = PyCFunctionFast; pub type PyCFunctionWithKeywords = unsafe extern "C" fn( slf: *mut PyObject, args: *mut PyObject, kwds: *mut PyObject, ) -> *mut PyObject; #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] pub type PyCFunctionFastWithKeywords = unsafe extern "C" fn( slf: *mut PyObject, args: *const *mut PyObject, nargs: crate::pyport::Py_ssize_t, kwnames: *mut PyObject, ) -> *mut PyObject; #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[deprecated(note = "renamed to `PyCFunctionFastWithKeywords`")] pub type _PyCFunctionFastWithKeywords = PyCFunctionFastWithKeywords; #[cfg(all(Py_3_9, not(Py_LIMITED_API)))] pub type PyCMethod = unsafe extern "C" fn( slf: *mut PyObject, defining_class: *mut PyTypeObject, args: *const *mut PyObject, nargs: crate::pyport::Py_ssize_t, kwnames: *mut PyObject, ) -> *mut PyObject; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCFunction_GetFunction")] pub fn PyCFunction_GetFunction(f: *mut PyObject) -> Option<PyCFunction>; pub fn PyCFunction_GetSelf(f: *mut PyObject) -> *mut PyObject; pub fn PyCFunction_GetFlags(f: *mut PyObject) -> c_int; #[cfg(not(Py_3_13))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] pub fn PyCFunction_Call( f: *mut PyObject, args: *mut PyObject, kwds: *mut PyObject, ) -> *mut PyObject; } /// Represents the [PyMethodDef](https://docs.python.org/3/c-api/structures.html#c.PyMethodDef) /// structure. /// /// Note that CPython may leave fields uninitialized. You must ensure that /// `ml_name` != NULL before dereferencing or reading other fields. #[repr(C)] #[derive(Copy, Clone, PartialEq, Eq)] pub struct PyMethodDef { pub ml_name: *const c_char, pub ml_meth: PyMethodDefPointer, pub ml_flags: c_int, pub ml_doc: *const c_char, } impl PyMethodDef { pub const fn zeroed() -> PyMethodDef { PyMethodDef { ml_name: ptr::null(), ml_meth: PyMethodDefPointer { Void: ptr::null_mut(), }, ml_flags: 0, ml_doc: ptr::null(), } } } impl Default for PyMethodDef { fn default() -> PyMethodDef { PyMethodDef { ml_name: ptr::null(), ml_meth: PyMethodDefPointer { Void: ptr::null_mut(), }, ml_flags: 0, ml_doc: ptr::null(), } } } /// Function types used to implement Python callables. /// /// This function pointer must be accompanied by the correct [ml_flags](PyMethodDef::ml_flags), /// otherwise the behavior is undefined. /// /// See the [Python C API documentation][1] for more information. /// /// [1]: https://docs.python.org/3/c-api/structures.html#implementing-functions-and-methods #[repr(C)] #[derive(Copy, Clone, Eq)] pub union PyMethodDefPointer { /// This variant corresponds with [`METH_VARARGS`] *or* [`METH_NOARGS`] *or* [`METH_O`]. pub PyCFunction: PyCFunction, /// This variant corresponds with [`METH_VARARGS`] | [`METH_KEYWORDS`]. pub PyCFunctionWithKeywords: PyCFunctionWithKeywords, /// This variant corresponds with [`METH_FASTCALL`]. #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[deprecated(note = "renamed to `PyCFunctionFast`")] pub _PyCFunctionFast: PyCFunctionFast, /// This variant corresponds with [`METH_FASTCALL`]. #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] pub PyCFunctionFast: PyCFunctionFast, /// This variant corresponds with [`METH_FASTCALL`] | [`METH_KEYWORDS`]. #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[deprecated(note = "renamed to `PyCFunctionFastWithKeywords`")] pub _PyCFunctionFastWithKeywords: PyCFunctionFastWithKeywords, /// This variant corresponds with [`METH_FASTCALL`] | [`METH_KEYWORDS`]. #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] pub PyCFunctionFastWithKeywords: PyCFunctionFastWithKeywords, /// This variant corresponds with [`METH_METHOD`] | [`METH_FASTCALL`] | [`METH_KEYWORDS`]. #[cfg(all(Py_3_9, not(Py_LIMITED_API)))] pub PyCMethod: PyCMethod, Void: *mut c_void, } impl PyMethodDefPointer { pub fn as_ptr(&self) -> *mut c_void { unsafe { self.Void } } pub fn is_null(&self) -> bool { self.as_ptr().is_null() } pub const fn zeroed() -> PyMethodDefPointer { PyMethodDefPointer { Void: ptr::null_mut(), } } } impl PartialEq for PyMethodDefPointer { fn eq(&self, other: &Self) -> bool { unsafe { self.Void == other.Void } } } impl std::fmt::Pointer for PyMethodDefPointer { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let ptr = unsafe { self.Void }; std::fmt::Pointer::fmt(&ptr, f) } } const _: () = assert!(mem::size_of::<PyMethodDefPointer>() == mem::size_of::<Option<extern "C" fn()>>()); #[cfg(not(Py_3_9))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCFunction_New")] pub fn PyCFunction_New(ml: *mut PyMethodDef, slf: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyCFunction_NewEx")] pub fn PyCFunction_NewEx( ml: *mut PyMethodDef, slf: *mut PyObject, module: *mut PyObject, ) -> *mut PyObject; } #[cfg(Py_3_9)] #[inline] pub unsafe fn PyCFunction_New(ml: *mut PyMethodDef, slf: *mut PyObject) -> *mut PyObject { PyCFunction_NewEx(ml, slf, std::ptr::null_mut()) } #[cfg(Py_3_9)] #[inline] pub unsafe fn PyCFunction_NewEx( ml: *mut PyMethodDef, slf: *mut PyObject, module: *mut PyObject, ) -> *mut PyObject { PyCMethod_New(ml, slf, module, std::ptr::null_mut()) } #[cfg(Py_3_9)] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCMethod_New")] pub fn PyCMethod_New( ml: *mut PyMethodDef, slf: *mut PyObject, module: *mut PyObject, cls: *mut PyTypeObject, ) -> *mut PyObject; } /* Flag passed to newmethodobject */ pub const METH_VARARGS: c_int = 0x0001; pub const METH_KEYWORDS: c_int = 0x0002; /* METH_NOARGS and METH_O must not be combined with the flags above. */ pub const METH_NOARGS: c_int = 0x0004; pub const METH_O: c_int = 0x0008; /* METH_CLASS and METH_STATIC are a little different; these control the construction of methods for a class. These cannot be used for functions in modules. */ pub const METH_CLASS: c_int = 0x0010; pub const METH_STATIC: c_int = 0x0020; /* METH_COEXIST allows a method to be entered eventhough a slot has already filled the entry. When defined, the flag allows a separate method, "__contains__" for example, to coexist with a defined slot like sq_contains. */ pub const METH_COEXIST: c_int = 0x0040; /* METH_FASTCALL indicates the PEP 590 Vectorcall calling format. It may be specified alone or with METH_KEYWORDS. */ #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] pub const METH_FASTCALL: c_int = 0x0080; // skipped METH_STACKLESS #[cfg(all(Py_3_9, not(Py_LIMITED_API)))] pub const METH_METHOD: c_int = 0x0200; extern "C" { #[cfg(not(Py_3_9))] pub fn PyCFunction_ClearFreeList() -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pycapsule.rs
use crate::object::*; use std::os::raw::{c_char, c_int, c_void}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCapsule_Type")] pub static mut PyCapsule_Type: PyTypeObject; } pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject); #[inline] pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == addr_of_mut!(PyCapsule_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCapsule_New")] pub fn PyCapsule_New( pointer: *mut c_void, name: *const c_char, destructor: Option<PyCapsule_Destructor>, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyCapsule_GetPointer")] pub fn PyCapsule_GetPointer(capsule: *mut PyObject, name: *const c_char) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyCapsule_GetDestructor")] pub fn PyCapsule_GetDestructor(capsule: *mut PyObject) -> Option<PyCapsule_Destructor>; #[cfg_attr(PyPy, link_name = "PyPyCapsule_GetName")] pub fn PyCapsule_GetName(capsule: *mut PyObject) -> *const c_char; #[cfg_attr(PyPy, link_name = "PyPyCapsule_GetContext")] pub fn PyCapsule_GetContext(capsule: *mut PyObject) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyCapsule_IsValid")] pub fn PyCapsule_IsValid(capsule: *mut PyObject, name: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCapsule_SetPointer")] pub fn PyCapsule_SetPointer(capsule: *mut PyObject, pointer: *mut c_void) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCapsule_SetDestructor")] pub fn PyCapsule_SetDestructor( capsule: *mut PyObject, destructor: Option<PyCapsule_Destructor>, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCapsule_SetName")] pub fn PyCapsule_SetName(capsule: *mut PyObject, name: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCapsule_SetContext")] pub fn PyCapsule_SetContext(capsule: *mut PyObject, context: *mut c_void) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCapsule_Import")] pub fn PyCapsule_Import(name: *const c_char, no_block: c_int) -> *mut c_void; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/descrobject.rs
use crate::methodobject::PyMethodDef; use crate::object::{PyObject, PyTypeObject}; use crate::Py_ssize_t; use std::os::raw::{c_char, c_int, c_void}; use std::ptr; pub type getter = unsafe extern "C" fn(slf: *mut PyObject, closure: *mut c_void) -> *mut PyObject; pub type setter = unsafe extern "C" fn(slf: *mut PyObject, value: *mut PyObject, closure: *mut c_void) -> c_int; /// Represents the [PyGetSetDef](https://docs.python.org/3/c-api/structures.html#c.PyGetSetDef) /// structure. /// /// Note that CPython may leave fields uninitialized. You must ensure that /// `name` != NULL before dereferencing or reading other fields. #[repr(C)] #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct PyGetSetDef { pub name: *const c_char, pub get: Option<getter>, pub set: Option<setter>, pub doc: *const c_char, pub closure: *mut c_void, } impl Default for PyGetSetDef { fn default() -> PyGetSetDef { PyGetSetDef { name: ptr::null(), get: None, set: None, doc: ptr::null(), closure: ptr::null_mut(), } } } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyClassMethodDescr_Type")] pub static mut PyClassMethodDescr_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyGetSetDescr_Type")] pub static mut PyGetSetDescr_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyMemberDescr_Type")] pub static mut PyMemberDescr_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyMethodDescr_Type")] pub static mut PyMethodDescr_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyWrapperDescr_Type")] pub static mut PyWrapperDescr_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyDictProxy_Type")] pub static mut PyDictProxy_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyProperty_Type")] pub static mut PyProperty_Type: PyTypeObject; } extern "C" { pub fn PyDescr_NewMethod(arg1: *mut PyTypeObject, arg2: *mut PyMethodDef) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDescr_NewClassMethod")] pub fn PyDescr_NewClassMethod(arg1: *mut PyTypeObject, arg2: *mut PyMethodDef) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDescr_NewMember")] pub fn PyDescr_NewMember(arg1: *mut PyTypeObject, arg2: *mut PyMemberDef) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDescr_NewGetSet")] pub fn PyDescr_NewGetSet(arg1: *mut PyTypeObject, arg2: *mut PyGetSetDef) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDictProxy_New")] pub fn PyDictProxy_New(arg1: *mut PyObject) -> *mut PyObject; pub fn PyWrapper_New(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject; } /// Represents the [PyMemberDef](https://docs.python.org/3/c-api/structures.html#c.PyMemberDef) /// structure. /// /// Note that CPython may leave fields uninitialized. You must always ensure that /// `name` != NULL before dereferencing or reading other fields. #[repr(C)] #[derive(Copy, Clone, Eq, PartialEq)] pub struct PyMemberDef { pub name: *const c_char, pub type_code: c_int, pub offset: Py_ssize_t, pub flags: c_int, pub doc: *const c_char, } impl Default for PyMemberDef { fn default() -> PyMemberDef { PyMemberDef { name: ptr::null_mut(), type_code: 0, offset: 0, flags: 0, doc: ptr::null_mut(), } } } /* Types */ pub const Py_T_SHORT: c_int = 0; pub const Py_T_INT: c_int = 1; pub const Py_T_LONG: c_int = 2; pub const Py_T_FLOAT: c_int = 3; pub const Py_T_DOUBLE: c_int = 4; pub const Py_T_STRING: c_int = 5; #[deprecated(note = "Use Py_T_OBJECT_EX instead")] pub const _Py_T_OBJECT: c_int = 6; pub const Py_T_CHAR: c_int = 7; pub const Py_T_BYTE: c_int = 8; pub const Py_T_UBYTE: c_int = 9; pub const Py_T_USHORT: c_int = 10; pub const Py_T_UINT: c_int = 11; pub const Py_T_ULONG: c_int = 12; pub const Py_T_STRING_INPLACE: c_int = 13; pub const Py_T_BOOL: c_int = 14; pub const Py_T_OBJECT_EX: c_int = 16; pub const Py_T_LONGLONG: c_int = 17; pub const Py_T_ULONGLONG: c_int = 18; pub const Py_T_PYSSIZET: c_int = 19; #[deprecated(note = "Value is always none")] pub const _Py_T_NONE: c_int = 20; /* Flags */ pub const Py_READONLY: c_int = 1; #[cfg(Py_3_10)] pub const Py_AUDIT_READ: c_int = 2; // Added in 3.10, harmless no-op before that #[deprecated] pub const _Py_WRITE_RESTRICTED: c_int = 4; // Deprecated, no-op. Do not reuse the value. pub const Py_RELATIVE_OFFSET: c_int = 8; extern "C" { pub fn PyMember_GetOne(addr: *const c_char, l: *mut PyMemberDef) -> *mut PyObject; pub fn PyMember_SetOne(addr: *mut c_char, l: *mut PyMemberDef, value: *mut PyObject) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/complexobject.rs
use crate::object::*; use std::os::raw::{c_double, c_int}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyComplex_Type")] pub static mut PyComplex_Type: PyTypeObject; } #[inline] pub unsafe fn PyComplex_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, addr_of_mut!(PyComplex_Type)) } #[inline] pub unsafe fn PyComplex_CheckExact(op: *mut PyObject) -> c_int { Py_IS_TYPE(op, addr_of_mut!(PyComplex_Type)) } extern "C" { // skipped non-limited PyComplex_FromCComplex #[cfg_attr(PyPy, link_name = "PyPyComplex_FromDoubles")] pub fn PyComplex_FromDoubles(real: c_double, imag: c_double) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyComplex_RealAsDouble")] pub fn PyComplex_RealAsDouble(op: *mut PyObject) -> c_double; #[cfg_attr(PyPy, link_name = "PyPyComplex_ImagAsDouble")] pub fn PyComplex_ImagAsDouble(op: *mut PyObject) -> c_double; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/unicodeobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use libc::wchar_t; use std::os::raw::{c_char, c_int, c_void}; #[cfg(not(PyPy))] use std::ptr::addr_of_mut; #[cfg(not(Py_LIMITED_API))] #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `libc::wchar_t` instead.") )] pub type Py_UNICODE = wchar_t; pub type Py_UCS4 = u32; pub type Py_UCS2 = u16; pub type Py_UCS1 = u8; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyUnicode_Type")] pub static mut PyUnicode_Type: PyTypeObject; pub static mut PyUnicodeIter_Type: PyTypeObject; #[cfg(PyPy)] #[link_name = "PyPyUnicode_Check"] pub fn PyUnicode_Check(op: *mut PyObject) -> c_int; #[cfg(PyPy)] #[link_name = "PyPyUnicode_CheckExact"] pub fn PyUnicode_CheckExact(op: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyUnicode_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyUnicode_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyUnicode_Type)) as c_int } pub const Py_UNICODE_REPLACEMENT_CHARACTER: Py_UCS4 = 0xFFFD; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromStringAndSize")] pub fn PyUnicode_FromStringAndSize(u: *const c_char, size: Py_ssize_t) -> *mut PyObject; pub fn PyUnicode_FromString(u: *const c_char) -> *mut PyObject; pub fn PyUnicode_Substring( str: *mut PyObject, start: Py_ssize_t, end: Py_ssize_t, ) -> *mut PyObject; pub fn PyUnicode_AsUCS4( unicode: *mut PyObject, buffer: *mut Py_UCS4, buflen: Py_ssize_t, copy_null: c_int, ) -> *mut Py_UCS4; pub fn PyUnicode_AsUCS4Copy(unicode: *mut PyObject) -> *mut Py_UCS4; #[cfg_attr(PyPy, link_name = "PyPyUnicode_GetLength")] pub fn PyUnicode_GetLength(unicode: *mut PyObject) -> Py_ssize_t; #[cfg(not(Py_3_12))] #[deprecated(note = "Removed in Python 3.12")] #[cfg_attr(PyPy, link_name = "PyPyUnicode_GetSize")] pub fn PyUnicode_GetSize(unicode: *mut PyObject) -> Py_ssize_t; pub fn PyUnicode_ReadChar(unicode: *mut PyObject, index: Py_ssize_t) -> Py_UCS4; pub fn PyUnicode_WriteChar( unicode: *mut PyObject, index: Py_ssize_t, character: Py_UCS4, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Resize")] pub fn PyUnicode_Resize(unicode: *mut *mut PyObject, length: Py_ssize_t) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromEncodedObject")] pub fn PyUnicode_FromEncodedObject( obj: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromObject")] pub fn PyUnicode_FromObject(obj: *mut PyObject) -> *mut PyObject; // #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromFormatV")] // pub fn PyUnicode_FromFormatV(format: *const c_char, vargs: va_list) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromFormat")] pub fn PyUnicode_FromFormat(format: *const c_char, ...) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_InternInPlace")] pub fn PyUnicode_InternInPlace(arg1: *mut *mut PyObject); #[cfg(not(Py_3_12))] #[cfg_attr(Py_3_10, deprecated(note = "Python 3.10"))] pub fn PyUnicode_InternImmortal(arg1: *mut *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyUnicode_InternFromString")] pub fn PyUnicode_InternFromString(u: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromWideChar")] pub fn PyUnicode_FromWideChar(w: *const wchar_t, size: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsWideChar")] pub fn PyUnicode_AsWideChar( unicode: *mut PyObject, w: *mut wchar_t, size: Py_ssize_t, ) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsWideCharString")] pub fn PyUnicode_AsWideCharString( unicode: *mut PyObject, size: *mut Py_ssize_t, ) -> *mut wchar_t; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromOrdinal")] pub fn PyUnicode_FromOrdinal(ordinal: c_int) -> *mut PyObject; pub fn PyUnicode_ClearFreeList() -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_GetDefaultEncoding")] pub fn PyUnicode_GetDefaultEncoding() -> *const c_char; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Decode")] pub fn PyUnicode_Decode( s: *const c_char, size: Py_ssize_t, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_AsDecodedObject( unicode: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_AsDecodedUnicode( unicode: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsEncodedObject")] pub fn PyUnicode_AsEncodedObject( unicode: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsEncodedString")] pub fn PyUnicode_AsEncodedString( unicode: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_AsEncodedUnicode( unicode: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_BuildEncodingMap(string: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_DecodeUTF7( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_DecodeUTF7Stateful( string: *const c_char, length: Py_ssize_t, errors: *const c_char, consumed: *mut Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeUTF8")] pub fn PyUnicode_DecodeUTF8( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_DecodeUTF8Stateful( string: *const c_char, length: Py_ssize_t, errors: *const c_char, consumed: *mut Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF8String")] pub fn PyUnicode_AsUTF8String(unicode: *mut PyObject) -> *mut PyObject; #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF8AndSize")] pub fn PyUnicode_AsUTF8AndSize(unicode: *mut PyObject, size: *mut Py_ssize_t) -> *const c_char; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeUTF32")] pub fn PyUnicode_DecodeUTF32( string: *const c_char, length: Py_ssize_t, errors: *const c_char, byteorder: *mut c_int, ) -> *mut PyObject; pub fn PyUnicode_DecodeUTF32Stateful( string: *const c_char, length: Py_ssize_t, errors: *const c_char, byteorder: *mut c_int, consumed: *mut Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF32String")] pub fn PyUnicode_AsUTF32String(unicode: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeUTF16")] pub fn PyUnicode_DecodeUTF16( string: *const c_char, length: Py_ssize_t, errors: *const c_char, byteorder: *mut c_int, ) -> *mut PyObject; pub fn PyUnicode_DecodeUTF16Stateful( string: *const c_char, length: Py_ssize_t, errors: *const c_char, byteorder: *mut c_int, consumed: *mut Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF16String")] pub fn PyUnicode_AsUTF16String(unicode: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_DecodeUnicodeEscape( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUnicodeEscapeString")] pub fn PyUnicode_AsUnicodeEscapeString(unicode: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_DecodeRawUnicodeEscape( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_AsRawUnicodeEscapeString(unicode: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeLatin1")] pub fn PyUnicode_DecodeLatin1( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsLatin1String")] pub fn PyUnicode_AsLatin1String(unicode: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeASCII")] pub fn PyUnicode_DecodeASCII( string: *const c_char, length: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsASCIIString")] pub fn PyUnicode_AsASCIIString(unicode: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_DecodeCharmap( string: *const c_char, length: Py_ssize_t, mapping: *mut PyObject, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_AsCharmapString( unicode: *mut PyObject, mapping: *mut PyObject, ) -> *mut PyObject; pub fn PyUnicode_DecodeLocaleAndSize( str: *const c_char, len: Py_ssize_t, errors: *const c_char, ) -> *mut PyObject; pub fn PyUnicode_DecodeLocale(str: *const c_char, errors: *const c_char) -> *mut PyObject; pub fn PyUnicode_EncodeLocale(unicode: *mut PyObject, errors: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FSConverter")] pub fn PyUnicode_FSConverter(arg1: *mut PyObject, arg2: *mut c_void) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_FSDecoder")] pub fn PyUnicode_FSDecoder(arg1: *mut PyObject, arg2: *mut c_void) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeFSDefault")] pub fn PyUnicode_DecodeFSDefault(s: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeFSDefaultAndSize")] pub fn PyUnicode_DecodeFSDefaultAndSize(s: *const c_char, size: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_EncodeFSDefault")] pub fn PyUnicode_EncodeFSDefault(unicode: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Concat")] pub fn PyUnicode_Concat(left: *mut PyObject, right: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_Append(pleft: *mut *mut PyObject, right: *mut PyObject); pub fn PyUnicode_AppendAndDel(pleft: *mut *mut PyObject, right: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyUnicode_Split")] pub fn PyUnicode_Split( s: *mut PyObject, sep: *mut PyObject, maxsplit: Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Splitlines")] pub fn PyUnicode_Splitlines(s: *mut PyObject, keepends: c_int) -> *mut PyObject; pub fn PyUnicode_Partition(s: *mut PyObject, sep: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_RPartition(s: *mut PyObject, sep: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_RSplit( s: *mut PyObject, sep: *mut PyObject, maxsplit: Py_ssize_t, ) -> *mut PyObject; pub fn PyUnicode_Translate( str: *mut PyObject, table: *mut PyObject, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Join")] pub fn PyUnicode_Join(separator: *mut PyObject, seq: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Tailmatch")] pub fn PyUnicode_Tailmatch( str: *mut PyObject, substr: *mut PyObject, start: Py_ssize_t, end: Py_ssize_t, direction: c_int, ) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Find")] pub fn PyUnicode_Find( str: *mut PyObject, substr: *mut PyObject, start: Py_ssize_t, end: Py_ssize_t, direction: c_int, ) -> Py_ssize_t; pub fn PyUnicode_FindChar( str: *mut PyObject, ch: Py_UCS4, start: Py_ssize_t, end: Py_ssize_t, direction: c_int, ) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Count")] pub fn PyUnicode_Count( str: *mut PyObject, substr: *mut PyObject, start: Py_ssize_t, end: Py_ssize_t, ) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Replace")] pub fn PyUnicode_Replace( str: *mut PyObject, substr: *mut PyObject, replstr: *mut PyObject, maxcount: Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Compare")] pub fn PyUnicode_Compare(left: *mut PyObject, right: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyUnicode_CompareWithASCIIString")] pub fn PyUnicode_CompareWithASCIIString(left: *mut PyObject, right: *const c_char) -> c_int; #[cfg(Py_3_13)] pub fn PyUnicode_EqualToUTF8(unicode: *mut PyObject, string: *const c_char) -> c_int; #[cfg(Py_3_13)] pub fn PyUnicode_EqualToUTF8AndSize( unicode: *mut PyObject, string: *const c_char, size: Py_ssize_t, ) -> c_int; pub fn PyUnicode_RichCompare( left: *mut PyObject, right: *mut PyObject, op: c_int, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyUnicode_Format")] pub fn PyUnicode_Format(format: *mut PyObject, args: *mut PyObject) -> *mut PyObject; pub fn PyUnicode_Contains(container: *mut PyObject, element: *mut PyObject) -> c_int; pub fn PyUnicode_IsIdentifier(s: *mut PyObject) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/structmember.rs
use std::os::raw::c_int; pub use crate::PyMemberDef; pub use crate::Py_T_BOOL as T_BOOL; pub use crate::Py_T_BYTE as T_BYTE; pub use crate::Py_T_CHAR as T_CHAR; pub use crate::Py_T_DOUBLE as T_DOUBLE; pub use crate::Py_T_FLOAT as T_FLOAT; pub use crate::Py_T_INT as T_INT; pub use crate::Py_T_LONG as T_LONG; pub use crate::Py_T_LONGLONG as T_LONGLONG; pub use crate::Py_T_OBJECT_EX as T_OBJECT_EX; pub use crate::Py_T_SHORT as T_SHORT; pub use crate::Py_T_STRING as T_STRING; pub use crate::Py_T_STRING_INPLACE as T_STRING_INPLACE; pub use crate::Py_T_UBYTE as T_UBYTE; pub use crate::Py_T_UINT as T_UINT; pub use crate::Py_T_ULONG as T_ULONG; pub use crate::Py_T_ULONGLONG as T_ULONGLONG; pub use crate::Py_T_USHORT as T_USHORT; #[allow(deprecated)] pub use crate::_Py_T_OBJECT as T_OBJECT; pub use crate::Py_T_PYSSIZET as T_PYSSIZET; #[allow(deprecated)] pub use crate::_Py_T_NONE as T_NONE; /* Flags */ pub use crate::Py_READONLY as READONLY; pub const READ_RESTRICTED: c_int = 2; pub const PY_WRITE_RESTRICTED: c_int = 4; pub const RESTRICTED: c_int = READ_RESTRICTED | PY_WRITE_RESTRICTED;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/bytearrayobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; use std::ptr::addr_of_mut; #[cfg(not(any(PyPy, GraalPy, Py_LIMITED_API)))] #[repr(C)] pub struct PyByteArrayObject { pub ob_base: PyVarObject, pub ob_alloc: Py_ssize_t, pub ob_bytes: *mut c_char, pub ob_start: *mut c_char, #[cfg(Py_3_9)] pub ob_exports: Py_ssize_t, #[cfg(not(Py_3_9))] pub ob_exports: c_int, } #[cfg(any(PyPy, GraalPy, Py_LIMITED_API))] opaque_struct!(PyByteArrayObject); #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyByteArray_Type")] pub static mut PyByteArray_Type: PyTypeObject; pub static mut PyByteArrayIter_Type: PyTypeObject; } #[inline] pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, addr_of_mut!(PyByteArray_Type)) } #[inline] pub unsafe fn PyByteArray_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyByteArray_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyByteArray_FromObject")] pub fn PyByteArray_FromObject(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyByteArray_Concat")] pub fn PyByteArray_Concat(a: *mut PyObject, b: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyByteArray_FromStringAndSize")] pub fn PyByteArray_FromStringAndSize(string: *const c_char, len: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyByteArray_Size")] pub fn PyByteArray_Size(bytearray: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyByteArray_AsString")] pub fn PyByteArray_AsString(bytearray: *mut PyObject) -> *mut c_char; #[cfg_attr(PyPy, link_name = "PyPyByteArray_Resize")] pub fn PyByteArray_Resize(bytearray: *mut PyObject, len: Py_ssize_t) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/floatobject.rs
use crate::object::*; use std::os::raw::{c_double, c_int}; use std::ptr::addr_of_mut; #[cfg(Py_LIMITED_API)] // TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985) opaque_struct!(PyFloatObject); #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyFloat_Type")] pub static mut PyFloat_Type: PyTypeObject; } #[inline] pub unsafe fn PyFloat_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, addr_of_mut!(PyFloat_Type)) } #[inline] pub unsafe fn PyFloat_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyFloat_Type)) as c_int } // skipped Py_RETURN_NAN // skipped Py_RETURN_INF extern "C" { pub fn PyFloat_GetMax() -> c_double; pub fn PyFloat_GetMin() -> c_double; pub fn PyFloat_GetInfo() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFloat_FromString")] pub fn PyFloat_FromString(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFloat_FromDouble")] pub fn PyFloat_FromDouble(arg1: c_double) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFloat_AsDouble")] pub fn PyFloat_AsDouble(arg1: *mut PyObject) -> c_double; } // skipped non-limited _PyFloat_Pack2 // skipped non-limited _PyFloat_Pack4 // skipped non-limited _PyFloat_Pack8 // skipped non-limited _PyFloat_Unpack2 // skipped non-limited _PyFloat_Unpack4 // skipped non-limited _PyFloat_Unpack8 // skipped non-limited _PyFloat_DebugMallocStats // skipped non-limited _PyFloat_FormatAdvancedWriter
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/objimpl.rs
use libc::size_t; use std::os::raw::{c_int, c_void}; use crate::object::*; use crate::pyport::Py_ssize_t; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyObject_Malloc")] pub fn PyObject_Malloc(size: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyObject_Calloc")] pub fn PyObject_Calloc(nelem: size_t, elsize: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyObject_Realloc")] pub fn PyObject_Realloc(ptr: *mut c_void, new_size: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyObject_Free")] pub fn PyObject_Free(ptr: *mut c_void); // skipped PyObject_MALLOC // skipped PyObject_REALLOC // skipped PyObject_FREE // skipped PyObject_Del // skipped PyObject_DEL #[cfg_attr(PyPy, link_name = "PyPyObject_Init")] pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_InitVar")] pub fn PyObject_InitVar( arg1: *mut PyVarObject, arg2: *mut PyTypeObject, arg3: Py_ssize_t, ) -> *mut PyVarObject; // skipped PyObject_INIT // skipped PyObject_INIT_VAR #[cfg_attr(PyPy, link_name = "_PyPyObject_New")] pub fn _PyObject_New(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "_PyPyObject_NewVar")] pub fn _PyObject_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t) -> *mut PyVarObject; // skipped PyObject_New // skipped PyObject_NEW // skipped PyObject_NewVar // skipped PyObject_NEW_VAR pub fn PyGC_Collect() -> Py_ssize_t; #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyGC_Enable")] pub fn PyGC_Enable() -> c_int; #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyGC_Disable")] pub fn PyGC_Disable() -> c_int; #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyGC_IsEnabled")] pub fn PyGC_IsEnabled() -> c_int; // skipped PyUnstable_GC_VisitObjects } #[inline] pub unsafe fn PyType_IS_GC(t: *mut PyTypeObject) -> c_int { PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC) } extern "C" { pub fn _PyObject_GC_Resize(arg1: *mut PyVarObject, arg2: Py_ssize_t) -> *mut PyVarObject; // skipped PyObject_GC_Resize #[cfg_attr(PyPy, link_name = "_PyPyObject_GC_New")] pub fn _PyObject_GC_New(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "_PyPyObject_GC_NewVar")] pub fn _PyObject_GC_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t) -> *mut PyVarObject; #[cfg(not(PyPy))] pub fn PyObject_GC_Track(arg1: *mut c_void); #[cfg(not(PyPy))] pub fn PyObject_GC_UnTrack(arg1: *mut c_void); #[cfg_attr(PyPy, link_name = "PyPyObject_GC_Del")] pub fn PyObject_GC_Del(arg1: *mut c_void); // skipped PyObject_GC_New // skipped PyObject_GC_NewVar #[cfg(any(all(Py_3_9, not(PyPy)), Py_3_10))] // added in 3.9, or 3.10 on PyPy #[cfg_attr(PyPy, link_name = "PyPyObject_GC_IsTracked")] pub fn PyObject_GC_IsTracked(arg1: *mut PyObject) -> c_int; #[cfg(any(all(Py_3_9, not(PyPy)), Py_3_10))] // added in 3.9, or 3.10 on PyPy #[cfg_attr(PyPy, link_name = "PyPyObject_GC_IsFinalized")] pub fn PyObject_GC_IsFinalized(arg1: *mut PyObject) -> c_int; } // skipped Py_VISIT
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pyport.rs
pub type PY_UINT32_T = u32; pub type PY_UINT64_T = u64; pub type PY_INT32_T = i32; pub type PY_INT64_T = i64; pub type Py_uintptr_t = ::libc::uintptr_t; pub type Py_intptr_t = ::libc::intptr_t; pub type Py_ssize_t = ::libc::ssize_t; pub type Py_hash_t = Py_ssize_t; pub type Py_uhash_t = ::libc::size_t; pub const PY_SSIZE_T_MIN: Py_ssize_t = isize::MIN as Py_ssize_t; pub const PY_SSIZE_T_MAX: Py_ssize_t = isize::MAX as Py_ssize_t; #[cfg(target_endian = "big")] pub const PY_BIG_ENDIAN: usize = 1; #[cfg(target_endian = "big")] pub const PY_LITTLE_ENDIAN: usize = 0; #[cfg(target_endian = "little")] pub const PY_BIG_ENDIAN: usize = 0; #[cfg(target_endian = "little")] pub const PY_LITTLE_ENDIAN: usize = 1;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pystrtod.rs
use crate::object::PyObject; use std::os::raw::{c_char, c_double, c_int}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyOS_string_to_double")] pub fn PyOS_string_to_double( str: *const c_char, endptr: *mut *mut c_char, overflow_exception: *mut PyObject, ) -> c_double; #[cfg_attr(PyPy, link_name = "PyPyOS_double_to_string")] pub fn PyOS_double_to_string( val: c_double, format_code: c_char, precision: c_int, flags: c_int, _type: *mut c_int, ) -> *mut c_char; } // skipped non-limited _Py_string_to_number_with_underscores // skipped non-limited _Py_parse_inf_or_nan /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ pub const Py_DTSF_SIGN: c_int = 0x01; /* always add the sign */ pub const Py_DTSF_ADD_DOT_0: c_int = 0x02; /* if the result is an integer add ".0" */ pub const Py_DTSF_ALT: c_int = 0x04; /* "alternate" formatting. it's format_code specific */ /* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ pub const Py_DTST_FINITE: c_int = 0; pub const Py_DTST_INFINITE: c_int = 1; pub const Py_DTST_NAN: c_int = 2;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/code.rs
// This header doesn't exist in CPython, but Include/cpython/code.h does. We add // this here so that PyCodeObject has a definition under the limited API. opaque_struct!(PyCodeObject);
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/boolobject.rs
#[cfg(not(GraalPy))] use crate::longobject::PyLongObject; use crate::object::*; use std::os::raw::{c_int, c_long}; use std::ptr::addr_of_mut; #[inline] pub unsafe fn PyBool_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyBool_Type)) as c_int } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg(not(GraalPy))] #[cfg_attr(PyPy, link_name = "_PyPy_FalseStruct")] static mut _Py_FalseStruct: PyLongObject; #[cfg(not(GraalPy))] #[cfg_attr(PyPy, link_name = "_PyPy_TrueStruct")] static mut _Py_TrueStruct: PyLongObject; #[cfg(GraalPy)] static mut _Py_FalseStructReference: *mut PyObject; #[cfg(GraalPy)] static mut _Py_TrueStructReference: *mut PyObject; } #[inline] pub unsafe fn Py_False() -> *mut PyObject { #[cfg(not(GraalPy))] return addr_of_mut!(_Py_FalseStruct) as *mut PyObject; #[cfg(GraalPy)] return _Py_FalseStructReference; } #[inline] pub unsafe fn Py_True() -> *mut PyObject { #[cfg(not(GraalPy))] return addr_of_mut!(_Py_TrueStruct) as *mut PyObject; #[cfg(GraalPy)] return _Py_TrueStructReference; } #[inline] pub unsafe fn Py_IsTrue(x: *mut PyObject) -> c_int { Py_Is(x, Py_True()) } #[inline] pub unsafe fn Py_IsFalse(x: *mut PyObject) -> c_int { Py_Is(x, Py_False()) } // skipped Py_RETURN_TRUE // skipped Py_RETURN_FALSE #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyBool_FromLong")] pub fn PyBool_FromLong(arg1: c_long) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/rangeobject.rs
use crate::object::*; use std::os::raw::c_int; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyRange_Type")] pub static mut PyRange_Type: PyTypeObject; pub static mut PyRangeIter_Type: PyTypeObject; pub static mut PyLongRangeIter_Type: PyTypeObject; } #[inline] pub unsafe fn PyRange_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyRange_Type)) as c_int }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/structseq.rs
use crate::object::{PyObject, PyTypeObject}; #[cfg(not(PyPy))] use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[repr(C)] #[derive(Copy, Clone)] pub struct PyStructSequence_Field { pub name: *const c_char, pub doc: *const c_char, } #[repr(C)] #[derive(Copy, Clone)] pub struct PyStructSequence_Desc { pub name: *const c_char, pub doc: *const c_char, pub fields: *mut PyStructSequence_Field, pub n_in_sequence: c_int, } // skipped PyStructSequence_UnnamedField; extern "C" { #[cfg(not(Py_LIMITED_API))] #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType")] pub fn PyStructSequence_InitType(_type: *mut PyTypeObject, desc: *mut PyStructSequence_Desc); #[cfg(not(Py_LIMITED_API))] #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType2")] pub fn PyStructSequence_InitType2( _type: *mut PyTypeObject, desc: *mut PyStructSequence_Desc, ) -> c_int; #[cfg(not(PyPy))] pub fn PyStructSequence_NewType(desc: *mut PyStructSequence_Desc) -> *mut PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyStructSequence_New")] pub fn PyStructSequence_New(_type: *mut PyTypeObject) -> *mut PyObject; } #[cfg(not(Py_LIMITED_API))] pub type PyStructSequence = crate::PyTupleObject; #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] #[inline] pub unsafe fn PyStructSequence_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) { crate::PyTuple_SET_ITEM(op, i, v) } #[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))] #[inline] pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject { crate::PyTuple_GET_ITEM(op, i) } extern "C" { #[cfg(not(PyPy))] pub fn PyStructSequence_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject); #[cfg(not(PyPy))] pub fn PyStructSequence_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/moduleobject.rs
use crate::methodobject::PyMethodDef; use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_void}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyModule_Type")] pub static mut PyModule_Type: PyTypeObject; } #[inline] pub unsafe fn PyModule_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, addr_of_mut!(PyModule_Type)) } #[inline] pub unsafe fn PyModule_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyModule_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyModule_NewObject")] pub fn PyModule_NewObject(name: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyModule_New")] pub fn PyModule_New(name: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyModule_GetDict")] pub fn PyModule_GetDict(arg1: *mut PyObject) -> *mut PyObject; #[cfg(not(PyPy))] pub fn PyModule_GetNameObject(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyModule_GetName")] pub fn PyModule_GetName(arg1: *mut PyObject) -> *const c_char; #[cfg(not(all(windows, PyPy)))] #[deprecated(note = "Python 3.2")] pub fn PyModule_GetFilename(arg1: *mut PyObject) -> *const c_char; #[cfg(not(PyPy))] pub fn PyModule_GetFilenameObject(arg1: *mut PyObject) -> *mut PyObject; // skipped non-limited _PyModule_Clear // skipped non-limited _PyModule_ClearDict // skipped non-limited _PyModuleSpec_IsInitializing #[cfg_attr(PyPy, link_name = "PyPyModule_GetDef")] pub fn PyModule_GetDef(arg1: *mut PyObject) -> *mut PyModuleDef; #[cfg_attr(PyPy, link_name = "PyPyModule_GetState")] pub fn PyModule_GetState(arg1: *mut PyObject) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyModuleDef_Init")] pub fn PyModuleDef_Init(arg1: *mut PyModuleDef) -> *mut PyObject; } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyModuleDef_Type: PyTypeObject; } #[repr(C)] pub struct PyModuleDef_Base { pub ob_base: PyObject, pub m_init: Option<extern "C" fn() -> *mut PyObject>, pub m_index: Py_ssize_t, pub m_copy: *mut PyObject, } #[allow(clippy::declare_interior_mutable_const)] pub const PyModuleDef_HEAD_INIT: PyModuleDef_Base = PyModuleDef_Base { ob_base: PyObject_HEAD_INIT, m_init: None, m_index: 0, m_copy: std::ptr::null_mut(), }; #[repr(C)] #[derive(Copy, Clone, Eq, PartialEq)] pub struct PyModuleDef_Slot { pub slot: c_int, pub value: *mut c_void, } impl Default for PyModuleDef_Slot { fn default() -> PyModuleDef_Slot { PyModuleDef_Slot { slot: 0, value: std::ptr::null_mut(), } } } pub const Py_mod_create: c_int = 1; pub const Py_mod_exec: c_int = 2; #[cfg(Py_3_12)] pub const Py_mod_multiple_interpreters: c_int = 3; #[cfg(Py_3_13)] pub const Py_mod_gil: c_int = 4; // skipped private _Py_mod_LAST_SLOT #[cfg(Py_3_12)] pub const Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED: *mut c_void = 0 as *mut c_void; #[cfg(Py_3_12)] pub const Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED: *mut c_void = 1 as *mut c_void; #[cfg(Py_3_12)] pub const Py_MOD_PER_INTERPRETER_GIL_SUPPORTED: *mut c_void = 2 as *mut c_void; #[cfg(Py_3_13)] pub const Py_MOD_GIL_USED: *mut c_void = 0 as *mut c_void; #[cfg(Py_3_13)] pub const Py_MOD_GIL_NOT_USED: *mut c_void = 1 as *mut c_void; #[cfg(all(not(Py_LIMITED_API), Py_GIL_DISABLED))] extern "C" { pub fn PyUnstable_Module_SetGIL(module: *mut PyObject, gil: *mut c_void) -> c_int; } #[repr(C)] pub struct PyModuleDef { pub m_base: PyModuleDef_Base, pub m_name: *const c_char, pub m_doc: *const c_char, pub m_size: Py_ssize_t, pub m_methods: *mut PyMethodDef, pub m_slots: *mut PyModuleDef_Slot, pub m_traverse: Option<traverseproc>, pub m_clear: Option<inquiry>, pub m_free: Option<freefunc>, }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/longobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use libc::size_t; use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void}; use std::ptr::addr_of_mut; opaque_struct!(PyLongObject); #[inline] pub unsafe fn PyLong_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) } #[inline] pub unsafe fn PyLong_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyLong_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyLong_FromLong")] pub fn PyLong_FromLong(arg1: c_long) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLong")] pub fn PyLong_FromUnsignedLong(arg1: c_ulong) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_FromSize_t")] pub fn PyLong_FromSize_t(arg1: size_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_FromSsize_t")] pub fn PyLong_FromSsize_t(arg1: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_FromDouble")] pub fn PyLong_FromDouble(arg1: c_double) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_AsLong")] pub fn PyLong_AsLong(arg1: *mut PyObject) -> c_long; #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongAndOverflow")] pub fn PyLong_AsLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_long; #[cfg_attr(PyPy, link_name = "PyPyLong_AsSsize_t")] pub fn PyLong_AsSsize_t(arg1: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyLong_AsSize_t")] pub fn PyLong_AsSize_t(arg1: *mut PyObject) -> size_t; #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLong")] pub fn PyLong_AsUnsignedLong(arg1: *mut PyObject) -> c_ulong; #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongMask")] pub fn PyLong_AsUnsignedLongMask(arg1: *mut PyObject) -> c_ulong; // skipped non-limited _PyLong_AsInt pub fn PyLong_GetInfo() -> *mut PyObject; // skipped PyLong_AS_LONG // skipped PyLong_FromPid // skipped PyLong_AsPid // skipped _Py_PARSE_INTPTR // skipped _Py_PARSE_UINTPTR // skipped non-limited _PyLong_UnsignedShort_Converter // skipped non-limited _PyLong_UnsignedInt_Converter // skipped non-limited _PyLong_UnsignedLong_Converter // skipped non-limited _PyLong_UnsignedLongLong_Converter // skipped non-limited _PyLong_Size_t_Converter // skipped non-limited _PyLong_DigitValue // skipped non-limited _PyLong_Frexp #[cfg_attr(PyPy, link_name = "PyPyLong_AsDouble")] pub fn PyLong_AsDouble(arg1: *mut PyObject) -> c_double; #[cfg_attr(PyPy, link_name = "PyPyLong_FromVoidPtr")] pub fn PyLong_FromVoidPtr(arg1: *mut c_void) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_AsVoidPtr")] pub fn PyLong_AsVoidPtr(arg1: *mut PyObject) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyLong_FromLongLong")] pub fn PyLong_FromLongLong(arg1: c_longlong) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLongLong")] pub fn PyLong_FromUnsignedLongLong(arg1: c_ulonglong) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLong")] pub fn PyLong_AsLongLong(arg1: *mut PyObject) -> c_longlong; #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLong")] pub fn PyLong_AsUnsignedLongLong(arg1: *mut PyObject) -> c_ulonglong; #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLongMask")] pub fn PyLong_AsUnsignedLongLongMask(arg1: *mut PyObject) -> c_ulonglong; #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLongAndOverflow")] pub fn PyLong_AsLongLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_longlong; #[cfg_attr(PyPy, link_name = "PyPyLong_FromString")] pub fn PyLong_FromString( arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int, ) -> *mut PyObject; } #[cfg(not(Py_LIMITED_API))] extern "C" { #[cfg_attr(PyPy, link_name = "_PyPyLong_NumBits")] pub fn _PyLong_NumBits(obj: *mut PyObject) -> size_t; } // skipped non-limited _PyLong_Format // skipped non-limited _PyLong_FormatWriter // skipped non-limited _PyLong_FormatBytesWriter // skipped non-limited _PyLong_FormatAdvancedWriter extern "C" { pub fn PyOS_strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong; pub fn PyOS_strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long; } // skipped non-limited _PyLong_Rshift // skipped non-limited _PyLong_Lshift
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/memoryobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg(not(Py_LIMITED_API))] pub static mut _PyManagedBuffer_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyMemoryView_Type")] pub static mut PyMemoryView_Type: PyTypeObject; } #[inline] pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyMemoryView_Type)) as c_int } // skipped non-limited PyMemoryView_GET_BUFFER // skipped non-limited PyMemeryView_GET_BASE extern "C" { #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromObject")] pub fn PyMemoryView_FromObject(base: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromMemory")] pub fn PyMemoryView_FromMemory( mem: *mut c_char, size: Py_ssize_t, flags: c_int, ) -> *mut PyObject; #[cfg(any(Py_3_11, not(Py_LIMITED_API)))] #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromBuffer")] pub fn PyMemoryView_FromBuffer(view: *const crate::Py_buffer) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMemoryView_GetContiguous")] pub fn PyMemoryView_GetContiguous( base: *mut PyObject, buffertype: c_int, order: c_char, ) -> *mut PyObject; } // skipped remainder of file with comment: /* The structs are declared here so that macros can work, but they shouldn't be considered public. Don't access their fields directly, use the macros and functions instead! */
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/traceback.rs
use crate::object::*; use std::os::raw::c_int; #[cfg(not(PyPy))] use std::ptr::addr_of_mut; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Here")] pub fn PyTraceBack_Here(arg1: *mut crate::PyFrameObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Print")] pub fn PyTraceBack_Print(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Type")] pub static mut PyTraceBack_Type: PyTypeObject; #[cfg(PyPy)] #[link_name = "PyPyTraceBack_Check"] pub fn PyTraceBack_Check(op: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyTraceBack_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyTraceBack_Type)) as c_int }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pybuffer.rs
use crate::object::PyObject; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_void}; use std::ptr; #[repr(C)] #[derive(Copy, Clone)] pub struct Py_buffer { pub buf: *mut c_void, /// Owned reference pub obj: *mut crate::PyObject, pub len: Py_ssize_t, pub itemsize: Py_ssize_t, pub readonly: c_int, pub ndim: c_int, pub format: *mut c_char, pub shape: *mut Py_ssize_t, pub strides: *mut Py_ssize_t, pub suboffsets: *mut Py_ssize_t, pub internal: *mut c_void, #[cfg(PyPy)] pub flags: c_int, #[cfg(PyPy)] pub _strides: [Py_ssize_t; PyBUF_MAX_NDIM], #[cfg(PyPy)] pub _shape: [Py_ssize_t; PyBUF_MAX_NDIM], } impl Py_buffer { #[allow(clippy::new_without_default)] pub const fn new() -> Self { Py_buffer { buf: ptr::null_mut(), obj: ptr::null_mut(), len: 0, itemsize: 0, readonly: 0, ndim: 0, format: ptr::null_mut(), shape: ptr::null_mut(), strides: ptr::null_mut(), suboffsets: ptr::null_mut(), internal: ptr::null_mut(), #[cfg(PyPy)] flags: 0, #[cfg(PyPy)] _strides: [0; PyBUF_MAX_NDIM], #[cfg(PyPy)] _shape: [0; PyBUF_MAX_NDIM], } } } pub type getbufferproc = unsafe extern "C" fn(*mut PyObject, *mut crate::Py_buffer, c_int) -> c_int; pub type releasebufferproc = unsafe extern "C" fn(*mut PyObject, *mut crate::Py_buffer); /* Return 1 if the getbuffer function is available, otherwise return 0. */ extern "C" { #[cfg(not(PyPy))] pub fn PyObject_CheckBuffer(obj: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_GetBuffer")] pub fn PyObject_GetBuffer(obj: *mut PyObject, view: *mut Py_buffer, flags: c_int) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyBuffer_GetPointer")] pub fn PyBuffer_GetPointer(view: *const Py_buffer, indices: *const Py_ssize_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyBuffer_SizeFromFormat")] pub fn PyBuffer_SizeFromFormat(format: *const c_char) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyBuffer_ToContiguous")] pub fn PyBuffer_ToContiguous( buf: *mut c_void, view: *const Py_buffer, len: Py_ssize_t, order: c_char, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyBuffer_FromContiguous")] pub fn PyBuffer_FromContiguous( view: *const Py_buffer, buf: *const c_void, len: Py_ssize_t, order: c_char, ) -> c_int; pub fn PyObject_CopyData(dest: *mut PyObject, src: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyBuffer_IsContiguous")] pub fn PyBuffer_IsContiguous(view: *const Py_buffer, fort: c_char) -> c_int; pub fn PyBuffer_FillContiguousStrides( ndims: c_int, shape: *mut Py_ssize_t, strides: *mut Py_ssize_t, itemsize: c_int, fort: c_char, ); #[cfg_attr(PyPy, link_name = "PyPyBuffer_FillInfo")] pub fn PyBuffer_FillInfo( view: *mut Py_buffer, o: *mut PyObject, buf: *mut c_void, len: Py_ssize_t, readonly: c_int, flags: c_int, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyBuffer_Release")] pub fn PyBuffer_Release(view: *mut Py_buffer); } /// Maximum number of dimensions pub const PyBUF_MAX_NDIM: c_int = if cfg!(PyPy) { 36 } else { 64 }; /* Flags for getting buffers */ pub const PyBUF_SIMPLE: c_int = 0; pub const PyBUF_WRITABLE: c_int = 0x0001; /* we used to include an E, backwards compatible alias */ pub const PyBUF_WRITEABLE: c_int = PyBUF_WRITABLE; pub const PyBUF_FORMAT: c_int = 0x0004; pub const PyBUF_ND: c_int = 0x0008; pub const PyBUF_STRIDES: c_int = 0x0010 | PyBUF_ND; pub const PyBUF_C_CONTIGUOUS: c_int = 0x0020 | PyBUF_STRIDES; pub const PyBUF_F_CONTIGUOUS: c_int = 0x0040 | PyBUF_STRIDES; pub const PyBUF_ANY_CONTIGUOUS: c_int = 0x0080 | PyBUF_STRIDES; pub const PyBUF_INDIRECT: c_int = 0x0100 | PyBUF_STRIDES; pub const PyBUF_CONTIG: c_int = PyBUF_ND | PyBUF_WRITABLE; pub const PyBUF_CONTIG_RO: c_int = PyBUF_ND; pub const PyBUF_STRIDED: c_int = PyBUF_STRIDES | PyBUF_WRITABLE; pub const PyBUF_STRIDED_RO: c_int = PyBUF_STRIDES; pub const PyBUF_RECORDS: c_int = PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT; pub const PyBUF_RECORDS_RO: c_int = PyBUF_STRIDES | PyBUF_FORMAT; pub const PyBUF_FULL: c_int = PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT; pub const PyBUF_FULL_RO: c_int = PyBUF_INDIRECT | PyBUF_FORMAT; pub const PyBUF_READ: c_int = 0x100; pub const PyBUF_WRITE: c_int = 0x200;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pyerrors.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyErr_SetNone")] pub fn PyErr_SetNone(arg1: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyErr_SetObject")] pub fn PyErr_SetObject(arg1: *mut PyObject, arg2: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyErr_SetString")] pub fn PyErr_SetString(exception: *mut PyObject, string: *const c_char); #[cfg_attr(PyPy, link_name = "PyPyErr_Occurred")] pub fn PyErr_Occurred() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_Clear")] pub fn PyErr_Clear(); #[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_GetRaisedException() instead."))] #[cfg_attr(PyPy, link_name = "PyPyErr_Fetch")] pub fn PyErr_Fetch( arg1: *mut *mut PyObject, arg2: *mut *mut PyObject, arg3: *mut *mut PyObject, ); #[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_SetRaisedException() instead."))] #[cfg_attr(PyPy, link_name = "PyPyErr_Restore")] pub fn PyErr_Restore(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyErr_GetExcInfo")] pub fn PyErr_GetExcInfo( arg1: *mut *mut PyObject, arg2: *mut *mut PyObject, arg3: *mut *mut PyObject, ); #[cfg_attr(PyPy, link_name = "PyPyErr_SetExcInfo")] pub fn PyErr_SetExcInfo(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPy_FatalError")] pub fn Py_FatalError(message: *const c_char) -> !; #[cfg_attr(PyPy, link_name = "PyPyErr_GivenExceptionMatches")] pub fn PyErr_GivenExceptionMatches(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyErr_ExceptionMatches")] pub fn PyErr_ExceptionMatches(arg1: *mut PyObject) -> c_int; #[cfg_attr( Py_3_12, deprecated( note = "Use PyErr_GetRaisedException() instead, to avoid any possible de-normalization." ) )] #[cfg_attr(PyPy, link_name = "PyPyErr_NormalizeException")] pub fn PyErr_NormalizeException( arg1: *mut *mut PyObject, arg2: *mut *mut PyObject, arg3: *mut *mut PyObject, ); #[cfg(Py_3_12)] pub fn PyErr_GetRaisedException() -> *mut PyObject; #[cfg(Py_3_12)] pub fn PyErr_SetRaisedException(exc: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyException_SetTraceback")] pub fn PyException_SetTraceback(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyException_GetTraceback")] pub fn PyException_GetTraceback(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyException_GetCause")] pub fn PyException_GetCause(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyException_SetCause")] pub fn PyException_SetCause(arg1: *mut PyObject, arg2: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyException_GetContext")] pub fn PyException_GetContext(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyException_SetContext")] pub fn PyException_SetContext(arg1: *mut PyObject, arg2: *mut PyObject); #[cfg(PyPy)] #[link_name = "PyPyExceptionInstance_Class"] pub fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject; } #[inline] pub unsafe fn PyExceptionClass_Check(x: *mut PyObject) -> c_int { (PyType_Check(x) != 0 && PyType_FastSubclass(x as *mut PyTypeObject, Py_TPFLAGS_BASE_EXC_SUBCLASS) != 0) as c_int } #[inline] pub unsafe fn PyExceptionInstance_Check(x: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS) } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject { Py_TYPE(x) as *mut PyObject } // ported from cpython exception.c (line 2096) #[cfg(PyPy)] pub unsafe fn PyUnicodeDecodeError_Create( encoding: *const c_char, object: *const c_char, length: Py_ssize_t, start: Py_ssize_t, end: Py_ssize_t, reason: *const c_char, ) -> *mut PyObject { crate::_PyObject_CallFunction_SizeT( PyExc_UnicodeDecodeError, c_str!("sy#nns").as_ptr(), encoding, object, length, start, end, reason, ) } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyExc_BaseException")] pub static mut PyExc_BaseException: *mut PyObject; #[cfg(Py_3_11)] pub static mut PyExc_BaseExceptionGroup: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_Exception")] pub static mut PyExc_Exception: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_StopAsyncIteration")] pub static mut PyExc_StopAsyncIteration: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_StopIteration")] pub static mut PyExc_StopIteration: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_GeneratorExit")] pub static mut PyExc_GeneratorExit: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ArithmeticError")] pub static mut PyExc_ArithmeticError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_LookupError")] pub static mut PyExc_LookupError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_AssertionError")] pub static mut PyExc_AssertionError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_AttributeError")] pub static mut PyExc_AttributeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_BufferError")] pub static mut PyExc_BufferError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_EOFError")] pub static mut PyExc_EOFError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_FloatingPointError")] pub static mut PyExc_FloatingPointError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_OSError")] pub static mut PyExc_OSError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ImportError")] pub static mut PyExc_ImportError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ModuleNotFoundError")] pub static mut PyExc_ModuleNotFoundError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_IndexError")] pub static mut PyExc_IndexError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_KeyError")] pub static mut PyExc_KeyError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_KeyboardInterrupt")] pub static mut PyExc_KeyboardInterrupt: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_MemoryError")] pub static mut PyExc_MemoryError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_NameError")] pub static mut PyExc_NameError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_OverflowError")] pub static mut PyExc_OverflowError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_RuntimeError")] pub static mut PyExc_RuntimeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_RecursionError")] pub static mut PyExc_RecursionError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_NotImplementedError")] pub static mut PyExc_NotImplementedError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_SyntaxError")] pub static mut PyExc_SyntaxError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_IndentationError")] pub static mut PyExc_IndentationError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_TabError")] pub static mut PyExc_TabError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ReferenceError")] pub static mut PyExc_ReferenceError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_SystemError")] pub static mut PyExc_SystemError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_SystemExit")] pub static mut PyExc_SystemExit: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_TypeError")] pub static mut PyExc_TypeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnboundLocalError")] pub static mut PyExc_UnboundLocalError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnicodeError")] pub static mut PyExc_UnicodeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnicodeEncodeError")] pub static mut PyExc_UnicodeEncodeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnicodeDecodeError")] pub static mut PyExc_UnicodeDecodeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnicodeTranslateError")] pub static mut PyExc_UnicodeTranslateError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ValueError")] pub static mut PyExc_ValueError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ZeroDivisionError")] pub static mut PyExc_ZeroDivisionError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_BlockingIOError")] pub static mut PyExc_BlockingIOError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_BrokenPipeError")] pub static mut PyExc_BrokenPipeError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ChildProcessError")] pub static mut PyExc_ChildProcessError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ConnectionError")] pub static mut PyExc_ConnectionError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ConnectionAbortedError")] pub static mut PyExc_ConnectionAbortedError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ConnectionRefusedError")] pub static mut PyExc_ConnectionRefusedError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ConnectionResetError")] pub static mut PyExc_ConnectionResetError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_FileExistsError")] pub static mut PyExc_FileExistsError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_FileNotFoundError")] pub static mut PyExc_FileNotFoundError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_InterruptedError")] pub static mut PyExc_InterruptedError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_IsADirectoryError")] pub static mut PyExc_IsADirectoryError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_NotADirectoryError")] pub static mut PyExc_NotADirectoryError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_PermissionError")] pub static mut PyExc_PermissionError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ProcessLookupError")] pub static mut PyExc_ProcessLookupError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_TimeoutError")] pub static mut PyExc_TimeoutError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_OSError")] pub static mut PyExc_EnvironmentError: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_OSError")] pub static mut PyExc_IOError: *mut PyObject; #[cfg(windows)] #[cfg_attr(PyPy, link_name = "PyPyExc_OSError")] pub static mut PyExc_WindowsError: *mut PyObject; pub static mut PyExc_RecursionErrorInst: *mut PyObject; /* Predefined warning categories */ #[cfg_attr(PyPy, link_name = "PyPyExc_Warning")] pub static mut PyExc_Warning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UserWarning")] pub static mut PyExc_UserWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_DeprecationWarning")] pub static mut PyExc_DeprecationWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_PendingDeprecationWarning")] pub static mut PyExc_PendingDeprecationWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_SyntaxWarning")] pub static mut PyExc_SyntaxWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_RuntimeWarning")] pub static mut PyExc_RuntimeWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_FutureWarning")] pub static mut PyExc_FutureWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ImportWarning")] pub static mut PyExc_ImportWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_UnicodeWarning")] pub static mut PyExc_UnicodeWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_BytesWarning")] pub static mut PyExc_BytesWarning: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_ResourceWarning")] pub static mut PyExc_ResourceWarning: *mut PyObject; #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyExc_EncodingWarning")] pub static mut PyExc_EncodingWarning: *mut PyObject; } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyErr_BadArgument")] pub fn PyErr_BadArgument() -> c_int; #[cfg_attr(PyPy, link_name = "PyPyErr_NoMemory")] pub fn PyErr_NoMemory() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_SetFromErrno")] pub fn PyErr_SetFromErrno(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_SetFromErrnoWithFilenameObject")] pub fn PyErr_SetFromErrnoWithFilenameObject( arg1: *mut PyObject, arg2: *mut PyObject, ) -> *mut PyObject; pub fn PyErr_SetFromErrnoWithFilenameObjects( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject, ) -> *mut PyObject; pub fn PyErr_SetFromErrnoWithFilename( exc: *mut PyObject, filename: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_Format")] pub fn PyErr_Format(exception: *mut PyObject, format: *const c_char, ...) -> *mut PyObject; pub fn PyErr_SetImportErrorSubclass( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject, arg4: *mut PyObject, ) -> *mut PyObject; pub fn PyErr_SetImportError( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_BadInternalCall")] pub fn PyErr_BadInternalCall(); pub fn _PyErr_BadInternalCall(filename: *const c_char, lineno: c_int); #[cfg_attr(PyPy, link_name = "PyPyErr_NewException")] pub fn PyErr_NewException( name: *const c_char, base: *mut PyObject, dict: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_NewExceptionWithDoc")] pub fn PyErr_NewExceptionWithDoc( name: *const c_char, doc: *const c_char, base: *mut PyObject, dict: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_WriteUnraisable")] pub fn PyErr_WriteUnraisable(arg1: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyErr_CheckSignals")] pub fn PyErr_CheckSignals() -> c_int; #[cfg_attr(PyPy, link_name = "PyPyErr_SetInterrupt")] pub fn PyErr_SetInterrupt(); #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyErr_SetInterruptEx")] pub fn PyErr_SetInterruptEx(signum: c_int); #[cfg_attr(PyPy, link_name = "PyPyErr_SyntaxLocation")] pub fn PyErr_SyntaxLocation(filename: *const c_char, lineno: c_int); #[cfg_attr(PyPy, link_name = "PyPyErr_SyntaxLocationEx")] pub fn PyErr_SyntaxLocationEx(filename: *const c_char, lineno: c_int, col_offset: c_int); #[cfg_attr(PyPy, link_name = "PyPyErr_ProgramText")] pub fn PyErr_ProgramText(filename: *const c_char, lineno: c_int) -> *mut PyObject; #[cfg(not(PyPy))] pub fn PyUnicodeDecodeError_Create( encoding: *const c_char, object: *const c_char, length: Py_ssize_t, start: Py_ssize_t, end: Py_ssize_t, reason: *const c_char, ) -> *mut PyObject; pub fn PyUnicodeEncodeError_GetEncoding(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeDecodeError_GetEncoding(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeEncodeError_GetObject(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeDecodeError_GetObject(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeTranslateError_GetObject(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeEncodeError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeDecodeError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeTranslateError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeEncodeError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeDecodeError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeTranslateError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeEncodeError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeDecodeError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeTranslateError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int; pub fn PyUnicodeEncodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeDecodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeTranslateError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int; pub fn PyUnicodeEncodeError_GetReason(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeDecodeError_GetReason(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeTranslateError_GetReason(arg1: *mut PyObject) -> *mut PyObject; pub fn PyUnicodeEncodeError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int; pub fn PyUnicodeDecodeError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int; pub fn PyUnicodeTranslateError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/codecs.rs
use crate::object::PyObject; use std::os::raw::{c_char, c_int}; extern "C" { pub fn PyCodec_Register(search_function: *mut PyObject) -> c_int; #[cfg(Py_3_10)] #[cfg(not(PyPy))] pub fn PyCodec_Unregister(search_function: *mut PyObject) -> c_int; // skipped non-limited _PyCodec_Lookup from Include/codecs.h // skipped non-limited _PyCodec_Forget from Include/codecs.h pub fn PyCodec_KnownEncoding(encoding: *const c_char) -> c_int; pub fn PyCodec_Encode( object: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyCodec_Decode( object: *mut PyObject, encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; // skipped non-limited _PyCodec_LookupTextEncoding from Include/codecs.h // skipped non-limited _PyCodec_EncodeText from Include/codecs.h // skipped non-limited _PyCodec_DecodeText from Include/codecs.h // skipped non-limited _PyCodecInfo_GetIncrementalDecoder from Include/codecs.h // skipped non-limited _PyCodecInfo_GetIncrementalEncoder from Include/codecs.h pub fn PyCodec_Encoder(encoding: *const c_char) -> *mut PyObject; pub fn PyCodec_Decoder(encoding: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyCodec_IncrementalEncoder")] pub fn PyCodec_IncrementalEncoder( encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyCodec_IncrementalDecoder")] pub fn PyCodec_IncrementalDecoder( encoding: *const c_char, errors: *const c_char, ) -> *mut PyObject; pub fn PyCodec_StreamReader( encoding: *const c_char, stream: *mut PyObject, errors: *const c_char, ) -> *mut PyObject; pub fn PyCodec_StreamWriter( encoding: *const c_char, stream: *mut PyObject, errors: *const c_char, ) -> *mut PyObject; pub fn PyCodec_RegisterError(name: *const c_char, error: *mut PyObject) -> c_int; pub fn PyCodec_LookupError(name: *const c_char) -> *mut PyObject; pub fn PyCodec_StrictErrors(exc: *mut PyObject) -> *mut PyObject; pub fn PyCodec_IgnoreErrors(exc: *mut PyObject) -> *mut PyObject; pub fn PyCodec_ReplaceErrors(exc: *mut PyObject) -> *mut PyObject; pub fn PyCodec_XMLCharRefReplaceErrors(exc: *mut PyObject) -> *mut PyObject; pub fn PyCodec_BackslashReplaceErrors(exc: *mut PyObject) -> *mut PyObject; // skipped non-limited PyCodec_NameReplaceErrors from Include/codecs.h // skipped non-limited Py_hexdigits from Include/codecs.h }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/abstract_.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[inline] #[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h pub unsafe fn PyObject_DelAttrString(o: *mut PyObject, attr_name: *const c_char) -> c_int { PyObject_SetAttrString(o, attr_name, std::ptr::null_mut()) } #[inline] #[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_int { PyObject_SetAttr(o, attr_name, std::ptr::null_mut()) } extern "C" { #[cfg(all( not(PyPy), not(GraalPy), any(Py_3_10, all(not(Py_LIMITED_API), Py_3_9)) // Added to python in 3.9 but to limited API in 3.10 ))] #[cfg_attr(PyPy, link_name = "PyPyObject_CallNoArgs")] pub fn PyObject_CallNoArgs(func: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_Call")] pub fn PyObject_Call( callable_object: *mut PyObject, args: *mut PyObject, kw: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_CallObject")] pub fn PyObject_CallObject( callable_object: *mut PyObject, args: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_CallFunction")] pub fn PyObject_CallFunction( callable_object: *mut PyObject, format: *const c_char, ... ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_CallMethod")] pub fn PyObject_CallMethod( o: *mut PyObject, method: *const c_char, format: *const c_char, ... ) -> *mut PyObject; #[cfg(not(Py_3_13))] #[cfg_attr(PyPy, link_name = "_PyPyObject_CallFunction_SizeT")] pub fn _PyObject_CallFunction_SizeT( callable_object: *mut PyObject, format: *const c_char, ... ) -> *mut PyObject; #[cfg(not(Py_3_13))] #[cfg_attr(PyPy, link_name = "_PyPyObject_CallMethod_SizeT")] pub fn _PyObject_CallMethod_SizeT( o: *mut PyObject, method: *const c_char, format: *const c_char, ... ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_CallFunctionObjArgs")] pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_CallMethodObjArgs")] pub fn PyObject_CallMethodObjArgs( o: *mut PyObject, method: *mut PyObject, ... ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_Type")] pub fn PyObject_Type(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_Size")] pub fn PyObject_Size(o: *mut PyObject) -> Py_ssize_t; } #[inline] pub unsafe fn PyObject_Length(o: *mut PyObject) -> Py_ssize_t { PyObject_Size(o) } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyObject_GetItem")] pub fn PyObject_GetItem(o: *mut PyObject, key: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_SetItem")] pub fn PyObject_SetItem(o: *mut PyObject, key: *mut PyObject, v: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_DelItemString")] pub fn PyObject_DelItemString(o: *mut PyObject, key: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_DelItem")] pub fn PyObject_DelItem(o: *mut PyObject, key: *mut PyObject) -> c_int; } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyObject_Format")] pub fn PyObject_Format(obj: *mut PyObject, format_spec: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_GetIter")] pub fn PyObject_GetIter(arg1: *mut PyObject) -> *mut PyObject; } // Before 3.8 PyIter_Check was defined in CPython as a macro, // but the implementation of that in PyO3 did not work, see // https://github.com/PyO3/pyo3/pull/2914 // // This is a slow implementation which should function equivalently. #[cfg(not(any(Py_3_8, PyPy)))] #[inline] pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int { crate::PyObject_HasAttrString(crate::Py_TYPE(o).cast(), c_str!("__next__").as_ptr()) } extern "C" { #[cfg(any(Py_3_8, PyPy))] #[cfg_attr(PyPy, link_name = "PyPyIter_Check")] pub fn PyIter_Check(obj: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyIter_Next")] pub fn PyIter_Next(arg1: *mut PyObject) -> *mut PyObject; #[cfg(all(not(PyPy), Py_3_10))] #[cfg_attr(PyPy, link_name = "PyPyIter_Send")] pub fn PyIter_Send(iter: *mut PyObject, arg: *mut PyObject, presult: *mut *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyNumber_Check")] pub fn PyNumber_Check(o: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyNumber_Add")] pub fn PyNumber_Add(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Subtract")] pub fn PyNumber_Subtract(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Multiply")] pub fn PyNumber_Multiply(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_MatrixMultiply")] pub fn PyNumber_MatrixMultiply(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_FloorDivide")] pub fn PyNumber_FloorDivide(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_TrueDivide")] pub fn PyNumber_TrueDivide(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Remainder")] pub fn PyNumber_Remainder(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Divmod")] pub fn PyNumber_Divmod(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Power")] pub fn PyNumber_Power(o1: *mut PyObject, o2: *mut PyObject, o3: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Negative")] pub fn PyNumber_Negative(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Positive")] pub fn PyNumber_Positive(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Absolute")] pub fn PyNumber_Absolute(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Invert")] pub fn PyNumber_Invert(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Lshift")] pub fn PyNumber_Lshift(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Rshift")] pub fn PyNumber_Rshift(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_And")] pub fn PyNumber_And(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Xor")] pub fn PyNumber_Xor(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Or")] pub fn PyNumber_Or(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; } // Defined as this macro in Python limited API, but relies on // non-limited PyTypeObject. Don't expose this since it cannot be used. #[cfg(not(any(Py_LIMITED_API, PyPy)))] #[inline] pub unsafe fn PyIndex_Check(o: *mut PyObject) -> c_int { let tp_as_number = (*Py_TYPE(o)).tp_as_number; (!tp_as_number.is_null() && (*tp_as_number).nb_index.is_some()) as c_int } extern "C" { #[cfg(any(all(Py_3_8, Py_LIMITED_API), PyPy))] #[link_name = "PyPyIndex_Check"] pub fn PyIndex_Check(o: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyNumber_Index")] pub fn PyNumber_Index(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_AsSsize_t")] pub fn PyNumber_AsSsize_t(o: *mut PyObject, exc: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyNumber_Long")] pub fn PyNumber_Long(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_Float")] pub fn PyNumber_Float(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceAdd")] pub fn PyNumber_InPlaceAdd(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceSubtract")] pub fn PyNumber_InPlaceSubtract(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceMultiply")] pub fn PyNumber_InPlaceMultiply(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceMatrixMultiply")] pub fn PyNumber_InPlaceMatrixMultiply(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceFloorDivide")] pub fn PyNumber_InPlaceFloorDivide(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceTrueDivide")] pub fn PyNumber_InPlaceTrueDivide(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceRemainder")] pub fn PyNumber_InPlaceRemainder(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlacePower")] pub fn PyNumber_InPlacePower( o1: *mut PyObject, o2: *mut PyObject, o3: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceLshift")] pub fn PyNumber_InPlaceLshift(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceRshift")] pub fn PyNumber_InPlaceRshift(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceAnd")] pub fn PyNumber_InPlaceAnd(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceXor")] pub fn PyNumber_InPlaceXor(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyNumber_InPlaceOr")] pub fn PyNumber_InPlaceOr(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; pub fn PyNumber_ToBase(n: *mut PyObject, base: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_Check")] pub fn PySequence_Check(o: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySequence_Size")] pub fn PySequence_Size(o: *mut PyObject) -> Py_ssize_t; #[cfg(PyPy)] #[link_name = "PyPySequence_Length"] pub fn PySequence_Length(o: *mut PyObject) -> Py_ssize_t; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PySequence_Length(o: *mut PyObject) -> Py_ssize_t { PySequence_Size(o) } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySequence_Concat")] pub fn PySequence_Concat(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_Repeat")] pub fn PySequence_Repeat(o: *mut PyObject, count: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_GetItem")] pub fn PySequence_GetItem(o: *mut PyObject, i: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_GetSlice")] pub fn PySequence_GetSlice(o: *mut PyObject, i1: Py_ssize_t, i2: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_SetItem")] pub fn PySequence_SetItem(o: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySequence_DelItem")] pub fn PySequence_DelItem(o: *mut PyObject, i: Py_ssize_t) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySequence_SetSlice")] pub fn PySequence_SetSlice( o: *mut PyObject, i1: Py_ssize_t, i2: Py_ssize_t, v: *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySequence_DelSlice")] pub fn PySequence_DelSlice(o: *mut PyObject, i1: Py_ssize_t, i2: Py_ssize_t) -> c_int; #[cfg_attr(PyPy, link_name = "PyPySequence_Tuple")] pub fn PySequence_Tuple(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_List")] pub fn PySequence_List(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_Fast")] pub fn PySequence_Fast(o: *mut PyObject, m: *const c_char) -> *mut PyObject; // skipped PySequence_Fast_GET_SIZE // skipped PySequence_Fast_GET_ITEM // skipped PySequence_Fast_GET_ITEMS pub fn PySequence_Count(o: *mut PyObject, value: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPySequence_Contains")] pub fn PySequence_Contains(seq: *mut PyObject, ob: *mut PyObject) -> c_int; } #[inline] pub unsafe fn PySequence_In(o: *mut PyObject, value: *mut PyObject) -> c_int { PySequence_Contains(o, value) } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySequence_Index")] pub fn PySequence_Index(o: *mut PyObject, value: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPySequence_InPlaceConcat")] pub fn PySequence_InPlaceConcat(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySequence_InPlaceRepeat")] pub fn PySequence_InPlaceRepeat(o: *mut PyObject, count: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMapping_Check")] pub fn PyMapping_Check(o: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyMapping_Size")] pub fn PyMapping_Size(o: *mut PyObject) -> Py_ssize_t; #[cfg(PyPy)] #[link_name = "PyPyMapping_Length"] pub fn PyMapping_Length(o: *mut PyObject) -> Py_ssize_t; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyMapping_Length(o: *mut PyObject) -> Py_ssize_t { PyMapping_Size(o) } #[inline] pub unsafe fn PyMapping_DelItemString(o: *mut PyObject, key: *mut c_char) -> c_int { PyObject_DelItemString(o, key) } #[inline] pub unsafe fn PyMapping_DelItem(o: *mut PyObject, key: *mut PyObject) -> c_int { PyObject_DelItem(o, key) } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyMapping_HasKeyString")] pub fn PyMapping_HasKeyString(o: *mut PyObject, key: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyMapping_HasKey")] pub fn PyMapping_HasKey(o: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyMapping_Keys")] pub fn PyMapping_Keys(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMapping_Values")] pub fn PyMapping_Values(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMapping_Items")] pub fn PyMapping_Items(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMapping_GetItemString")] pub fn PyMapping_GetItemString(o: *mut PyObject, key: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyMapping_SetItemString")] pub fn PyMapping_SetItemString( o: *mut PyObject, key: *const c_char, value: *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_IsInstance")] pub fn PyObject_IsInstance(object: *mut PyObject, typeorclass: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_IsSubclass")] pub fn PyObject_IsSubclass(object: *mut PyObject, typeorclass: *mut PyObject) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/object.rs
use crate::pyport::{Py_hash_t, Py_ssize_t}; #[cfg(Py_GIL_DISABLED)] use crate::PyMutex; #[cfg(Py_GIL_DISABLED)] use std::marker::PhantomPinned; use std::mem; use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void}; use std::ptr; #[cfg(Py_GIL_DISABLED)] use std::sync::atomic::{AtomicIsize, AtomicU32, AtomicU8, Ordering::Relaxed}; #[cfg(Py_LIMITED_API)] opaque_struct!(PyTypeObject); #[cfg(not(Py_LIMITED_API))] pub use crate::cpython::object::PyTypeObject; #[cfg(Py_3_12)] const _Py_IMMORTAL_REFCNT: Py_ssize_t = { if cfg!(target_pointer_width = "64") { c_uint::MAX as Py_ssize_t } else { // for 32-bit systems, use the lower 30 bits (see comment in CPython's object.h) (c_uint::MAX >> 2) as Py_ssize_t } }; #[cfg(Py_GIL_DISABLED)] const _Py_IMMORTAL_REFCNT_LOCAL: u32 = u32::MAX; #[allow(clippy::declare_interior_mutable_const)] pub const PyObject_HEAD_INIT: PyObject = PyObject { #[cfg(py_sys_config = "Py_TRACE_REFS")] _ob_next: std::ptr::null_mut(), #[cfg(py_sys_config = "Py_TRACE_REFS")] _ob_prev: std::ptr::null_mut(), #[cfg(Py_GIL_DISABLED)] ob_tid: 0, #[cfg(Py_GIL_DISABLED)] _padding: 0, #[cfg(Py_GIL_DISABLED)] ob_mutex: PyMutex { _bits: AtomicU8::new(0), _pin: PhantomPinned, }, #[cfg(Py_GIL_DISABLED)] ob_gc_bits: 0, #[cfg(Py_GIL_DISABLED)] ob_ref_local: AtomicU32::new(_Py_IMMORTAL_REFCNT_LOCAL), #[cfg(Py_GIL_DISABLED)] ob_ref_shared: AtomicIsize::new(0), #[cfg(all(not(Py_GIL_DISABLED), Py_3_12))] ob_refcnt: PyObjectObRefcnt { ob_refcnt: 1 }, #[cfg(not(Py_3_12))] ob_refcnt: 1, #[cfg(PyPy)] ob_pypy_link: 0, ob_type: std::ptr::null_mut(), }; // skipped PyObject_VAR_HEAD // skipped Py_INVALID_SIZE // skipped private _Py_UNOWNED_TID #[cfg(Py_GIL_DISABLED)] const _Py_REF_SHARED_SHIFT: isize = 2; // skipped private _Py_REF_SHARED_FLAG_MASK // skipped private _Py_REF_SHARED_INIT // skipped private _Py_REF_MAYBE_WEAKREF // skipped private _Py_REF_QUEUED // skipped private _Py_REF_MERGED // skipped private _Py_REF_SHARED #[repr(C)] #[derive(Copy, Clone)] #[cfg(all(Py_3_12, not(Py_GIL_DISABLED)))] /// This union is anonymous in CPython, so the name was given by PyO3 because /// Rust unions need a name. pub union PyObjectObRefcnt { pub ob_refcnt: Py_ssize_t, #[cfg(target_pointer_width = "64")] pub ob_refcnt_split: [crate::PY_UINT32_T; 2], } #[cfg(all(Py_3_12, not(Py_GIL_DISABLED)))] impl std::fmt::Debug for PyObjectObRefcnt { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", unsafe { self.ob_refcnt }) } } #[cfg(all(not(Py_3_12), not(Py_GIL_DISABLED)))] pub type PyObjectObRefcnt = Py_ssize_t; #[repr(C)] #[derive(Debug)] pub struct PyObject { #[cfg(py_sys_config = "Py_TRACE_REFS")] pub _ob_next: *mut PyObject, #[cfg(py_sys_config = "Py_TRACE_REFS")] pub _ob_prev: *mut PyObject, #[cfg(Py_GIL_DISABLED)] pub ob_tid: libc::uintptr_t, #[cfg(Py_GIL_DISABLED)] pub _padding: u16, #[cfg(Py_GIL_DISABLED)] pub ob_mutex: PyMutex, // per-object lock #[cfg(Py_GIL_DISABLED)] pub ob_gc_bits: u8, // gc-related state #[cfg(Py_GIL_DISABLED)] pub ob_ref_local: AtomicU32, // local reference count #[cfg(Py_GIL_DISABLED)] pub ob_ref_shared: AtomicIsize, // shared reference count #[cfg(not(Py_GIL_DISABLED))] pub ob_refcnt: PyObjectObRefcnt, #[cfg(PyPy)] pub ob_pypy_link: Py_ssize_t, pub ob_type: *mut PyTypeObject, } // skipped private _PyObject_CAST #[repr(C)] #[derive(Debug)] pub struct PyVarObject { pub ob_base: PyObject, #[cfg(not(GraalPy))] pub ob_size: Py_ssize_t, } // skipped private _PyVarObject_CAST #[inline] #[cfg(not(all(PyPy, Py_3_10)))] #[cfg_attr(docsrs, doc(cfg(all())))] pub unsafe fn Py_Is(x: *mut PyObject, y: *mut PyObject) -> c_int { (x == y).into() } #[cfg(all(PyPy, Py_3_10))] #[cfg_attr(docsrs, doc(cfg(all())))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPy_Is")] pub fn Py_Is(x: *mut PyObject, y: *mut PyObject) -> c_int; } // skipped private _Py_GetThreadLocal_Addr // skipped private _Py_ThreadId // skipped private _Py_IsOwnedByCurrentThread #[inline] pub unsafe fn Py_REFCNT(ob: *mut PyObject) -> Py_ssize_t { #[cfg(Py_GIL_DISABLED)] { let local = (*ob).ob_ref_local.load(Relaxed); if local == _Py_IMMORTAL_REFCNT_LOCAL { return _Py_IMMORTAL_REFCNT; } let shared = (*ob).ob_ref_shared.load(Relaxed); local as Py_ssize_t + Py_ssize_t::from(shared >> _Py_REF_SHARED_SHIFT) } #[cfg(all(not(Py_GIL_DISABLED), Py_3_12))] { (*ob).ob_refcnt.ob_refcnt } #[cfg(all(not(Py_GIL_DISABLED), not(Py_3_12), not(GraalPy)))] { (*ob).ob_refcnt } #[cfg(all(not(Py_GIL_DISABLED), not(Py_3_12), GraalPy))] { _Py_REFCNT(ob) } } #[inline] pub unsafe fn Py_TYPE(ob: *mut PyObject) -> *mut PyTypeObject { #[cfg(not(GraalPy))] return (*ob).ob_type; #[cfg(GraalPy)] return _Py_TYPE(ob); } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyLong_Type")] pub static mut PyLong_Type: PyTypeObject; #[cfg_attr(PyPy, link_name = "PyPyBool_Type")] pub static mut PyBool_Type: PyTypeObject; } #[inline] pub unsafe fn Py_SIZE(ob: *mut PyObject) -> Py_ssize_t { #[cfg(not(GraalPy))] { debug_assert_ne!((*ob).ob_type, std::ptr::addr_of_mut!(crate::PyLong_Type)); debug_assert_ne!((*ob).ob_type, std::ptr::addr_of_mut!(crate::PyBool_Type)); (*ob.cast::<PyVarObject>()).ob_size } #[cfg(GraalPy)] _Py_SIZE(ob) } #[inline(always)] #[cfg(all(Py_3_12, not(Py_GIL_DISABLED)))] pub unsafe fn _Py_IsImmortal(op: *mut PyObject) -> c_int { #[cfg(target_pointer_width = "64")] { (((*op).ob_refcnt.ob_refcnt as crate::PY_INT32_T) < 0) as c_int } #[cfg(target_pointer_width = "32")] { ((*op).ob_refcnt.ob_refcnt == _Py_IMMORTAL_REFCNT) as c_int } } #[inline] pub unsafe fn Py_IS_TYPE(ob: *mut PyObject, tp: *mut PyTypeObject) -> c_int { (Py_TYPE(ob) == tp) as c_int } // skipped _Py_SetRefCnt // skipped Py_SET_REFCNT // skipped Py_SET_TYPE // skipped Py_SET_SIZE pub type unaryfunc = unsafe extern "C" fn(*mut PyObject) -> *mut PyObject; pub type binaryfunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject) -> *mut PyObject; pub type ternaryfunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> *mut PyObject; pub type inquiry = unsafe extern "C" fn(*mut PyObject) -> c_int; pub type lenfunc = unsafe extern "C" fn(*mut PyObject) -> Py_ssize_t; pub type ssizeargfunc = unsafe extern "C" fn(*mut PyObject, Py_ssize_t) -> *mut PyObject; pub type ssizessizeargfunc = unsafe extern "C" fn(*mut PyObject, Py_ssize_t, Py_ssize_t) -> *mut PyObject; pub type ssizeobjargproc = unsafe extern "C" fn(*mut PyObject, Py_ssize_t, *mut PyObject) -> c_int; pub type ssizessizeobjargproc = unsafe extern "C" fn(*mut PyObject, Py_ssize_t, Py_ssize_t, arg4: *mut PyObject) -> c_int; pub type objobjargproc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> c_int; pub type objobjproc = unsafe extern "C" fn(*mut PyObject, *mut PyObject) -> c_int; pub type visitproc = unsafe extern "C" fn(object: *mut PyObject, arg: *mut c_void) -> c_int; pub type traverseproc = unsafe extern "C" fn(slf: *mut PyObject, visit: visitproc, arg: *mut c_void) -> c_int; pub type freefunc = unsafe extern "C" fn(*mut c_void); pub type destructor = unsafe extern "C" fn(*mut PyObject); pub type getattrfunc = unsafe extern "C" fn(*mut PyObject, *mut c_char) -> *mut PyObject; pub type getattrofunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject) -> *mut PyObject; pub type setattrfunc = unsafe extern "C" fn(*mut PyObject, *mut c_char, *mut PyObject) -> c_int; pub type setattrofunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> c_int; pub type reprfunc = unsafe extern "C" fn(*mut PyObject) -> *mut PyObject; pub type hashfunc = unsafe extern "C" fn(*mut PyObject) -> Py_hash_t; pub type richcmpfunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, c_int) -> *mut PyObject; pub type getiterfunc = unsafe extern "C" fn(*mut PyObject) -> *mut PyObject; pub type iternextfunc = unsafe extern "C" fn(*mut PyObject) -> *mut PyObject; pub type descrgetfunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> *mut PyObject; pub type descrsetfunc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> c_int; pub type initproc = unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> c_int; pub type newfunc = unsafe extern "C" fn(*mut PyTypeObject, *mut PyObject, *mut PyObject) -> *mut PyObject; pub type allocfunc = unsafe extern "C" fn(*mut PyTypeObject, Py_ssize_t) -> *mut PyObject; #[cfg(Py_3_8)] pub type vectorcallfunc = unsafe extern "C" fn( callable: *mut PyObject, args: *const *mut PyObject, nargsf: libc::size_t, kwnames: *mut PyObject, ) -> *mut PyObject; #[repr(C)] #[derive(Copy, Clone)] pub struct PyType_Slot { pub slot: c_int, pub pfunc: *mut c_void, } impl Default for PyType_Slot { fn default() -> PyType_Slot { unsafe { mem::zeroed() } } } #[repr(C)] #[derive(Copy, Clone)] pub struct PyType_Spec { pub name: *const c_char, pub basicsize: c_int, pub itemsize: c_int, pub flags: c_uint, pub slots: *mut PyType_Slot, } impl Default for PyType_Spec { fn default() -> PyType_Spec { unsafe { mem::zeroed() } } } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyType_FromSpec")] pub fn PyType_FromSpec(arg1: *mut PyType_Spec) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyType_FromSpecWithBases")] pub fn PyType_FromSpecWithBases(arg1: *mut PyType_Spec, arg2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyType_GetSlot")] pub fn PyType_GetSlot(arg1: *mut PyTypeObject, arg2: c_int) -> *mut c_void; #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "PyPyType_FromModuleAndSpec")] pub fn PyType_FromModuleAndSpec( module: *mut PyObject, spec: *mut PyType_Spec, bases: *mut PyObject, ) -> *mut PyObject; #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "PyPyType_GetModule")] pub fn PyType_GetModule(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "PyPyType_GetModuleState")] pub fn PyType_GetModuleState(arg1: *mut PyTypeObject) -> *mut c_void; #[cfg(Py_3_11)] #[cfg_attr(PyPy, link_name = "PyPyType_GetName")] pub fn PyType_GetName(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg(Py_3_11)] #[cfg_attr(PyPy, link_name = "PyPyType_GetQualName")] pub fn PyType_GetQualName(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyType_GetFullyQualifiedName")] pub fn PyType_GetFullyQualifiedName(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyType_GetModuleName")] pub fn PyType_GetModuleName(arg1: *mut PyTypeObject) -> *mut PyObject; #[cfg(Py_3_12)] #[cfg_attr(PyPy, link_name = "PyPyType_FromMetaclass")] pub fn PyType_FromMetaclass( metaclass: *mut PyTypeObject, module: *mut PyObject, spec: *mut PyType_Spec, bases: *mut PyObject, ) -> *mut PyObject; #[cfg(Py_3_12)] #[cfg_attr(PyPy, link_name = "PyPyObject_GetTypeData")] pub fn PyObject_GetTypeData(obj: *mut PyObject, cls: *mut PyTypeObject) -> *mut c_void; #[cfg(Py_3_12)] #[cfg_attr(PyPy, link_name = "PyPyObject_GetTypeDataSize")] pub fn PyObject_GetTypeDataSize(cls: *mut PyTypeObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyType_IsSubtype")] pub fn PyType_IsSubtype(a: *mut PyTypeObject, b: *mut PyTypeObject) -> c_int; } #[inline] pub unsafe fn PyObject_TypeCheck(ob: *mut PyObject, tp: *mut PyTypeObject) -> c_int { (Py_IS_TYPE(ob, tp) != 0 || PyType_IsSubtype(Py_TYPE(ob), tp) != 0) as c_int } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { /// built-in 'type' #[cfg_attr(PyPy, link_name = "PyPyType_Type")] pub static mut PyType_Type: PyTypeObject; /// built-in 'object' #[cfg_attr(PyPy, link_name = "PyPyBaseObject_Type")] pub static mut PyBaseObject_Type: PyTypeObject; /// built-in 'super' pub static mut PySuper_Type: PyTypeObject; } extern "C" { pub fn PyType_GetFlags(arg1: *mut PyTypeObject) -> c_ulong; #[cfg_attr(PyPy, link_name = "PyPyType_Ready")] pub fn PyType_Ready(t: *mut PyTypeObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyType_GenericAlloc")] pub fn PyType_GenericAlloc(t: *mut PyTypeObject, nitems: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyType_GenericNew")] pub fn PyType_GenericNew( t: *mut PyTypeObject, args: *mut PyObject, kwds: *mut PyObject, ) -> *mut PyObject; pub fn PyType_ClearCache() -> c_uint; #[cfg_attr(PyPy, link_name = "PyPyType_Modified")] pub fn PyType_Modified(t: *mut PyTypeObject); #[cfg_attr(PyPy, link_name = "PyPyObject_Repr")] pub fn PyObject_Repr(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_Str")] pub fn PyObject_Str(o: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_ASCII")] pub fn PyObject_ASCII(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_Bytes")] pub fn PyObject_Bytes(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_RichCompare")] pub fn PyObject_RichCompare( arg1: *mut PyObject, arg2: *mut PyObject, arg3: c_int, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_RichCompareBool")] pub fn PyObject_RichCompareBool(arg1: *mut PyObject, arg2: *mut PyObject, arg3: c_int) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_GetAttrString")] pub fn PyObject_GetAttrString(arg1: *mut PyObject, arg2: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_SetAttrString")] pub fn PyObject_SetAttrString( arg1: *mut PyObject, arg2: *const c_char, arg3: *mut PyObject, ) -> c_int; #[cfg(any(Py_3_13, PyPy))] // CPython defined in 3.12 as an inline function in abstract.h #[cfg_attr(PyPy, link_name = "PyPyObject_DelAttrString")] pub fn PyObject_DelAttrString(arg1: *mut PyObject, arg2: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_HasAttrString")] pub fn PyObject_HasAttrString(arg1: *mut PyObject, arg2: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_GetAttr")] pub fn PyObject_GetAttr(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyObject_GetOptionalAttr")] pub fn PyObject_GetOptionalAttr( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut *mut PyObject, ) -> c_int; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyObject_GetOptionalAttrString")] pub fn PyObject_GetOptionalAttrString( arg1: *mut PyObject, arg2: *const c_char, arg3: *mut *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_SetAttr")] pub fn PyObject_SetAttr(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject) -> c_int; #[cfg(any(Py_3_13, PyPy))] // CPython defined in 3.12 as an inline function in abstract.h #[cfg_attr(PyPy, link_name = "PyPyObject_DelAttr")] pub fn PyObject_DelAttr(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_HasAttr")] pub fn PyObject_HasAttr(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyObject_HasAttrWithError")] pub fn PyObject_HasAttrWithError(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyObject_HasAttrStringWithError")] pub fn PyObject_HasAttrStringWithError(arg1: *mut PyObject, arg2: *const c_char) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_SelfIter")] pub fn PyObject_SelfIter(arg1: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_GenericGetAttr")] pub fn PyObject_GenericGetAttr(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_GenericSetAttr")] pub fn PyObject_GenericSetAttr( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject, ) -> c_int; #[cfg(not(all(Py_LIMITED_API, not(Py_3_10))))] #[cfg_attr(PyPy, link_name = "PyPyObject_GenericGetDict")] pub fn PyObject_GenericGetDict(arg1: *mut PyObject, arg2: *mut c_void) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyObject_GenericSetDict")] pub fn PyObject_GenericSetDict( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut c_void, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_Hash")] pub fn PyObject_Hash(arg1: *mut PyObject) -> Py_hash_t; #[cfg_attr(PyPy, link_name = "PyPyObject_HashNotImplemented")] pub fn PyObject_HashNotImplemented(arg1: *mut PyObject) -> Py_hash_t; #[cfg_attr(PyPy, link_name = "PyPyObject_IsTrue")] pub fn PyObject_IsTrue(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_Not")] pub fn PyObject_Not(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyCallable_Check")] pub fn PyCallable_Check(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyObject_ClearWeakRefs")] pub fn PyObject_ClearWeakRefs(arg1: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyObject_Dir")] pub fn PyObject_Dir(arg1: *mut PyObject) -> *mut PyObject; pub fn Py_ReprEnter(arg1: *mut PyObject) -> c_int; pub fn Py_ReprLeave(arg1: *mut PyObject); } // Flag bits for printing: pub const Py_PRINT_RAW: c_int = 1; // No string quotes etc. // skipped because is a private API // const _Py_TPFLAGS_STATIC_BUILTIN: c_ulong = 1 << 1; #[cfg(all(Py_3_12, not(Py_LIMITED_API)))] pub const Py_TPFLAGS_MANAGED_WEAKREF: c_ulong = 1 << 3; #[cfg(all(Py_3_11, not(Py_LIMITED_API)))] pub const Py_TPFLAGS_MANAGED_DICT: c_ulong = 1 << 4; #[cfg(all(Py_3_10, not(Py_LIMITED_API)))] pub const Py_TPFLAGS_SEQUENCE: c_ulong = 1 << 5; #[cfg(all(Py_3_10, not(Py_LIMITED_API)))] pub const Py_TPFLAGS_MAPPING: c_ulong = 1 << 6; #[cfg(Py_3_10)] pub const Py_TPFLAGS_DISALLOW_INSTANTIATION: c_ulong = 1 << 7; #[cfg(Py_3_10)] pub const Py_TPFLAGS_IMMUTABLETYPE: c_ulong = 1 << 8; /// Set if the type object is dynamically allocated pub const Py_TPFLAGS_HEAPTYPE: c_ulong = 1 << 9; /// Set if the type allows subclassing pub const Py_TPFLAGS_BASETYPE: c_ulong = 1 << 10; /// Set if the type implements the vectorcall protocol (PEP 590) #[cfg(any(Py_3_12, all(Py_3_8, not(Py_LIMITED_API))))] pub const Py_TPFLAGS_HAVE_VECTORCALL: c_ulong = 1 << 11; // skipped backwards-compatibility alias _Py_TPFLAGS_HAVE_VECTORCALL /// Set if the type is 'ready' -- fully initialized pub const Py_TPFLAGS_READY: c_ulong = 1 << 12; /// Set while the type is being 'readied', to prevent recursive ready calls pub const Py_TPFLAGS_READYING: c_ulong = 1 << 13; /// Objects support garbage collection (see objimp.h) pub const Py_TPFLAGS_HAVE_GC: c_ulong = 1 << 14; const Py_TPFLAGS_HAVE_STACKLESS_EXTENSION: c_ulong = 0; #[cfg(Py_3_8)] pub const Py_TPFLAGS_METHOD_DESCRIPTOR: c_ulong = 1 << 17; pub const Py_TPFLAGS_VALID_VERSION_TAG: c_ulong = 1 << 19; /* Type is abstract and cannot be instantiated */ pub const Py_TPFLAGS_IS_ABSTRACT: c_ulong = 1 << 20; // skipped non-limited / 3.10 Py_TPFLAGS_HAVE_AM_SEND #[cfg(Py_3_12)] pub const Py_TPFLAGS_ITEMS_AT_END: c_ulong = 1 << 23; /* These flags are used to determine if a type is a subclass. */ pub const Py_TPFLAGS_LONG_SUBCLASS: c_ulong = 1 << 24; pub const Py_TPFLAGS_LIST_SUBCLASS: c_ulong = 1 << 25; pub const Py_TPFLAGS_TUPLE_SUBCLASS: c_ulong = 1 << 26; pub const Py_TPFLAGS_BYTES_SUBCLASS: c_ulong = 1 << 27; pub const Py_TPFLAGS_UNICODE_SUBCLASS: c_ulong = 1 << 28; pub const Py_TPFLAGS_DICT_SUBCLASS: c_ulong = 1 << 29; pub const Py_TPFLAGS_BASE_EXC_SUBCLASS: c_ulong = 1 << 30; pub const Py_TPFLAGS_TYPE_SUBCLASS: c_ulong = 1 << 31; pub const Py_TPFLAGS_DEFAULT: c_ulong = if cfg!(Py_3_10) { Py_TPFLAGS_HAVE_STACKLESS_EXTENSION } else { Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | Py_TPFLAGS_HAVE_VERSION_TAG }; pub const Py_TPFLAGS_HAVE_FINALIZE: c_ulong = 1; pub const Py_TPFLAGS_HAVE_VERSION_TAG: c_ulong = 1 << 18; extern "C" { #[cfg(all(py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] fn _Py_NegativeRefcount(filename: *const c_char, lineno: c_int, op: *mut PyObject); #[cfg(all(Py_3_12, py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] fn _Py_INCREF_IncRefTotal(); #[cfg(all(Py_3_12, py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] fn _Py_DECREF_DecRefTotal(); #[cfg_attr(PyPy, link_name = "_PyPy_Dealloc")] fn _Py_Dealloc(arg1: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPy_IncRef")] #[cfg_attr(GraalPy, link_name = "_Py_IncRef")] pub fn Py_IncRef(o: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPy_DecRef")] #[cfg_attr(GraalPy, link_name = "_Py_DecRef")] pub fn Py_DecRef(o: *mut PyObject); #[cfg(all(Py_3_10, not(PyPy)))] fn _Py_IncRef(o: *mut PyObject); #[cfg(all(Py_3_10, not(PyPy)))] fn _Py_DecRef(o: *mut PyObject); #[cfg(GraalPy)] fn _Py_REFCNT(arg1: *const PyObject) -> Py_ssize_t; #[cfg(GraalPy)] fn _Py_TYPE(arg1: *const PyObject) -> *mut PyTypeObject; #[cfg(GraalPy)] fn _Py_SIZE(arg1: *const PyObject) -> Py_ssize_t; } #[inline(always)] pub unsafe fn Py_INCREF(op: *mut PyObject) { // On limited API, the free-threaded build, or with refcount debugging, let the interpreter do refcounting // TODO: reimplement the logic in the header in the free-threaded build, for a little bit of performance. #[cfg(any( Py_GIL_DISABLED, Py_LIMITED_API, py_sys_config = "Py_REF_DEBUG", GraalPy ))] { // _Py_IncRef was added to the ABI in 3.10; skips null checks #[cfg(all(Py_3_10, not(PyPy)))] { _Py_IncRef(op); } #[cfg(any(not(Py_3_10), PyPy))] { Py_IncRef(op); } } // version-specific builds are allowed to directly manipulate the reference count #[cfg(not(any( Py_GIL_DISABLED, Py_LIMITED_API, py_sys_config = "Py_REF_DEBUG", GraalPy )))] { #[cfg(all(Py_3_12, target_pointer_width = "64"))] { let cur_refcnt = (*op).ob_refcnt.ob_refcnt_split[crate::PY_BIG_ENDIAN]; let new_refcnt = cur_refcnt.wrapping_add(1); if new_refcnt == 0 { return; } (*op).ob_refcnt.ob_refcnt_split[crate::PY_BIG_ENDIAN] = new_refcnt; } #[cfg(all(Py_3_12, target_pointer_width = "32"))] { if _Py_IsImmortal(op) != 0 { return; } (*op).ob_refcnt.ob_refcnt += 1 } #[cfg(not(Py_3_12))] { (*op).ob_refcnt += 1 } // Skipped _Py_INCREF_STAT_INC - if anyone wants this, please file an issue // or submit a PR supporting Py_STATS build option and pystats.h } } #[inline(always)] #[cfg_attr( all(py_sys_config = "Py_REF_DEBUG", Py_3_12, not(Py_LIMITED_API)), track_caller )] pub unsafe fn Py_DECREF(op: *mut PyObject) { // On limited API, the free-threaded build, or with refcount debugging, let the interpreter do refcounting // On 3.12+ we implement refcount debugging to get better assertion locations on negative refcounts // TODO: reimplement the logic in the header in the free-threaded build, for a little bit of performance. #[cfg(any( Py_GIL_DISABLED, Py_LIMITED_API, all(py_sys_config = "Py_REF_DEBUG", not(Py_3_12)), GraalPy ))] { // _Py_DecRef was added to the ABI in 3.10; skips null checks #[cfg(all(Py_3_10, not(PyPy)))] { _Py_DecRef(op); } #[cfg(any(not(Py_3_10), PyPy))] { Py_DecRef(op); } } #[cfg(not(any( Py_GIL_DISABLED, Py_LIMITED_API, all(py_sys_config = "Py_REF_DEBUG", not(Py_3_12)), GraalPy )))] { #[cfg(Py_3_12)] if _Py_IsImmortal(op) != 0 { return; } // Skipped _Py_DECREF_STAT_INC - if anyone needs this, please file an issue // or submit a PR supporting Py_STATS build option and pystats.h #[cfg(py_sys_config = "Py_REF_DEBUG")] _Py_DECREF_DecRefTotal(); #[cfg(Py_3_12)] { (*op).ob_refcnt.ob_refcnt -= 1; #[cfg(py_sys_config = "Py_REF_DEBUG")] if (*op).ob_refcnt.ob_refcnt < 0 { let location = std::panic::Location::caller(); let filename = std::ffi::CString::new(location.file()).unwrap(); _Py_NegativeRefcount(filename.as_ptr(), location.line() as i32, op); } if (*op).ob_refcnt.ob_refcnt == 0 { _Py_Dealloc(op); } } #[cfg(not(Py_3_12))] { (*op).ob_refcnt -= 1; if (*op).ob_refcnt == 0 { _Py_Dealloc(op); } } } } #[inline] pub unsafe fn Py_CLEAR(op: *mut *mut PyObject) { let tmp = *op; if !tmp.is_null() { *op = ptr::null_mut(); Py_DECREF(tmp); } } #[inline] pub unsafe fn Py_XINCREF(op: *mut PyObject) { if !op.is_null() { Py_INCREF(op) } } #[inline] pub unsafe fn Py_XDECREF(op: *mut PyObject) { if !op.is_null() { Py_DECREF(op) } } extern "C" { #[cfg(all(Py_3_10, Py_LIMITED_API, not(PyPy)))] #[cfg_attr(docsrs, doc(cfg(Py_3_10)))] pub fn Py_NewRef(obj: *mut PyObject) -> *mut PyObject; #[cfg(all(Py_3_10, Py_LIMITED_API, not(PyPy)))] #[cfg_attr(docsrs, doc(cfg(Py_3_10)))] pub fn Py_XNewRef(obj: *mut PyObject) -> *mut PyObject; } // macro _Py_NewRef not public; reimplemented directly inside Py_NewRef here // macro _Py_XNewRef not public; reimplemented directly inside Py_XNewRef here #[cfg(all(Py_3_10, any(not(Py_LIMITED_API), PyPy)))] #[cfg_attr(docsrs, doc(cfg(Py_3_10)))] #[inline] pub unsafe fn Py_NewRef(obj: *mut PyObject) -> *mut PyObject { Py_INCREF(obj); obj } #[cfg(all(Py_3_10, any(not(Py_LIMITED_API), PyPy)))] #[cfg_attr(docsrs, doc(cfg(Py_3_10)))] #[inline] pub unsafe fn Py_XNewRef(obj: *mut PyObject) -> *mut PyObject { Py_XINCREF(obj); obj } #[cfg(Py_3_13)] pub const Py_CONSTANT_NONE: c_uint = 0; #[cfg(Py_3_13)] pub const Py_CONSTANT_FALSE: c_uint = 1; #[cfg(Py_3_13)] pub const Py_CONSTANT_TRUE: c_uint = 2; #[cfg(Py_3_13)] pub const Py_CONSTANT_ELLIPSIS: c_uint = 3; #[cfg(Py_3_13)] pub const Py_CONSTANT_NOT_IMPLEMENTED: c_uint = 4; #[cfg(Py_3_13)] pub const Py_CONSTANT_ZERO: c_uint = 5; #[cfg(Py_3_13)] pub const Py_CONSTANT_ONE: c_uint = 6; #[cfg(Py_3_13)] pub const Py_CONSTANT_EMPTY_STR: c_uint = 7; #[cfg(Py_3_13)] pub const Py_CONSTANT_EMPTY_BYTES: c_uint = 8; #[cfg(Py_3_13)] pub const Py_CONSTANT_EMPTY_TUPLE: c_uint = 9; extern "C" { #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPy_GetConstant")] pub fn Py_GetConstant(constant_id: c_uint) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPy_GetConstantBorrowed")] pub fn Py_GetConstantBorrowed(constant_id: c_uint) -> *mut PyObject; } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg(all(not(GraalPy), not(all(Py_3_13, Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "_PyPy_NoneStruct")] static mut _Py_NoneStruct: PyObject; #[cfg(GraalPy)] static mut _Py_NoneStructReference: *mut PyObject; } #[inline] pub unsafe fn Py_None() -> *mut PyObject { #[cfg(all(not(GraalPy), all(Py_3_13, Py_LIMITED_API)))] return Py_GetConstantBorrowed(Py_CONSTANT_NONE); #[cfg(all(not(GraalPy), not(all(Py_3_13, Py_LIMITED_API))))] return ptr::addr_of_mut!(_Py_NoneStruct); #[cfg(GraalPy)] return _Py_NoneStructReference; } #[inline] pub unsafe fn Py_IsNone(x: *mut PyObject) -> c_int { Py_Is(x, Py_None()) } // skipped Py_RETURN_NONE #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg(all(not(GraalPy), not(all(Py_3_13, Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "_PyPy_NotImplementedStruct")] static mut _Py_NotImplementedStruct: PyObject; #[cfg(GraalPy)] static mut _Py_NotImplementedStructReference: *mut PyObject; } #[inline] pub unsafe fn Py_NotImplemented() -> *mut PyObject { #[cfg(all(not(GraalPy), all(Py_3_13, Py_LIMITED_API)))] return Py_GetConstantBorrowed(Py_CONSTANT_NOT_IMPLEMENTED); #[cfg(all(not(GraalPy), not(all(Py_3_13, Py_LIMITED_API))))] return ptr::addr_of_mut!(_Py_NotImplementedStruct); #[cfg(GraalPy)] return _Py_NotImplementedStructReference; } // skipped Py_RETURN_NOTIMPLEMENTED /* Rich comparison opcodes */ pub const Py_LT: c_int = 0; pub const Py_LE: c_int = 1; pub const Py_EQ: c_int = 2; pub const Py_NE: c_int = 3; pub const Py_GT: c_int = 4; pub const Py_GE: c_int = 5; #[cfg(Py_3_10)] #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum PySendResult { PYGEN_RETURN = 0, PYGEN_ERROR = -1, PYGEN_NEXT = 1, } // skipped Py_RETURN_RICHCOMPARE #[inline] pub unsafe fn PyType_HasFeature(ty: *mut PyTypeObject, feature: c_ulong) -> c_int { #[cfg(Py_LIMITED_API)] let flags = PyType_GetFlags(ty); #[cfg(all(not(Py_LIMITED_API), Py_GIL_DISABLED))] let flags = (*ty).tp_flags.load(std::sync::atomic::Ordering::Relaxed); #[cfg(all(not(Py_LIMITED_API), not(Py_GIL_DISABLED)))] let flags = (*ty).tp_flags; ((flags & feature) != 0) as c_int } #[inline] pub unsafe fn PyType_FastSubclass(t: *mut PyTypeObject, f: c_ulong) -> c_int { PyType_HasFeature(t, f) } #[inline] pub unsafe fn PyType_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) } // skipped _PyType_CAST #[inline] pub unsafe fn PyType_CheckExact(op: *mut PyObject) -> c_int { Py_IS_TYPE(op, ptr::addr_of_mut!(PyType_Type)) } extern "C" { #[cfg(any(Py_3_13, all(Py_3_11, not(Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "PyPyType_GetModuleByDef")] pub fn PyType_GetModuleByDef( arg1: *mut crate::PyTypeObject, arg2: *mut crate::PyModuleDef, ) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/osmodule.rs
use crate::object::PyObject; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyOS_FSPath")] pub fn PyOS_FSPath(path: *mut PyObject) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/dictobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyDict_Type")] pub static mut PyDict_Type: PyTypeObject; } #[inline] pub unsafe fn PyDict_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) } #[inline] pub unsafe fn PyDict_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyDict_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyDict_New")] pub fn PyDict_New() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_GetItem")] pub fn PyDict_GetItem(mp: *mut PyObject, key: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_GetItemWithError")] pub fn PyDict_GetItemWithError(mp: *mut PyObject, key: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_SetItem")] pub fn PyDict_SetItem(mp: *mut PyObject, key: *mut PyObject, item: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_DelItem")] pub fn PyDict_DelItem(mp: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Clear")] pub fn PyDict_Clear(mp: *mut PyObject); #[cfg_attr(PyPy, link_name = "PyPyDict_Next")] pub fn PyDict_Next( mp: *mut PyObject, pos: *mut Py_ssize_t, key: *mut *mut PyObject, value: *mut *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Keys")] pub fn PyDict_Keys(mp: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_Values")] pub fn PyDict_Values(mp: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_Items")] pub fn PyDict_Items(mp: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_Size")] pub fn PyDict_Size(mp: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyDict_Copy")] pub fn PyDict_Copy(mp: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_Contains")] pub fn PyDict_Contains(mp: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Update")] pub fn PyDict_Update(mp: *mut PyObject, other: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Merge")] pub fn PyDict_Merge(mp: *mut PyObject, other: *mut PyObject, _override: c_int) -> c_int; pub fn PyDict_MergeFromSeq2(d: *mut PyObject, seq2: *mut PyObject, _override: c_int) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_GetItemString")] pub fn PyDict_GetItemString(dp: *mut PyObject, key: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_SetItemString")] pub fn PyDict_SetItemString( dp: *mut PyObject, key: *const c_char, item: *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_DelItemString")] pub fn PyDict_DelItemString(dp: *mut PyObject, key: *const c_char) -> c_int; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyDict_GetItemRef")] pub fn PyDict_GetItemRef( dp: *mut PyObject, key: *mut PyObject, result: *mut *mut PyObject, ) -> c_int; // skipped 3.10 / ex-non-limited PyObject_GenericGetDict } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyDictKeys_Type: PyTypeObject; pub static mut PyDictValues_Type: PyTypeObject; pub static mut PyDictItems_Type: PyTypeObject; } #[inline] pub unsafe fn PyDictKeys_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyDictKeys_Type)) as c_int } #[inline] pub unsafe fn PyDictValues_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyDictValues_Type)) as c_int } #[inline] pub unsafe fn PyDictItems_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyDictItems_Type)) as c_int } #[inline] pub unsafe fn PyDictViewSet_Check(op: *mut PyObject) -> c_int { (PyDictKeys_Check(op) != 0 || PyDictItems_Check(op) != 0) as c_int } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyDictIterKey_Type: PyTypeObject; pub static mut PyDictIterValue_Type: PyTypeObject; pub static mut PyDictIterItem_Type: PyTypeObject; #[cfg(Py_3_8)] pub static mut PyDictRevIterKey_Type: PyTypeObject; #[cfg(Py_3_8)] pub static mut PyDictRevIterValue_Type: PyTypeObject; #[cfg(Py_3_8)] pub static mut PyDictRevIterItem_Type: PyTypeObject; } #[cfg(any(PyPy, GraalPy, Py_LIMITED_API))] // TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985) opaque_struct!(PyDictObject);
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/datetime.rs
//! FFI bindings to the functions and structs defined in `datetime.h` //! //! This is the unsafe thin wrapper around the [CPython C API](https://docs.python.org/3/c-api/datetime.html), //! and covers the various date and time related objects in the Python `datetime` //! standard library module. #[cfg(not(PyPy))] use crate::PyCapsule_Import; #[cfg(GraalPy)] use crate::{PyLong_AsLong, PyLong_Check, PyObject_GetAttrString, Py_DecRef}; use crate::{PyObject, PyObject_TypeCheck, PyTypeObject, Py_TYPE}; #[cfg(not(GraalPy))] use std::os::raw::c_char; use std::os::raw::c_int; use std::ptr; use std::sync::Once; use std::{cell::UnsafeCell, ffi::CStr}; #[cfg(not(any(PyPy, GraalPy)))] use {crate::Py_hash_t, std::os::raw::c_uchar}; // Type struct wrappers const _PyDateTime_DATE_DATASIZE: usize = 4; const _PyDateTime_TIME_DATASIZE: usize = 6; const _PyDateTime_DATETIME_DATASIZE: usize = 10; #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.timedelta`. pub struct PyDateTime_Delta { pub ob_base: PyObject, #[cfg(not(any(PyPy, GraalPy)))] pub hashcode: Py_hash_t, #[cfg(not(GraalPy))] pub days: c_int, #[cfg(not(GraalPy))] pub seconds: c_int, #[cfg(not(GraalPy))] pub microseconds: c_int, } // skipped non-limited PyDateTime_TZInfo // skipped non-limited _PyDateTime_BaseTZInfo #[cfg(not(any(PyPy, GraalPy)))] #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.time` without a `tzinfo` member. pub struct _PyDateTime_BaseTime { pub ob_base: PyObject, pub hashcode: Py_hash_t, pub hastzinfo: c_char, pub data: [c_uchar; _PyDateTime_TIME_DATASIZE], } #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.time`. pub struct PyDateTime_Time { pub ob_base: PyObject, #[cfg(not(any(PyPy, GraalPy)))] pub hashcode: Py_hash_t, #[cfg(not(GraalPy))] pub hastzinfo: c_char, #[cfg(not(any(PyPy, GraalPy)))] pub data: [c_uchar; _PyDateTime_TIME_DATASIZE], #[cfg(not(any(PyPy, GraalPy)))] pub fold: c_uchar, /// # Safety /// /// Care should be taken when reading this field. If the time does not have a /// tzinfo then CPython may allocate as a `_PyDateTime_BaseTime` without this field. #[cfg(not(GraalPy))] pub tzinfo: *mut PyObject, } #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.date` pub struct PyDateTime_Date { pub ob_base: PyObject, #[cfg(not(any(PyPy, GraalPy)))] pub hashcode: Py_hash_t, #[cfg(not(any(PyPy, GraalPy)))] pub hastzinfo: c_char, #[cfg(not(any(PyPy, GraalPy)))] pub data: [c_uchar; _PyDateTime_DATE_DATASIZE], } #[cfg(not(any(PyPy, GraalPy)))] #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.datetime` without a `tzinfo` member. pub struct _PyDateTime_BaseDateTime { pub ob_base: PyObject, pub hashcode: Py_hash_t, pub hastzinfo: c_char, pub data: [c_uchar; _PyDateTime_DATETIME_DATASIZE], } #[repr(C)] #[derive(Debug)] /// Structure representing a `datetime.datetime`. pub struct PyDateTime_DateTime { pub ob_base: PyObject, #[cfg(not(any(PyPy, GraalPy)))] pub hashcode: Py_hash_t, #[cfg(not(GraalPy))] pub hastzinfo: c_char, #[cfg(not(any(PyPy, GraalPy)))] pub data: [c_uchar; _PyDateTime_DATETIME_DATASIZE], #[cfg(not(any(PyPy, GraalPy)))] pub fold: c_uchar, /// # Safety /// /// Care should be taken when reading this field. If the time does not have a /// tzinfo then CPython may allocate as a `_PyDateTime_BaseDateTime` without this field. #[cfg(not(GraalPy))] pub tzinfo: *mut PyObject, } // skipped non-limited _PyDateTime_HAS_TZINFO // Accessor functions for PyDateTime_Date and PyDateTime_DateTime #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the year component of a `PyDateTime_Date` or `PyDateTime_DateTime`. /// Returns a signed integer greater than 0. pub unsafe fn PyDateTime_GET_YEAR(o: *mut PyObject) -> c_int { // This should work for Date or DateTime let data = (*(o as *mut PyDateTime_Date)).data; c_int::from(data[0]) << 8 | c_int::from(data[1]) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the month component of a `PyDateTime_Date` or `PyDateTime_DateTime`. /// Returns a signed integer in the range `[1, 12]`. pub unsafe fn PyDateTime_GET_MONTH(o: *mut PyObject) -> c_int { let data = (*(o as *mut PyDateTime_Date)).data; c_int::from(data[2]) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the day component of a `PyDateTime_Date` or `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[1, 31]`. pub unsafe fn PyDateTime_GET_DAY(o: *mut PyObject) -> c_int { let data = (*(o as *mut PyDateTime_Date)).data; c_int::from(data[3]) } // Accessor macros for times #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_HOUR { ($o: expr, $offset:expr) => { c_int::from((*$o).data[$offset + 0]) }; } #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_MINUTE { ($o: expr, $offset:expr) => { c_int::from((*$o).data[$offset + 1]) }; } #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_SECOND { ($o: expr, $offset:expr) => { c_int::from((*$o).data[$offset + 2]) }; } #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_MICROSECOND { ($o: expr, $offset:expr) => { (c_int::from((*$o).data[$offset + 3]) << 16) | (c_int::from((*$o).data[$offset + 4]) << 8) | (c_int::from((*$o).data[$offset + 5])) }; } #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_FOLD { ($o: expr) => { (*$o).fold }; } #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _PyDateTime_GET_TZINFO { ($o: expr) => { if (*$o).hastzinfo != 0 { (*$o).tzinfo } else { $crate::Py_None() } }; } // Accessor functions for DateTime #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the hour component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 23]` pub unsafe fn PyDateTime_DATE_GET_HOUR(o: *mut PyObject) -> c_int { _PyDateTime_GET_HOUR!((o as *mut PyDateTime_DateTime), _PyDateTime_DATE_DATASIZE) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the minute component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 59]` pub unsafe fn PyDateTime_DATE_GET_MINUTE(o: *mut PyObject) -> c_int { _PyDateTime_GET_MINUTE!((o as *mut PyDateTime_DateTime), _PyDateTime_DATE_DATASIZE) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the second component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 59]` pub unsafe fn PyDateTime_DATE_GET_SECOND(o: *mut PyObject) -> c_int { _PyDateTime_GET_SECOND!((o as *mut PyDateTime_DateTime), _PyDateTime_DATE_DATASIZE) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the microsecond component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 999999]` pub unsafe fn PyDateTime_DATE_GET_MICROSECOND(o: *mut PyObject) -> c_int { _PyDateTime_GET_MICROSECOND!((o as *mut PyDateTime_DateTime), _PyDateTime_DATE_DATASIZE) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the fold component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 1]` pub unsafe fn PyDateTime_DATE_GET_FOLD(o: *mut PyObject) -> c_uchar { _PyDateTime_GET_FOLD!(o as *mut PyDateTime_DateTime) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the tzinfo component of a `PyDateTime_DateTime`. /// Returns a pointer to a `PyObject` that should be either NULL or an instance /// of a `datetime.tzinfo` subclass. pub unsafe fn PyDateTime_DATE_GET_TZINFO(o: *mut PyObject) -> *mut PyObject { _PyDateTime_GET_TZINFO!(o as *mut PyDateTime_DateTime) } // Accessor functions for Time #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the hour component of a `PyDateTime_Time`. /// Returns a signed integer in the interval `[0, 23]` pub unsafe fn PyDateTime_TIME_GET_HOUR(o: *mut PyObject) -> c_int { _PyDateTime_GET_HOUR!((o as *mut PyDateTime_Time), 0) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the minute component of a `PyDateTime_Time`. /// Returns a signed integer in the interval `[0, 59]` pub unsafe fn PyDateTime_TIME_GET_MINUTE(o: *mut PyObject) -> c_int { _PyDateTime_GET_MINUTE!((o as *mut PyDateTime_Time), 0) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the second component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 59]` pub unsafe fn PyDateTime_TIME_GET_SECOND(o: *mut PyObject) -> c_int { _PyDateTime_GET_SECOND!((o as *mut PyDateTime_Time), 0) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the microsecond component of a `PyDateTime_DateTime`. /// Returns a signed integer in the interval `[0, 999999]` pub unsafe fn PyDateTime_TIME_GET_MICROSECOND(o: *mut PyObject) -> c_int { _PyDateTime_GET_MICROSECOND!((o as *mut PyDateTime_Time), 0) } #[cfg(not(any(PyPy, GraalPy)))] #[inline] /// Retrieve the fold component of a `PyDateTime_Time`. /// Returns a signed integer in the interval `[0, 1]` pub unsafe fn PyDateTime_TIME_GET_FOLD(o: *mut PyObject) -> c_uchar { _PyDateTime_GET_FOLD!(o as *mut PyDateTime_Time) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the tzinfo component of a `PyDateTime_Time`. /// Returns a pointer to a `PyObject` that should be either NULL or an instance /// of a `datetime.tzinfo` subclass. pub unsafe fn PyDateTime_TIME_GET_TZINFO(o: *mut PyObject) -> *mut PyObject { _PyDateTime_GET_TZINFO!(o as *mut PyDateTime_Time) } // Accessor functions #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _access_field { ($obj:expr, $type: ident, $field:ident) => { (*($obj as *mut $type)).$field }; } // Accessor functions for PyDateTime_Delta #[cfg(not(any(PyPy, GraalPy)))] macro_rules! _access_delta_field { ($obj:expr, $field:ident) => { _access_field!($obj, PyDateTime_Delta, $field) }; } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the days component of a `PyDateTime_Delta`. /// /// Returns a signed integer in the interval [-999999999, 999999999]. /// /// Note: This retrieves a component from the underlying structure, it is *not* /// a representation of the total duration of the structure. pub unsafe fn PyDateTime_DELTA_GET_DAYS(o: *mut PyObject) -> c_int { _access_delta_field!(o, days) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the seconds component of a `PyDateTime_Delta`. /// /// Returns a signed integer in the interval [0, 86399]. /// /// Note: This retrieves a component from the underlying structure, it is *not* /// a representation of the total duration of the structure. pub unsafe fn PyDateTime_DELTA_GET_SECONDS(o: *mut PyObject) -> c_int { _access_delta_field!(o, seconds) } #[inline] #[cfg(not(any(PyPy, GraalPy)))] /// Retrieve the seconds component of a `PyDateTime_Delta`. /// /// Returns a signed integer in the interval [0, 999999]. /// /// Note: This retrieves a component from the underlying structure, it is *not* /// a representation of the total duration of the structure. pub unsafe fn PyDateTime_DELTA_GET_MICROSECONDS(o: *mut PyObject) -> c_int { _access_delta_field!(o, microseconds) } // Accessor functions for GraalPy. The macros on GraalPy work differently, // but copying them seems suboptimal #[inline] #[cfg(GraalPy)] pub unsafe fn _get_attr(obj: *mut PyObject, field: &std::ffi::CStr) -> c_int { let result = PyObject_GetAttrString(obj, field.as_ptr()); Py_DecRef(result); // the original macros are borrowing if PyLong_Check(result) == 1 { PyLong_AsLong(result) as c_int } else { 0 } } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_GET_YEAR(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("year")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_GET_MONTH(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("month")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_GET_DAY(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("day")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_HOUR(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("hour")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_MINUTE(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("minute")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_SECOND(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("second")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_MICROSECOND(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("microsecond")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_FOLD(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("fold")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DATE_GET_TZINFO(o: *mut PyObject) -> *mut PyObject { let res = PyObject_GetAttrString(o, c_str!("tzinfo").as_ptr().cast()); Py_DecRef(res); // the original macros are borrowing res } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_HOUR(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("hour")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_MINUTE(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("minute")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_SECOND(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("second")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_MICROSECOND(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("microsecond")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_FOLD(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("fold")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_TIME_GET_TZINFO(o: *mut PyObject) -> *mut PyObject { let res = PyObject_GetAttrString(o, c_str!("tzinfo").as_ptr().cast()); Py_DecRef(res); // the original macros are borrowing res } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DELTA_GET_DAYS(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("days")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DELTA_GET_SECONDS(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("seconds")) } #[inline] #[cfg(GraalPy)] pub unsafe fn PyDateTime_DELTA_GET_MICROSECONDS(o: *mut PyObject) -> c_int { _get_attr(o, c_str!("microseconds")) } #[cfg(PyPy)] extern "C" { // skipped _PyDateTime_HAS_TZINFO (not in PyPy) #[link_name = "PyPyDateTime_GET_YEAR"] pub fn PyDateTime_GET_YEAR(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_GET_MONTH"] pub fn PyDateTime_GET_MONTH(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_GET_DAY"] pub fn PyDateTime_GET_DAY(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DATE_GET_HOUR"] pub fn PyDateTime_DATE_GET_HOUR(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DATE_GET_MINUTE"] pub fn PyDateTime_DATE_GET_MINUTE(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DATE_GET_SECOND"] pub fn PyDateTime_DATE_GET_SECOND(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DATE_GET_MICROSECOND"] pub fn PyDateTime_DATE_GET_MICROSECOND(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_GET_FOLD"] pub fn PyDateTime_DATE_GET_FOLD(o: *mut PyObject) -> c_int; // skipped PyDateTime_DATE_GET_TZINFO (not in PyPy) #[link_name = "PyPyDateTime_TIME_GET_HOUR"] pub fn PyDateTime_TIME_GET_HOUR(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_TIME_GET_MINUTE"] pub fn PyDateTime_TIME_GET_MINUTE(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_TIME_GET_SECOND"] pub fn PyDateTime_TIME_GET_SECOND(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_TIME_GET_MICROSECOND"] pub fn PyDateTime_TIME_GET_MICROSECOND(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_TIME_GET_FOLD"] pub fn PyDateTime_TIME_GET_FOLD(o: *mut PyObject) -> c_int; // skipped PyDateTime_TIME_GET_TZINFO (not in PyPy) #[link_name = "PyPyDateTime_DELTA_GET_DAYS"] pub fn PyDateTime_DELTA_GET_DAYS(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DELTA_GET_SECONDS"] pub fn PyDateTime_DELTA_GET_SECONDS(o: *mut PyObject) -> c_int; #[link_name = "PyPyDateTime_DELTA_GET_MICROSECONDS"] pub fn PyDateTime_DELTA_GET_MICROSECONDS(o: *mut PyObject) -> c_int; } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct PyDateTime_CAPI { pub DateType: *mut PyTypeObject, pub DateTimeType: *mut PyTypeObject, pub TimeType: *mut PyTypeObject, pub DeltaType: *mut PyTypeObject, pub TZInfoType: *mut PyTypeObject, pub TimeZone_UTC: *mut PyObject, pub Date_FromDate: unsafe extern "C" fn( year: c_int, month: c_int, day: c_int, cls: *mut PyTypeObject, ) -> *mut PyObject, pub DateTime_FromDateAndTime: unsafe extern "C" fn( year: c_int, month: c_int, day: c_int, hour: c_int, minute: c_int, second: c_int, microsecond: c_int, tzinfo: *mut PyObject, cls: *mut PyTypeObject, ) -> *mut PyObject, pub Time_FromTime: unsafe extern "C" fn( hour: c_int, minute: c_int, second: c_int, microsecond: c_int, tzinfo: *mut PyObject, cls: *mut PyTypeObject, ) -> *mut PyObject, pub Delta_FromDelta: unsafe extern "C" fn( days: c_int, seconds: c_int, microseconds: c_int, normalize: c_int, cls: *mut PyTypeObject, ) -> *mut PyObject, pub TimeZone_FromTimeZone: unsafe extern "C" fn(offset: *mut PyObject, name: *mut PyObject) -> *mut PyObject, pub DateTime_FromTimestamp: unsafe extern "C" fn( cls: *mut PyTypeObject, args: *mut PyObject, kwargs: *mut PyObject, ) -> *mut PyObject, pub Date_FromTimestamp: unsafe extern "C" fn(cls: *mut PyTypeObject, args: *mut PyObject) -> *mut PyObject, pub DateTime_FromDateAndTimeAndFold: unsafe extern "C" fn( year: c_int, month: c_int, day: c_int, hour: c_int, minute: c_int, second: c_int, microsecond: c_int, tzinfo: *mut PyObject, fold: c_int, cls: *mut PyTypeObject, ) -> *mut PyObject, pub Time_FromTimeAndFold: unsafe extern "C" fn( hour: c_int, minute: c_int, second: c_int, microsecond: c_int, tzinfo: *mut PyObject, fold: c_int, cls: *mut PyTypeObject, ) -> *mut PyObject, } // Python already shares this object between threads, so it's no more evil for us to do it too! unsafe impl Sync for PyDateTime_CAPI {} pub const PyDateTime_CAPSULE_NAME: &CStr = c_str!("datetime.datetime_CAPI"); /// Returns a pointer to a `PyDateTime_CAPI` instance /// /// # Note /// This function will return a null pointer until /// `PyDateTime_IMPORT` is called #[inline] pub unsafe fn PyDateTimeAPI() -> *mut PyDateTime_CAPI { *PyDateTimeAPI_impl.ptr.get() } /// Populates the `PyDateTimeAPI` object pub unsafe fn PyDateTime_IMPORT() { if !PyDateTimeAPI_impl.once.is_completed() { // PyPy expects the C-API to be initialized via PyDateTime_Import, so trying to use // `PyCapsule_Import` will behave unexpectedly in pypy. #[cfg(PyPy)] let py_datetime_c_api = PyDateTime_Import(); #[cfg(not(PyPy))] let py_datetime_c_api = PyCapsule_Import(PyDateTime_CAPSULE_NAME.as_ptr(), 1) as *mut PyDateTime_CAPI; if py_datetime_c_api.is_null() { return; } // Protect against race conditions when the datetime API is concurrently // initialized in multiple threads. UnsafeCell.get() cannot panic so this // won't panic either. PyDateTimeAPI_impl.once.call_once(|| { *PyDateTimeAPI_impl.ptr.get() = py_datetime_c_api; }); } } #[inline] pub unsafe fn PyDateTime_TimeZone_UTC() -> *mut PyObject { (*PyDateTimeAPI()).TimeZone_UTC } /// Type Check macros /// /// These are bindings around the C API typecheck macros, all of them return /// `1` if True and `0` if False. In all type check macros, the argument (`op`) /// must not be `NULL`. #[inline] /// Check if `op` is a `PyDateTimeAPI.DateType` or subtype. pub unsafe fn PyDate_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, (*PyDateTimeAPI()).DateType) as c_int } #[inline] /// Check if `op`'s type is exactly `PyDateTimeAPI.DateType`. pub unsafe fn PyDate_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == (*PyDateTimeAPI()).DateType) as c_int } #[inline] /// Check if `op` is a `PyDateTimeAPI.DateTimeType` or subtype. pub unsafe fn PyDateTime_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, (*PyDateTimeAPI()).DateTimeType) as c_int } #[inline] /// Check if `op`'s type is exactly `PyDateTimeAPI.DateTimeType`. pub unsafe fn PyDateTime_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == (*PyDateTimeAPI()).DateTimeType) as c_int } #[inline] /// Check if `op` is a `PyDateTimeAPI.TimeType` or subtype. pub unsafe fn PyTime_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, (*PyDateTimeAPI()).TimeType) as c_int } #[inline] /// Check if `op`'s type is exactly `PyDateTimeAPI.TimeType`. pub unsafe fn PyTime_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == (*PyDateTimeAPI()).TimeType) as c_int } #[inline] /// Check if `op` is a `PyDateTimeAPI.DetaType` or subtype. pub unsafe fn PyDelta_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, (*PyDateTimeAPI()).DeltaType) as c_int } #[inline] /// Check if `op`'s type is exactly `PyDateTimeAPI.DeltaType`. pub unsafe fn PyDelta_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == (*PyDateTimeAPI()).DeltaType) as c_int } #[inline] /// Check if `op` is a `PyDateTimeAPI.TZInfoType` or subtype. pub unsafe fn PyTZInfo_Check(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, (*PyDateTimeAPI()).TZInfoType) as c_int } #[inline] /// Check if `op`'s type is exactly `PyDateTimeAPI.TZInfoType`. pub unsafe fn PyTZInfo_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == (*PyDateTimeAPI()).TZInfoType) as c_int } // skipped non-limited PyDate_FromDate // skipped non-limited PyDateTime_FromDateAndTime // skipped non-limited PyDateTime_FromDateAndTimeAndFold // skipped non-limited PyTime_FromTime // skipped non-limited PyTime_FromTimeAndFold // skipped non-limited PyDelta_FromDSU pub unsafe fn PyTimeZone_FromOffset(offset: *mut PyObject) -> *mut PyObject { ((*PyDateTimeAPI()).TimeZone_FromTimeZone)(offset, std::ptr::null_mut()) } pub unsafe fn PyTimeZone_FromOffsetAndName( offset: *mut PyObject, name: *mut PyObject, ) -> *mut PyObject { ((*PyDateTimeAPI()).TimeZone_FromTimeZone)(offset, name) } #[cfg(not(PyPy))] pub unsafe fn PyDateTime_FromTimestamp(args: *mut PyObject) -> *mut PyObject { let f = (*PyDateTimeAPI()).DateTime_FromTimestamp; f((*PyDateTimeAPI()).DateTimeType, args, std::ptr::null_mut()) } #[cfg(not(PyPy))] pub unsafe fn PyDate_FromTimestamp(args: *mut PyObject) -> *mut PyObject { let f = (*PyDateTimeAPI()).Date_FromTimestamp; f((*PyDateTimeAPI()).DateType, args) } #[cfg(PyPy)] extern "C" { #[link_name = "PyPyDate_FromTimestamp"] pub fn PyDate_FromTimestamp(args: *mut PyObject) -> *mut PyObject; #[link_name = "PyPyDateTime_FromTimestamp"] pub fn PyDateTime_FromTimestamp(args: *mut PyObject) -> *mut PyObject; } #[cfg(PyPy)] extern "C" { #[link_name = "_PyPyDateTime_Import"] pub fn PyDateTime_Import() -> *mut PyDateTime_CAPI; } // Rust specific implementation details struct PyDateTimeAPISingleton { once: Once, ptr: UnsafeCell<*mut PyDateTime_CAPI>, } unsafe impl Sync for PyDateTimeAPISingleton {} static PyDateTimeAPI_impl: PyDateTimeAPISingleton = PyDateTimeAPISingleton { once: Once::new(), ptr: UnsafeCell::new(ptr::null_mut()), };
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/bltinmodule.rs
use crate::object::PyTypeObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyFilter_Type: PyTypeObject; pub static mut PyMap_Type: PyTypeObject; pub static mut PyZip_Type: PyTypeObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/warnings.rs
use crate::object::PyObject; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyErr_WarnEx")] pub fn PyErr_WarnEx( category: *mut PyObject, message: *const c_char, stack_level: Py_ssize_t, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyErr_WarnFormat")] pub fn PyErr_WarnFormat( category: *mut PyObject, stack_level: Py_ssize_t, format: *const c_char, ... ) -> c_int; pub fn PyErr_ResourceWarning( source: *mut PyObject, stack_level: Py_ssize_t, format: *const c_char, ... ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyErr_WarnExplicit")] pub fn PyErr_WarnExplicit( category: *mut PyObject, message: *const c_char, filename: *const c_char, lineno: c_int, module: *const c_char, registry: *mut PyObject, ) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/lib.rs
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] //! Raw FFI declarations for Python's C API. //! //! PyO3 can be used to write native Python modules or run Python code and modules from Rust. //! //! This crate just provides low level bindings to the Python interpreter. //! It is meant for advanced users only - regular PyO3 users shouldn't //! need to interact with this crate at all. //! //! The contents of this crate are not documented here, as it would entail //! basically copying the documentation from CPython. Consult the [Python/C API Reference //! Manual][capi] for up-to-date documentation. //! //! # Safety //! //! The functions in this crate lack individual safety documentation, but //! generally the following apply: //! - Pointer arguments have to point to a valid Python object of the correct type, //! although null pointers are sometimes valid input. //! - The vast majority can only be used safely while the GIL is held. //! - Some functions have additional safety requirements, consult the //! [Python/C API Reference Manual][capi] //! for more information. //! //! //! # Feature flags //! //! PyO3 uses [feature flags] to enable you to opt-in to additional functionality. For a detailed //! description, see the [Features chapter of the guide]. //! //! ## Optional feature flags //! //! The following features customize PyO3's behavior: //! //! - `abi3`: Restricts PyO3's API to a subset of the full Python API which is guaranteed by //! [PEP 384] to be forward-compatible with future Python versions. //! - `extension-module`: This will tell the linker to keep the Python symbols unresolved, so that //! your module can also be used with statically linked Python interpreters. Use this feature when //! building an extension module. //! //! ## `rustc` environment flags //! //! PyO3 uses `rustc`'s `--cfg` flags to enable or disable code used for different Python versions. //! If you want to do this for your own crate, you can do so with the [`pyo3-build-config`] crate. //! //! - `Py_3_7`, `Py_3_8`, `Py_3_9`, `Py_3_10`, `Py_3_11`, `Py_3_12`, `Py_3_13`: Marks code that is //! only enabled when compiling for a given minimum Python version. //! - `Py_LIMITED_API`: Marks code enabled when the `abi3` feature flag is enabled. //! - `Py_GIL_DISABLED`: Marks code that runs only in the free-threaded build of CPython. //! - `PyPy` - Marks code enabled when compiling for PyPy. //! - `GraalPy` - Marks code enabled when compiling for GraalPy. //! //! Additionally, you can query for the values `Py_DEBUG`, `Py_REF_DEBUG`, //! `Py_TRACE_REFS`, and `COUNT_ALLOCS` from `py_sys_config` to query for the //! corresponding C build-time defines. For example, to conditionally define //! debug code using `Py_DEBUG`, you could do: //! //! ```rust,ignore //! #[cfg(py_sys_config = "Py_DEBUG")] //! println!("only runs if python was compiled with Py_DEBUG") //! ``` //! //! To use these attributes, add [`pyo3-build-config`] as a build dependency in //! your `Cargo.toml`: //! //! ```toml //! [build-dependencies] #![doc = concat!("pyo3-build-config =\"", env!("CARGO_PKG_VERSION"), "\"")] //! ``` //! //! And then either create a new `build.rs` file in the project root or modify //! the existing `build.rs` file to call `use_pyo3_cfgs()`: //! //! ```rust,ignore //! fn main() { //! pyo3_build_config::use_pyo3_cfgs(); //! } //! ``` //! //! # Minimum supported Rust and Python versions //! //! `pyo3-ffi` supports the following Python distributions: //! - CPython 3.7 or greater //! - PyPy 7.3 (Python 3.9+) //! - GraalPy 24.0 or greater (Python 3.10+) //! //! # Example: Building Python Native modules //! //! PyO3 can be used to generate a native Python module. The easiest way to try this out for the //! first time is to use [`maturin`]. `maturin` is a tool for building and publishing Rust-based //! Python packages with minimal configuration. The following steps set up some files for an example //! Python module, install `maturin`, and then show how to build and import the Python module. //! //! First, create a new folder (let's call it `string_sum`) containing the following two files: //! //! **`Cargo.toml`** //! //! ```toml //! [lib] //! name = "string_sum" //! # "cdylib" is necessary to produce a shared library for Python to import from. //! # //! # Downstream Rust code (including code in `bin/`, `examples/`, and `tests/`) will not be able //! # to `use string_sum;` unless the "rlib" or "lib" crate type is also included, e.g.: //! # crate-type = ["cdylib", "rlib"] //! crate-type = ["cdylib"] //! //! [dependencies.pyo3-ffi] #![doc = concat!("version = \"", env!("CARGO_PKG_VERSION"), "\"")] //! features = ["extension-module"] //! //! [build-dependencies] //! # This is only necessary if you need to configure your build based on //! # the Python version or the compile-time configuration for the interpreter. #![doc = concat!("pyo3_build_config = \"", env!("CARGO_PKG_VERSION"), "\"")] //! ``` //! //! If you need to use conditional compilation based on Python version or how //! Python was compiled, you need to add `pyo3-build-config` as a //! `build-dependency` in your `Cargo.toml` as in the example above and either //! create a new `build.rs` file or modify an existing one so that //! `pyo3_build_config::use_pyo3_cfgs()` gets called at build time: //! //! **`build.rs`** //! ```rust,ignore //! fn main() { //! pyo3_build_config::use_pyo3_cfgs() //! } //! ``` //! //! **`src/lib.rs`** //! see: `../examples/string-sum/src/lib.rs` //! //! With those two files in place, now `maturin` needs to be installed. This can be done using //! Python's package manager `pip`. First, load up a new Python `virtualenv`, and install `maturin` //! into it: //! ```bash //! $ cd string_sum //! $ python -m venv .env //! $ source .env/bin/activate //! $ pip install maturin //! ``` //! //! Now build and execute the module: //! ```bash //! $ maturin develop //! # lots of progress output as maturin runs the compilation... //! $ python //! >>> import string_sum //! >>> string_sum.sum_as_string(5, 20) //! '25' //! ``` //! //! As well as with `maturin`, it is possible to build using [setuptools-rust] or //! [manually][manual_builds]. Both offer more flexibility than `maturin` but require further //! configuration. //! //! This example stores the module definition statically and uses the `PyModule_Create` function //! in the CPython C API to register the module. This is the "old" style for registering modules //! and has the limitation that it cannot support subinterpreters. You can also create a module //! using the new multi-phase initialization API that does support subinterpreters. See the //! `sequential` project located in the `examples` directory at the root of the `pyo3-ffi` crate //! for a worked example of how to this using `pyo3-ffi`. //! //! # Using Python from Rust //! //! To embed Python into a Rust binary, you need to ensure that your Python installation contains a //! shared library. The following steps demonstrate how to ensure this (for Ubuntu). //! //! To install the Python shared library on Ubuntu: //! ```bash //! sudo apt install python3-dev //! ``` //! //! While most projects use the safe wrapper provided by pyo3, //! you can take a look at the [`orjson`] library as an example on how to use `pyo3-ffi` directly. //! For those well versed in C and Rust the [tutorials] from the CPython documentation //! can be easily converted to rust as well. //! //! [tutorials]: https://docs.python.org/3/extending/ //! [`orjson`]: https://github.com/ijl/orjson //! [capi]: https://docs.python.org/3/c-api/index.html //! [`maturin`]: https://github.com/PyO3/maturin "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages" //! [`pyo3-build-config`]: https://docs.rs/pyo3-build-config //! [feature flags]: https://doc.rust-lang.org/cargo/reference/features.html "Features - The Cargo Book" #![doc = concat!("[manual_builds]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/building-and-distribution.html#manual-builds \"Manual builds - Building and Distribution - PyO3 user guide\"")] //! [setuptools-rust]: https://github.com/PyO3/setuptools-rust "Setuptools plugin for Rust extensions" //! [PEP 384]: https://www.python.org/dev/peps/pep-0384 "PEP 384 -- Defining a Stable ABI" #![doc = concat!("[Features chapter of the guide]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/features.html#features-reference \"Features eference - PyO3 user guide\"")] #![allow( missing_docs, non_camel_case_types, non_snake_case, non_upper_case_globals, clippy::upper_case_acronyms, clippy::missing_safety_doc )] #![warn(elided_lifetimes_in_paths, unused_lifetimes)] // Until `extern type` is stabilized, use the recommended approach to // model opaque types: // https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs macro_rules! opaque_struct { ($name:ident) => { #[repr(C)] pub struct $name([u8; 0]); }; } /// This is a helper macro to create a `&'static CStr`. /// /// It can be used on all Rust versions supported by PyO3, unlike c"" literals which /// were stabilised in Rust 1.77. /// /// Due to the nature of PyO3 making heavy use of C FFI interop with Python, it is /// common for PyO3 to use CStr. /// /// Examples: /// /// ```rust /// use std::ffi::CStr; /// /// const HELLO: &CStr = pyo3_ffi::c_str!("hello"); /// static WORLD: &CStr = pyo3_ffi::c_str!("world"); /// ``` #[macro_export] macro_rules! c_str { ($s:expr) => { $crate::_cstr_from_utf8_with_nul_checked(concat!($s, "\0")) }; } /// Private helper for `c_str!` macro. #[doc(hidden)] pub const fn _cstr_from_utf8_with_nul_checked(s: &str) -> &CStr { // TODO: Replace this implementation with `CStr::from_bytes_with_nul` when MSRV above 1.72. let bytes = s.as_bytes(); let len = bytes.len(); assert!( !bytes.is_empty() && bytes[bytes.len() - 1] == b'\0', "string is not nul-terminated" ); let mut i = 0; let non_null_len = len - 1; while i < non_null_len { assert!(bytes[i] != b'\0', "string contains null bytes"); i += 1; } unsafe { CStr::from_bytes_with_nul_unchecked(bytes) } } use std::ffi::CStr; pub mod compat; mod impl_; pub use self::abstract_::*; pub use self::bltinmodule::*; pub use self::boolobject::*; pub use self::bytearrayobject::*; pub use self::bytesobject::*; pub use self::ceval::*; #[cfg(Py_LIMITED_API)] pub use self::code::*; pub use self::codecs::*; pub use self::compile::*; pub use self::complexobject::*; #[cfg(all(Py_3_8, not(Py_LIMITED_API)))] pub use self::context::*; #[cfg(not(Py_LIMITED_API))] pub use self::datetime::*; pub use self::descrobject::*; pub use self::dictobject::*; pub use self::enumobject::*; pub use self::fileobject::*; pub use self::fileutils::*; pub use self::floatobject::*; pub use self::import::*; pub use self::intrcheck::*; pub use self::iterobject::*; pub use self::listobject::*; pub use self::longobject::*; #[cfg(not(Py_LIMITED_API))] pub use self::marshal::*; pub use self::memoryobject::*; pub use self::methodobject::*; pub use self::modsupport::*; pub use self::moduleobject::*; pub use self::object::*; pub use self::objimpl::*; pub use self::osmodule::*; #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] pub use self::pyarena::*; #[cfg(Py_3_11)] pub use self::pybuffer::*; pub use self::pycapsule::*; pub use self::pyerrors::*; pub use self::pyframe::*; pub use self::pyhash::*; pub use self::pylifecycle::*; pub use self::pymem::*; pub use self::pyport::*; pub use self::pystate::*; pub use self::pystrtod::*; pub use self::pythonrun::*; pub use self::rangeobject::*; pub use self::setobject::*; pub use self::sliceobject::*; pub use self::structseq::*; pub use self::sysmodule::*; pub use self::traceback::*; pub use self::tupleobject::*; pub use self::typeslots::*; pub use self::unicodeobject::*; pub use self::warnings::*; pub use self::weakrefobject::*; mod abstract_; // skipped asdl.h // skipped ast.h mod bltinmodule; mod boolobject; mod bytearrayobject; mod bytesobject; // skipped cellobject.h mod ceval; // skipped classobject.h #[cfg(Py_LIMITED_API)] mod code; mod codecs; mod compile; mod complexobject; #[cfg(all(Py_3_8, not(Py_LIMITED_API)))] mod context; // It's actually 3.7.1, but no cfg for patches. #[cfg(not(Py_LIMITED_API))] pub(crate) mod datetime; mod descrobject; mod dictobject; // skipped dynamic_annotations.h mod enumobject; // skipped errcode.h // skipped exports.h mod fileobject; mod fileutils; mod floatobject; // skipped empty frameobject.h // skipped genericaliasobject.h mod import; // skipped interpreteridobject.h mod intrcheck; mod iterobject; mod listobject; // skipped longintrepr.h mod longobject; #[cfg(not(Py_LIMITED_API))] pub mod marshal; mod memoryobject; mod methodobject; mod modsupport; mod moduleobject; // skipped namespaceobject.h mod object; mod objimpl; // skipped odictobject.h // skipped opcode.h // skipped osdefs.h mod osmodule; // skipped parser_interface.h // skipped patchlevel.h // skipped picklebufobject.h // skipped pyctype.h // skipped py_curses.h #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] mod pyarena; #[cfg(Py_3_11)] mod pybuffer; mod pycapsule; // skipped pydtrace.h mod pyerrors; // skipped pyexpat.h // skipped pyfpe.h mod pyframe; mod pyhash; mod pylifecycle; // skipped pymacconfig.h // skipped pymacro.h // skipped pymath.h mod pymem; mod pyport; mod pystate; // skipped pystats.h mod pythonrun; // skipped pystrhex.h // skipped pystrcmp.h mod pystrtod; // skipped pythread.h // skipped pytime.h mod rangeobject; mod setobject; mod sliceobject; mod structseq; mod sysmodule; mod traceback; // skipped tracemalloc.h mod tupleobject; mod typeslots; mod unicodeobject; mod warnings; mod weakrefobject; // Additional headers that are not exported by Python.h #[deprecated(note = "Python 3.12")] pub mod structmember; // "Limited API" definitions matching Python's `include/cpython` directory. #[cfg(not(Py_LIMITED_API))] mod cpython; #[cfg(not(Py_LIMITED_API))] pub use self::cpython::*;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/iterobject.rs
use crate::object::*; use std::os::raw::c_int; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PySeqIter_Type: PyTypeObject; pub static mut PyCallIter_Type: PyTypeObject; } #[inline] pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PySeqIter_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPySeqIter_New")] pub fn PySeqIter_New(arg1: *mut PyObject) -> *mut PyObject; } #[inline] pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyCallIter_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyCallIter_New")] pub fn PyCallIter_New(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pythonrun.rs
use crate::object::*; #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] use libc::FILE; #[cfg(any(Py_LIMITED_API, not(Py_3_10), PyPy, GraalPy))] use std::os::raw::c_char; use std::os::raw::c_int; extern "C" { #[cfg(any(all(Py_LIMITED_API, not(PyPy)), GraalPy))] pub fn Py_CompileString(string: *const c_char, p: *const c_char, s: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyErr_Print")] pub fn PyErr_Print(); #[cfg_attr(PyPy, link_name = "PyPyErr_PrintEx")] pub fn PyErr_PrintEx(arg1: c_int); #[cfg_attr(PyPy, link_name = "PyPyErr_Display")] pub fn PyErr_Display(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject); #[cfg(Py_3_12)] pub fn PyErr_DisplayException(exc: *mut PyObject); } #[inline] #[cfg(PyPy)] pub unsafe fn Py_CompileString(string: *const c_char, p: *const c_char, s: c_int) -> *mut PyObject { // PyPy's implementation of Py_CompileString always forwards to Py_CompileStringFlags; this // is only available in the non-limited API and has a real definition for all versions in // the cpython/ subdirectory. #[cfg(Py_LIMITED_API)] extern "C" { #[link_name = "PyPy_CompileStringFlags"] pub fn Py_CompileStringFlags( string: *const c_char, p: *const c_char, s: c_int, f: *mut std::os::raw::c_void, // Actually *mut Py_CompilerFlags in the real definition ) -> *mut PyObject; } #[cfg(not(Py_LIMITED_API))] use crate::Py_CompileStringFlags; Py_CompileStringFlags(string, p, s, std::ptr::null_mut()) } // skipped PyOS_InputHook pub const PYOS_STACK_MARGIN: c_int = 2048; // skipped PyOS_CheckStack under Microsoft C #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] opaque_struct!(_mod); #[cfg(not(any(PyPy, Py_3_10)))] opaque_struct!(symtable); #[cfg(not(any(PyPy, Py_3_10)))] opaque_struct!(_node); #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[inline] pub unsafe fn PyParser_SimpleParseString(s: *const c_char, b: c_int) -> *mut _node { #[allow(deprecated)] crate::PyParser_SimpleParseStringFlags(s, b, 0) } #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] #[cfg_attr(Py_3_9, deprecated(note = "Python 3.9"))] #[inline] pub unsafe fn PyParser_SimpleParseFile(fp: *mut FILE, s: *const c_char, b: c_int) -> *mut _node { #[allow(deprecated)] crate::PyParser_SimpleParseFileFlags(fp, s, b, 0) } extern "C" { #[cfg(not(any(PyPy, Py_3_10)))] pub fn Py_SymtableString( str: *const c_char, filename: *const c_char, start: c_int, ) -> *mut symtable; #[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))] pub fn Py_SymtableStringObject( str: *const c_char, filename: *mut PyObject, start: c_int, ) -> *mut symtable; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/modsupport.rs
use crate::methodobject::PyMethodDef; use crate::moduleobject::PyModuleDef; use crate::object::PyObject; use crate::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_long}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyArg_Parse")] pub fn PyArg_Parse(arg1: *mut PyObject, arg2: *const c_char, ...) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyArg_ParseTuple")] pub fn PyArg_ParseTuple(arg1: *mut PyObject, arg2: *const c_char, ...) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyArg_ParseTupleAndKeywords")] pub fn PyArg_ParseTupleAndKeywords( arg1: *mut PyObject, arg2: *mut PyObject, arg3: *const c_char, #[cfg(not(Py_3_13))] arg4: *mut *mut c_char, #[cfg(Py_3_13)] arg4: *const *const c_char, ... ) -> c_int; // skipped PyArg_VaParse // skipped PyArg_VaParseTupleAndKeywords pub fn PyArg_ValidateKeywordArguments(arg1: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyArg_UnpackTuple")] pub fn PyArg_UnpackTuple( arg1: *mut PyObject, arg2: *const c_char, arg3: Py_ssize_t, arg4: Py_ssize_t, ... ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPy_BuildValue")] pub fn Py_BuildValue(arg1: *const c_char, ...) -> *mut PyObject; // skipped Py_VaBuildValue #[cfg(Py_3_13)] pub fn PyModule_Add( module: *mut PyObject, name: *const c_char, value: *mut PyObject, ) -> core::ffi::c_int; #[cfg(Py_3_10)] #[cfg_attr(PyPy, link_name = "PyPyModule_AddObjectRef")] pub fn PyModule_AddObjectRef( module: *mut PyObject, name: *const c_char, value: *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyModule_AddObject")] pub fn PyModule_AddObject( module: *mut PyObject, name: *const c_char, value: *mut PyObject, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyModule_AddIntConstant")] pub fn PyModule_AddIntConstant( module: *mut PyObject, name: *const c_char, value: c_long, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyModule_AddStringConstant")] pub fn PyModule_AddStringConstant( module: *mut PyObject, name: *const c_char, value: *const c_char, ) -> c_int; #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] #[cfg_attr(PyPy, link_name = "PyPyModule_AddType")] pub fn PyModule_AddType( module: *mut PyObject, type_: *mut crate::object::PyTypeObject, ) -> c_int; // skipped PyModule_AddIntMacro // skipped PyModule_AddStringMacro pub fn PyModule_SetDocString(arg1: *mut PyObject, arg2: *const c_char) -> c_int; pub fn PyModule_AddFunctions(arg1: *mut PyObject, arg2: *mut PyMethodDef) -> c_int; pub fn PyModule_ExecDef(module: *mut PyObject, def: *mut PyModuleDef) -> c_int; } pub const Py_CLEANUP_SUPPORTED: i32 = 0x2_0000; pub const PYTHON_API_VERSION: i32 = 1013; pub const PYTHON_ABI_VERSION: i32 = 3; extern "C" { #[cfg(not(py_sys_config = "Py_TRACE_REFS"))] #[cfg_attr(PyPy, link_name = "PyPyModule_Create2")] pub fn PyModule_Create2(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject; #[cfg(py_sys_config = "Py_TRACE_REFS")] fn PyModule_Create2TraceRefs(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject; #[cfg(not(py_sys_config = "Py_TRACE_REFS"))] pub fn PyModule_FromDefAndSpec2( def: *mut PyModuleDef, spec: *mut PyObject, module_api_version: c_int, ) -> *mut PyObject; #[cfg(py_sys_config = "Py_TRACE_REFS")] fn PyModule_FromDefAndSpec2TraceRefs( def: *mut PyModuleDef, spec: *mut PyObject, module_api_version: c_int, ) -> *mut PyObject; } #[cfg(py_sys_config = "Py_TRACE_REFS")] #[inline] pub unsafe fn PyModule_Create2(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject { PyModule_Create2TraceRefs(module, apiver) } #[cfg(py_sys_config = "Py_TRACE_REFS")] #[inline] pub unsafe fn PyModule_FromDefAndSpec2( def: *mut PyModuleDef, spec: *mut PyObject, module_api_version: c_int, ) -> *mut PyObject { PyModule_FromDefAndSpec2TraceRefs(def, spec, module_api_version) } #[inline] pub unsafe fn PyModule_Create(module: *mut PyModuleDef) -> *mut PyObject { PyModule_Create2( module, if cfg!(Py_LIMITED_API) { PYTHON_ABI_VERSION } else { PYTHON_API_VERSION }, ) } #[inline] pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject) -> *mut PyObject { PyModule_FromDefAndSpec2( def, spec, if cfg!(Py_LIMITED_API) { PYTHON_ABI_VERSION } else { PYTHON_API_VERSION }, ) }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/tupleobject.rs
use crate::object::*; use crate::pyport::Py_ssize_t; use std::os::raw::c_int; use std::ptr::addr_of_mut; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyTuple_Type")] pub static mut PyTuple_Type: PyTypeObject; pub static mut PyTupleIter_Type: PyTypeObject; } #[inline] pub unsafe fn PyTuple_Check(op: *mut PyObject) -> c_int { PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) } #[inline] pub unsafe fn PyTuple_CheckExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(PyTuple_Type)) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyTuple_New")] pub fn PyTuple_New(size: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyTuple_Size")] pub fn PyTuple_Size(arg1: *mut PyObject) -> Py_ssize_t; #[cfg_attr(PyPy, link_name = "PyPyTuple_GetItem")] pub fn PyTuple_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyTuple_SetItem")] pub fn PyTuple_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyTuple_GetSlice")] pub fn PyTuple_GetSlice( arg1: *mut PyObject, arg2: Py_ssize_t, arg3: Py_ssize_t, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyTuple_Pack")] pub fn PyTuple_Pack(arg1: Py_ssize_t, ...) -> *mut PyObject; #[cfg(not(Py_3_9))] pub fn PyTuple_ClearFreeList() -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/marshal.rs
use super::{PyObject, Py_ssize_t}; use std::os::raw::{c_char, c_int}; // skipped Py_MARSHAL_VERSION // skipped PyMarshal_WriteLongToFile // skipped PyMarshal_WriteObjectToFile extern "C" { #[cfg_attr(PyPy, link_name = "PyPyMarshal_WriteObjectToString")] pub fn PyMarshal_WriteObjectToString(object: *mut PyObject, version: c_int) -> *mut PyObject; // skipped non-limited PyMarshal_ReadLongFromFile // skipped non-limited PyMarshal_ReadShortFromFile // skipped non-limited PyMarshal_ReadObjectFromFile // skipped non-limited PyMarshal_ReadLastObjectFromFile #[cfg_attr(PyPy, link_name = "PyPyMarshal_ReadObjectFromString")] pub fn PyMarshal_ReadObjectFromString(data: *const c_char, len: Py_ssize_t) -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pyframe.rs
#[cfg(not(GraalPy))] #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] use crate::PyCodeObject; #[cfg(not(Py_LIMITED_API))] use crate::PyFrameObject; use std::os::raw::c_int; #[cfg(Py_LIMITED_API)] opaque_struct!(PyFrameObject); extern "C" { pub fn PyFrame_GetLineNumber(f: *mut PyFrameObject) -> c_int; #[cfg(not(GraalPy))] #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] pub fn PyFrame_GetCode(f: *mut PyFrameObject) -> *mut PyCodeObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/weakrefobject.rs
use crate::object::*; use std::os::raw::c_int; #[cfg(not(PyPy))] use std::ptr::addr_of_mut; #[cfg(all(not(PyPy), Py_LIMITED_API, not(GraalPy)))] opaque_struct!(PyWeakReference); #[cfg(all(not(PyPy), not(Py_LIMITED_API), not(GraalPy)))] pub use crate::_PyWeakReference as PyWeakReference; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut _PyWeakref_RefType: PyTypeObject; pub static mut _PyWeakref_ProxyType: PyTypeObject; pub static mut _PyWeakref_CallableProxyType: PyTypeObject; #[cfg(PyPy)] #[link_name = "PyPyWeakref_CheckRef"] pub fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int; #[cfg(PyPy)] #[link_name = "PyPyWeakref_CheckRefExact"] pub fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int; #[cfg(PyPy)] #[link_name = "PyPyWeakref_CheckProxy"] pub fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int; } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int { PyObject_TypeCheck(op, addr_of_mut!(_PyWeakref_RefType)) } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int { (Py_TYPE(op) == addr_of_mut!(_PyWeakref_RefType)) as c_int } #[inline] #[cfg(not(PyPy))] pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int { ((Py_TYPE(op) == addr_of_mut!(_PyWeakref_ProxyType)) || (Py_TYPE(op) == addr_of_mut!(_PyWeakref_CallableProxyType))) as c_int } #[inline] pub unsafe fn PyWeakref_Check(op: *mut PyObject) -> c_int { (PyWeakref_CheckRef(op) != 0 || PyWeakref_CheckProxy(op) != 0) as c_int } extern "C" { #[cfg_attr(PyPy, link_name = "PyPyWeakref_NewRef")] pub fn PyWeakref_NewRef(ob: *mut PyObject, callback: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyWeakref_NewProxy")] pub fn PyWeakref_NewProxy(ob: *mut PyObject, callback: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyWeakref_GetObject")] #[cfg_attr( Py_3_13, deprecated(note = "deprecated since Python 3.13. Use `PyWeakref_GetRef` instead.") )] pub fn PyWeakref_GetObject(reference: *mut PyObject) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyWeakref_GetRef")] pub fn PyWeakref_GetRef(reference: *mut PyObject, pobj: *mut *mut PyObject) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/enumobject.rs
use crate::object::PyTypeObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyEnum_Type: PyTypeObject; pub static mut PyReversed_Type: PyTypeObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/intrcheck.rs
use std::os::raw::c_int; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyOS_InterruptOccurred")] pub fn PyOS_InterruptOccurred() -> c_int; #[cfg(not(Py_3_10))] #[deprecated(note = "Not documented in Python API; see Python 3.10 release notes")] pub fn PyOS_InitInterrupts(); pub fn PyOS_BeforeFork(); pub fn PyOS_AfterFork_Parent(); pub fn PyOS_AfterFork_Child(); #[deprecated(note = "use PyOS_AfterFork_Child instead")] #[cfg_attr(PyPy, link_name = "PyPyOS_AfterFork")] pub fn PyOS_AfterFork(); // skipped non-limited _PyOS_IsMainThread // skipped non-limited Windows _PyOS_SigintEvent }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pylifecycle.rs
use crate::pystate::PyThreadState; use libc::wchar_t; use std::os::raw::{c_char, c_int}; extern "C" { pub fn Py_Initialize(); pub fn Py_InitializeEx(arg1: c_int); pub fn Py_Finalize(); pub fn Py_FinalizeEx() -> c_int; #[cfg_attr(PyPy, link_name = "PyPy_IsInitialized")] pub fn Py_IsInitialized() -> c_int; pub fn Py_NewInterpreter() -> *mut PyThreadState; pub fn Py_EndInterpreter(arg1: *mut PyThreadState); #[cfg_attr(PyPy, link_name = "PyPy_AtExit")] pub fn Py_AtExit(func: Option<extern "C" fn()>) -> c_int; pub fn Py_Exit(arg1: c_int); pub fn Py_Main(argc: c_int, argv: *mut *mut wchar_t) -> c_int; pub fn Py_BytesMain(argc: c_int, argv: *mut *mut c_char) -> c_int; #[cfg_attr( Py_3_11, deprecated(note = "Deprecated since Python 3.11. Use `PyConfig.program_name` instead.") )] pub fn Py_SetProgramName(arg1: *const wchar_t); #[cfg_attr(PyPy, link_name = "PyPy_GetProgramName")] #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.") )] pub fn Py_GetProgramName() -> *mut wchar_t; #[cfg_attr( Py_3_11, deprecated(note = "Deprecated since Python 3.11. Use `PyConfig.home` instead.") )] pub fn Py_SetPythonHome(arg1: *const wchar_t); #[cfg_attr( Py_3_13, deprecated( note = "Deprecated since Python 3.13. Use `PyConfig.home` or the value of the `PYTHONHOME` environment variable instead." ) )] pub fn Py_GetPythonHome() -> *mut wchar_t; #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.") )] pub fn Py_GetProgramFullPath() -> *mut wchar_t; #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `sys.prefix` instead.") )] pub fn Py_GetPrefix() -> *mut wchar_t; #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `sys.exec_prefix` instead.") )] pub fn Py_GetExecPrefix() -> *mut wchar_t; #[cfg_attr( Py_3_13, deprecated(note = "Deprecated since Python 3.13. Use `sys.path` instead.") )] pub fn Py_GetPath() -> *mut wchar_t; #[cfg(not(Py_3_13))] #[cfg_attr( Py_3_11, deprecated(note = "Deprecated since Python 3.11. Use `sys.path` instead.") )] pub fn Py_SetPath(arg1: *const wchar_t); // skipped _Py_CheckPython3 #[cfg_attr(PyPy, link_name = "PyPy_GetVersion")] pub fn Py_GetVersion() -> *const c_char; pub fn Py_GetPlatform() -> *const c_char; pub fn Py_GetCopyright() -> *const c_char; pub fn Py_GetCompiler() -> *const c_char; pub fn Py_GetBuildInfo() -> *const c_char; } type PyOS_sighandler_t = unsafe extern "C" fn(arg1: c_int); extern "C" { pub fn PyOS_getsig(arg1: c_int) -> PyOS_sighandler_t; pub fn PyOS_setsig(arg1: c_int, arg2: PyOS_sighandler_t) -> PyOS_sighandler_t; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/fileobject.rs
use crate::object::PyObject; use std::os::raw::{c_char, c_int}; pub const PY_STDIOTEXTMODE: &str = "b"; extern "C" { pub fn PyFile_FromFd( arg1: c_int, arg2: *const c_char, arg3: *const c_char, arg4: c_int, arg5: *const c_char, arg6: *const c_char, arg7: *const c_char, arg8: c_int, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFile_GetLine")] pub fn PyFile_GetLine(arg1: *mut PyObject, arg2: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyFile_WriteObject")] pub fn PyFile_WriteObject(arg1: *mut PyObject, arg2: *mut PyObject, arg3: c_int) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyFile_WriteString")] pub fn PyFile_WriteString(arg1: *const c_char, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyFile_AsFileDescriptor")] pub fn PyObject_AsFileDescriptor(arg1: *mut PyObject) -> c_int; } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[deprecated(note = "Python 3.12")] pub static mut Py_FileSystemDefaultEncoding: *const c_char; #[deprecated(note = "Python 3.12")] pub static mut Py_FileSystemDefaultEncodeErrors: *const c_char; #[deprecated(note = "Python 3.12")] pub static mut Py_HasFileSystemDefaultEncoding: c_int; // skipped 3.12-deprecated Py_UTF8Mode } // skipped _PyIsSelectable_fd
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/sysmodule.rs
use crate::object::PyObject; use libc::wchar_t; use std::os::raw::{c_char, c_int}; extern "C" { #[cfg_attr(PyPy, link_name = "PyPySys_GetObject")] pub fn PySys_GetObject(arg1: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPySys_SetObject")] pub fn PySys_SetObject(arg1: *const c_char, arg2: *mut PyObject) -> c_int; #[cfg_attr( Py_3_11, deprecated( note = "Deprecated in Python 3.11, use `PyConfig.argv` and `PyConfig.parse_argv` instead" ) )] pub fn PySys_SetArgv(arg1: c_int, arg2: *mut *mut wchar_t); #[cfg_attr( Py_3_11, deprecated( note = "Deprecated in Python 3.11, use `PyConfig.argv` and `PyConfig.parse_argv` instead" ) )] pub fn PySys_SetArgvEx(arg1: c_int, arg2: *mut *mut wchar_t, arg3: c_int); pub fn PySys_SetPath(arg1: *const wchar_t); #[cfg_attr(PyPy, link_name = "PyPySys_WriteStdout")] pub fn PySys_WriteStdout(format: *const c_char, ...); #[cfg_attr(PyPy, link_name = "PyPySys_WriteStderr")] pub fn PySys_WriteStderr(format: *const c_char, ...); pub fn PySys_FormatStdout(format: *const c_char, ...); pub fn PySys_FormatStderr(format: *const c_char, ...); #[cfg_attr( Py_3_13, deprecated( note = "Deprecated since Python 3.13. Clear sys.warnoptions and warnings.filters instead." ) )] pub fn PySys_ResetWarnOptions(); #[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] pub fn PySys_AddWarnOption(arg1: *const wchar_t); #[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] pub fn PySys_AddWarnOptionUnicode(arg1: *mut PyObject); #[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] pub fn PySys_HasWarnOptions() -> c_int; pub fn PySys_AddXOption(arg1: *const wchar_t); pub fn PySys_GetXOptions() -> *mut PyObject; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/fileutils.rs
use crate::pyport::Py_ssize_t; use libc::wchar_t; use std::os::raw::c_char; extern "C" { pub fn Py_DecodeLocale(arg1: *const c_char, size: *mut Py_ssize_t) -> *mut wchar_t; pub fn Py_EncodeLocale(text: *const wchar_t, error_pos: *mut Py_ssize_t) -> *mut c_char; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/import.rs
use crate::object::PyObject; use std::os::raw::{c_char, c_int, c_long}; extern "C" { pub fn PyImport_GetMagicNumber() -> c_long; pub fn PyImport_GetMagicTag() -> *const c_char; #[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModule")] pub fn PyImport_ExecCodeModule(name: *const c_char, co: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModuleEx")] pub fn PyImport_ExecCodeModuleEx( name: *const c_char, co: *mut PyObject, pathname: *const c_char, ) -> *mut PyObject; pub fn PyImport_ExecCodeModuleWithPathnames( name: *const c_char, co: *mut PyObject, pathname: *const c_char, cpathname: *const c_char, ) -> *mut PyObject; pub fn PyImport_ExecCodeModuleObject( name: *mut PyObject, co: *mut PyObject, pathname: *mut PyObject, cpathname: *mut PyObject, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_GetModuleDict")] pub fn PyImport_GetModuleDict() -> *mut PyObject; // skipped Python 3.7 / ex-non-limited PyImport_GetModule pub fn PyImport_AddModuleObject(name: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_AddModule")] pub fn PyImport_AddModule(name: *const c_char) -> *mut PyObject; #[cfg(Py_3_13)] #[cfg_attr(PyPy, link_name = "PyPyImport_AddModuleRef")] pub fn PyImport_AddModuleRef(name: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModule")] pub fn PyImport_ImportModule(name: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleNoBlock")] pub fn PyImport_ImportModuleNoBlock(name: *const c_char) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevel")] pub fn PyImport_ImportModuleLevel( name: *const c_char, globals: *mut PyObject, locals: *mut PyObject, fromlist: *mut PyObject, level: c_int, ) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevelObject")] pub fn PyImport_ImportModuleLevelObject( name: *mut PyObject, globals: *mut PyObject, locals: *mut PyObject, fromlist: *mut PyObject, level: c_int, ) -> *mut PyObject; } #[inline] pub unsafe fn PyImport_ImportModuleEx( name: *const c_char, globals: *mut PyObject, locals: *mut PyObject, fromlist: *mut PyObject, ) -> *mut PyObject { PyImport_ImportModuleLevel(name, globals, locals, fromlist, 0) } extern "C" { pub fn PyImport_GetImporter(path: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_Import")] pub fn PyImport_Import(name: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyImport_ReloadModule")] pub fn PyImport_ReloadModule(m: *mut PyObject) -> *mut PyObject; #[cfg(not(Py_3_9))] #[deprecated(note = "Removed in Python 3.9 as it was \"For internal use only\".")] pub fn PyImport_Cleanup(); pub fn PyImport_ImportFrozenModuleObject(name: *mut PyObject) -> c_int; pub fn PyImport_ImportFrozenModule(name: *const c_char) -> c_int; pub fn PyImport_AppendInittab( name: *const c_char, initfunc: Option<unsafe extern "C" fn() -> *mut PyObject>, ) -> c_int; }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pyarena.rs
opaque_struct!(PyArena);
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/pymem.rs
use libc::size_t; use std::os::raw::c_void; extern "C" { #[cfg_attr(PyPy, link_name = "PyPyMem_Malloc")] pub fn PyMem_Malloc(size: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyMem_Calloc")] pub fn PyMem_Calloc(nelem: size_t, elsize: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyMem_Realloc")] pub fn PyMem_Realloc(ptr: *mut c_void, new_size: size_t) -> *mut c_void; #[cfg_attr(PyPy, link_name = "PyPyMem_Free")] pub fn PyMem_Free(ptr: *mut c_void); }
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/compat/py_3_10.rs
compat_function!( originally_defined_for(Py_3_10); #[inline] pub unsafe fn Py_NewRef(obj: *mut crate::PyObject) -> *mut crate::PyObject { crate::Py_INCREF(obj); obj } ); compat_function!( originally_defined_for(Py_3_10); #[inline] pub unsafe fn Py_XNewRef(obj: *mut crate::PyObject) -> *mut crate::PyObject { crate::Py_XINCREF(obj); obj } );
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/compat/py_3_9.rs
compat_function!( originally_defined_for(all( not(PyPy), not(GraalPy), any(Py_3_10, all(not(Py_LIMITED_API), Py_3_9)) // Added to python in 3.9 but to limited API in 3.10 )); #[inline] pub unsafe fn PyObject_CallNoArgs(obj: *mut crate::PyObject) -> *mut crate::PyObject { crate::PyObject_CallObject(obj, std::ptr::null_mut()) } ); compat_function!( originally_defined_for(all(Py_3_9, not(any(Py_LIMITED_API, PyPy, GraalPy)))); #[inline] pub unsafe fn PyObject_CallMethodNoArgs(obj: *mut crate::PyObject, name: *mut crate::PyObject) -> *mut crate::PyObject { crate::PyObject_CallMethodObjArgs(obj, name, std::ptr::null_mut::<crate::PyObject>()) } );
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/compat/py_3_13.rs
compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyDict_GetItemRef( dp: *mut crate::PyObject, key: *mut crate::PyObject, result: *mut *mut crate::PyObject, ) -> std::os::raw::c_int { use crate::{compat::Py_NewRef, PyDict_GetItemWithError, PyErr_Occurred}; let item = PyDict_GetItemWithError(dp, key); if !item.is_null() { *result = Py_NewRef(item); return 1; // found } *result = std::ptr::null_mut(); if PyErr_Occurred().is_null() { return 0; // not found } -1 } ); compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyList_GetItemRef( arg1: *mut crate::PyObject, arg2: crate::Py_ssize_t, ) -> *mut crate::PyObject { use crate::{PyList_GetItem, Py_XINCREF}; let item = PyList_GetItem(arg1, arg2); Py_XINCREF(item); item } ); compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyImport_AddModuleRef( name: *const std::os::raw::c_char, ) -> *mut crate::PyObject { use crate::{compat::Py_XNewRef, PyImport_AddModule}; Py_XNewRef(PyImport_AddModule(name)) } ); compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyWeakref_GetRef( reference: *mut crate::PyObject, pobj: *mut *mut crate::PyObject, ) -> std::os::raw::c_int { use crate::{ compat::Py_NewRef, PyErr_SetString, PyExc_TypeError, PyWeakref_Check, PyWeakref_GetObject, Py_None, }; if !reference.is_null() && PyWeakref_Check(reference) == 0 { *pobj = std::ptr::null_mut(); PyErr_SetString(PyExc_TypeError, c_str!("expected a weakref").as_ptr()); return -1; } let obj = PyWeakref_GetObject(reference); if obj.is_null() { // SystemError if reference is NULL *pobj = std::ptr::null_mut(); return -1; } if obj == Py_None() { *pobj = std::ptr::null_mut(); return 0; } *pobj = Py_NewRef(obj); 1 } ); compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyList_Extend( list: *mut crate::PyObject, iterable: *mut crate::PyObject, ) -> std::os::raw::c_int { crate::PyList_SetSlice(list, crate::PY_SSIZE_T_MAX, crate::PY_SSIZE_T_MAX, iterable) } ); compat_function!( originally_defined_for(Py_3_13); #[inline] pub unsafe fn PyList_Clear(list: *mut crate::PyObject) -> std::os::raw::c_int { crate::PyList_SetSlice(list, 0, crate::PY_SSIZE_T_MAX, std::ptr::null_mut()) } );
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/compat/mod.rs
//! C API Compatibility Shims //! //! Some CPython C API functions added in recent versions of Python are //! inherently safer to use than older C API constructs. This module //! exposes functions available on all Python versions that wrap the //! old C API on old Python versions and wrap the function directly //! on newer Python versions. // Unless otherwise noted, the compatibility shims are adapted from // the pythoncapi-compat project: https://github.com/python/pythoncapi-compat /// Internal helper macro which defines compatibility shims for C API functions, deferring to a /// re-export when that's available. macro_rules! compat_function { ( originally_defined_for($cfg:meta); $(#[$attrs:meta])* pub unsafe fn $name:ident($($arg_names:ident: $arg_types:ty),* $(,)?) -> $ret:ty $body:block ) => { // Define as a standalone function under docsrs cfg so that this shows as a unique function in the docs, // not a re-export (the re-export has the wrong visibility) #[cfg(any(docsrs, not($cfg)))] #[cfg_attr(docsrs, doc(cfg(all())))] $(#[$attrs])* pub unsafe fn $name( $($arg_names: $arg_types,)* ) -> $ret $body #[cfg(all($cfg, not(docsrs)))] pub use $crate::$name; #[cfg(test)] paste::paste! { // Test that the compat function does not overlap with the original function. If the // cfgs line up, then the the two glob imports will resolve to the same item via the // re-export. If the cfgs mismatch, then the use of $name will be ambiguous in cases // where the function is defined twice, and the test will fail to compile. #[allow(unused_imports)] mod [<test_ $name _export>] { use $crate::*; use $crate::compat::*; #[test] fn test_export() { let _ = $name; } } } }; } mod py_3_10; mod py_3_13; mod py_3_9; pub use self::py_3_10::*; pub use self::py_3_13::*; pub use self::py_3_9::*;
0
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src
lc_public_repos/langsmith-sdk/vendor/pyo3/pyo3-ffi/src/cpython/pystate.rs
#[cfg(not(PyPy))] use crate::PyThreadState; use crate::{PyFrameObject, PyInterpreterState, PyObject}; use std::os::raw::c_int; // skipped _PyInterpreterState_RequiresIDRef // skipped _PyInterpreterState_RequireIDRef // skipped _PyInterpreterState_GetMainModule pub type Py_tracefunc = unsafe extern "C" fn( obj: *mut PyObject, frame: *mut PyFrameObject, what: c_int, arg: *mut PyObject, ) -> c_int; pub const PyTrace_CALL: c_int = 0; pub const PyTrace_EXCEPTION: c_int = 1; pub const PyTrace_LINE: c_int = 2; pub const PyTrace_RETURN: c_int = 3; pub const PyTrace_C_CALL: c_int = 4; pub const PyTrace_C_EXCEPTION: c_int = 5; pub const PyTrace_C_RETURN: c_int = 6; pub const PyTrace_OPCODE: c_int = 7; // skipped PyTraceInfo // skipped CFrame #[cfg(not(PyPy))] #[repr(C)] #[derive(Clone, Copy)] pub struct _PyErr_StackItem { #[cfg(not(Py_3_11))] pub exc_type: *mut PyObject, pub exc_value: *mut PyObject, #[cfg(not(Py_3_11))] pub exc_traceback: *mut PyObject, pub previous_item: *mut _PyErr_StackItem, } // skipped _PyStackChunk // skipped _ts (aka PyThreadState) extern "C" { // skipped _PyThreadState_Prealloc // skipped _PyThreadState_UncheckedGet // skipped _PyThreadState_GetDict #[cfg_attr(PyPy, link_name = "PyPyGILState_Check")] pub fn PyGILState_Check() -> c_int; // skipped _PyGILState_GetInterpreterStateUnsafe // skipped _PyThread_CurrentFrames // skipped _PyThread_CurrentExceptions #[cfg(not(PyPy))] pub fn PyInterpreterState_Main() -> *mut PyInterpreterState; #[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Head")] pub fn PyInterpreterState_Head() -> *mut PyInterpreterState; #[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Next")] pub fn PyInterpreterState_Next(interp: *mut PyInterpreterState) -> *mut PyInterpreterState; #[cfg(not(PyPy))] pub fn PyInterpreterState_ThreadHead(interp: *mut PyInterpreterState) -> *mut PyThreadState; #[cfg(not(PyPy))] pub fn PyThreadState_Next(tstate: *mut PyThreadState) -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyThreadState_DeleteCurrent")] pub fn PyThreadState_DeleteCurrent(); } #[cfg(all(Py_3_9, not(Py_3_11)))] pub type _PyFrameEvalFunction = extern "C" fn( *mut crate::PyThreadState, *mut crate::PyFrameObject, c_int, ) -> *mut crate::object::PyObject; #[cfg(Py_3_11)] pub type _PyFrameEvalFunction = extern "C" fn( *mut crate::PyThreadState, *mut crate::_PyInterpreterFrame, c_int, ) -> *mut crate::object::PyObject; #[cfg(Py_3_9)] extern "C" { /// Get the frame evaluation function. pub fn _PyInterpreterState_GetEvalFrameFunc( interp: *mut PyInterpreterState, ) -> _PyFrameEvalFunction; ///Set the frame evaluation function. pub fn _PyInterpreterState_SetEvalFrameFunc( interp: *mut PyInterpreterState, eval_frame: _PyFrameEvalFunction, ); } // skipped _PyInterpreterState_GetConfig // skipped _PyInterpreterState_GetConfigCopy // skipped _PyInterpreterState_SetConfig // skipped _Py_GetConfig // skipped _PyCrossInterpreterData // skipped _PyObject_GetCrossInterpreterData // skipped _PyCrossInterpreterData_NewObject // skipped _PyCrossInterpreterData_Release // skipped _PyObject_CheckCrossInterpreterData // skipped crossinterpdatafunc // skipped _PyCrossInterpreterData_RegisterClass // skipped _PyCrossInterpreterData_Lookup