Repository: python/cpython
Pull request: gh-121477: mention new PyLong_*Bytes() functions in PyLong_FromString()
<!--
Thanks for your contribution!
Please read this comment in its entirety. It's quite important.

# Pull Request title

It should be in the following format:

```
gh-NNNNN: Summary of the changes made
```

Where: gh-NNNNN refers to the GitHub issue number.

Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue.

# Backport Pull Request title

If this is a backport PR (PR made against branches other than `main`),
please ensure that the PR title is in the following format:

```
[X.Y] <title from the original PR> (GH-NNNN)
```

Where: [X.Y] is the branch name, e.g. [3.6].

GH-NNNN refers to the PR number from `main`.

-->


<!-- gh-issue-number: gh-121477 -->
* Issue: gh-121477
<!-- /gh-issue-number -->


<!-- readthedocs-preview cpython-previews start -->
----
📚 Documentation preview 📚: https://cpython-previews--121478.org.readthedocs.build/

<!-- readthedocs-preview cpython-previews end -->

Closes https://github.com/python/cpython/issues/121477

Problem statement:
PyLong_FromString() docs should point to C API functions rather than to int.to_bytes()/from_bytes()
Patch:
```diff
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index 42162914c0..a43a46a55a 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -94,9 +94,9 @@ distinguished from a number.  Use :c:func:`PyErr_Occurred` to disambiguate.
    ignored.  If there are no digits or *str* is not NULL-terminated following the
    digits and trailing whitespace, :exc:`ValueError` will be raised.
 
-   .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
-      to convert a :c:type:`PyLongObject` to/from an array of bytes in base
-      ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
+   .. seealso:: :c:func:`PyLong_AsNativeBytes()` and
+      :c:func:`PyLong_FromNativeBytes()` functions could be used to convert
+      a :c:type:`PyLongObject` to/from an array of bytes in base ``256``.
 
 
 .. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)
```

<!-- gh-linked-prs -->
### Linked PRs
* gh-121478
<!-- /gh-linked-prs -->

Hints from issue discussion:

Commit message: gh-121477: mention new PyLong_*Bytes() functions in PyLong_FromString()

Patch to review:
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index 42162914c0aec8..a43a46a55a3355 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -94,9 +94,9 @@ distinguished from a number.  Use :c:func:`PyErr_Occurred` to disambiguate.
    ignored.  If there are no digits or *str* is not NULL-terminated following the
    digits and trailing whitespace, :exc:`ValueError` will be raised.
 
-   .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
-      to convert a :c:type:`PyLongObject` to/from an array of bytes in base
-      ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
+   .. seealso:: :c:func:`PyLong_AsNativeBytes()` and
+      :c:func:`PyLong_FromNativeBytes()` functions could be used to convert
+      a :c:type:`PyLongObject` to/from an array of bytes in base ``256``.
 
 
 .. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)


Code review comments:
diff_hunk: @@ -94,9 +94,9 @@ distinguished from a number.  Use :c:func:`PyErr_Occurred` to disambiguate.
    ignored.  If there are no digits or *str* is not NULL-terminated following the
    digits and trailing whitespace, :exc:`ValueError` will be raised.
 
-   .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
-      to convert a :c:type:`PyLongObject` to/from an array of bytes in base
-      ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
+   .. seealso:: :c:func:`PyLong_AsNativeBytes()` and
+      :c:func:`PyLong_FromNativeBytes()` functions could be used to convert
path: Doc/c-api/long.rst
text: @user1:
```suggestion
      :c:func:`PyLong_FromNativeBytes()` functions can be used to convert
```