Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-106320: Remove private _PyLong_Sign() #108743

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Include/cpython/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@

PyAPI_FUNC(PyObject*) PyLong_FromUnicodeObject(PyObject *u, int base);

/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
v must not be NULL, and must be a normalized long.
There are no error cases.
*/
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);

/* _PyLong_NumBits. Return the number of bits needed to represent the
absolute value of a long. For example, this returns 1 for 1 and -1, 2
for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
v must not be NULL, and must be a normalized long.
(size_t)-1 is returned and OverflowError set if the true result doesn't
fit in a size_t.
*/
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);

PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op);
PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op);

17 changes: 17 additions & 0 deletions Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ PyAPI_FUNC(PyLongObject*) _PyLong_FromDigits(
Py_ssize_t digit_count,
digit *digits);

// _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
// v must not be NULL, and must be a normalized long.
// There are no error cases.
//
// Export for '_pickle' shared extension.
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);

// _PyLong_NumBits. Return the number of bits needed to represent the
// absolute value of a long. For example, this returns 1 for 1 and -1, 2
// for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
// v must not be NULL, and must be a normalized long.
// (size_t)-1 is returned and OverflowError set if the true result doesn't
// fit in a size_t.
//
// Export for 'math' shared extension.
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);


/* runtime lifecycle */

Expand Down
1 change: 1 addition & 0 deletions Modules/_io/_iomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Python.h"
#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_long.h" // _PyLong_Sign()
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
#include "pycore_pystate.h" // _PyInterpreterState_GET()

Expand Down
5 changes: 5 additions & 0 deletions Modules/_testcapi/long.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "parts.h"
#include "clinic/long.c.h"
#include "pycore_long.h" // _PyLong_Sign()

/*[clinic input]
module _testcapi
Expand Down
Loading