Skip to content

Commit

Permalink
Doc fixes: Update filename in README.md, remove obsolete and broken r…
Browse files Browse the repository at this point in the history
…eferences to pybind11_protobuf.

Fixes in response to #10

PiperOrigin-RevId: 568278228
  • Loading branch information
Ralf W. Grosse-Kunstleve authored and copybara-github committed Sep 25, 2023
1 parent fcfff85 commit ba421f1
Showing 1 changed file with 4 additions and 47 deletions.
51 changes: 4 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ To use the Status[Or] casters:
1. Call `pybind11::google::ImportStatusModule();` in your `PYBIND11_MODULE`
definition.

(For use outside google3:
The path used for the `status` module may be changed by altering the value of
`PYBIND11_ABSEIL_STATUS_MODULE_PATH` defined in `import_status_module.h`.)

By default, an ok status will be converted into `None`, and a non-ok status will
raise a `status.StatusNotOk` exception. This has a `status` attribute which can
be used to access the status object and check the code/ message.
Expand Down Expand Up @@ -319,50 +323,3 @@ if status.StatusCode(status_code) == status.StatusCode.OK: # Correct.
if status_code == int(status.StatusCode.OK): # Also correct.
...
```

### Aliasing parts of the status module

The need to import the `status` module can be eliminated by aliasing the parts
of the status module that are needed in your own module:

```cpp
PYBIND11_MODULE(test_bindings, m) {
auto status_module = pybind11::google::ImportStatusModule();
m.attr("StatusNotOk") = status_module.attr("StatusNotOk");

...
}
```
Python:
```python
import test_bindings
try:
return_status()
except test_bindings.StatusNotOk as e:
print(e.status)
```

### Importing the status module

The status module uses the same import mechansim as the proto module; see [its
documentation](../pybind11_protobuf/README.md#importing-the-proto-module)
for details. For now there is a `#ifdef` to allow `ImportStatusModule` to work
with python 2 rather than giving an error, but this will be removed eventually.

If modifying the following functions, make the same changes in the
corresponding proto functions:
- ImportStatusModule
- IsStatusModuleImported
- CheckStatusModuleImported

### Use Outside of Google3

The path used for the status module may be changed by altering the value of
`PYBIND11_ABSEIL_STATUS_MODULE_PATH` defined in `status_casters.h`. This uses
the same mechanism as the proto module, so see [its documentation
](../pybind11_protobuf/README.md?cl=head#use-outside-of-google3)
for details.

0 comments on commit ba421f1

Please sign in to comment.