python-gmp 0.4.0b5__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/os.yml +1 -1
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/wheels.yml +1 -1
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/PKG-INFO +2 -2
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/gmp.c +20 -10
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/pyproject.toml +1 -1
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/test_mpz.py +4 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/zz.c +2 -2
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.clang-format +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/dependabot.yml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/ci.yml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/coverage.yml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/linter.yml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.github/workflows/publish.yml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.gitignore +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.pre-commit-config.yaml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/.readthedocs.yaml +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/LICENSE +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/README.rst +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/docs/conf.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/docs/index.rst +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/fmt.c +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/meson.build +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/mpz.h +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/pythoncapi_compat.h +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/scripts/cibw_before_all.sh +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/scripts/dll-importexport.diff +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/scripts/fat_build_fix.diff +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/conftest.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/test_api.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/test_functions.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/test_memory.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/tests/test_utils.py +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/utils.c +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/utils.h +0 -0
- {python_gmp-0.4.0b5 → python_gmp-0.4.1}/zz.h +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-gmp
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Safe bindings to the GNU GMP library
|
|
5
5
|
Keywords: gmp,multiple-precision,arbitrary-precision,bignum
|
|
6
6
|
Author-Email: Sergey B Kirpichev <skirpichev@gmail.com>
|
|
@@ -39,7 +39,7 @@ Requires-Python: >=3.9
|
|
|
39
39
|
Provides-Extra: tests
|
|
40
40
|
Requires-Dist: pytest; extra == "tests"
|
|
41
41
|
Requires-Dist: hypothesis; extra == "tests"
|
|
42
|
-
Requires-Dist: mpmath>=1.4.
|
|
42
|
+
Requires-Dist: mpmath>=1.4.0a7; extra == "tests"
|
|
43
43
|
Provides-Extra: docs
|
|
44
44
|
Requires-Dist: sphinx>=8.2; extra == "docs"
|
|
45
45
|
Provides-Extra: develop
|
|
@@ -65,6 +65,7 @@ PyObject *
|
|
|
65
65
|
MPZ_to_str(MPZ_Object *u, int base, int options)
|
|
66
66
|
{
|
|
67
67
|
size_t len;
|
|
68
|
+
bool negative = zz_isneg(&u->z);
|
|
68
69
|
|
|
69
70
|
if ((base < INT8_MIN || base > INT8_MAX)
|
|
70
71
|
|| zz_sizeinbase(&u->z, (int8_t)base, &len))
|
|
@@ -79,8 +80,7 @@ MPZ_to_str(MPZ_Object *u, int base, int options)
|
|
|
79
80
|
}
|
|
80
81
|
len++;
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
bool negative = zz_isneg(&u->z), cast_abs = false;
|
|
83
|
+
char *buf = malloc(len), *p = buf, saved_char = 0;
|
|
84
84
|
|
|
85
85
|
if (!buf) {
|
|
86
86
|
return PyErr_NoMemory(); /* LCOV_EXCL_LINE */
|
|
@@ -92,7 +92,7 @@ MPZ_to_str(MPZ_Object *u, int base, int options)
|
|
|
92
92
|
if (options & OPT_PREFIX) {
|
|
93
93
|
if (negative) {
|
|
94
94
|
*(p++) = '-';
|
|
95
|
-
|
|
95
|
+
saved_char = '-';
|
|
96
96
|
}
|
|
97
97
|
if (base == 2) {
|
|
98
98
|
*(p++) = '0';
|
|
@@ -111,14 +111,15 @@ MPZ_to_str(MPZ_Object *u, int base, int options)
|
|
|
111
111
|
*(p++) = 'X';
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
if (
|
|
115
|
-
(
|
|
114
|
+
if (saved_char) {
|
|
115
|
+
saved_char = *(--p);
|
|
116
|
+
assert(saved_char);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
zz_err ret = zz_to_str(&u->z, (int8_t)base, p, &len);
|
|
119
|
+
zz_err ret = zz_to_str(&u->z, (int8_t)base, (int8_t *)p, &len);
|
|
119
120
|
|
|
120
|
-
if (
|
|
121
|
-
|
|
121
|
+
if (saved_char) {
|
|
122
|
+
*p = saved_char;
|
|
122
123
|
}
|
|
123
124
|
if (ret) {
|
|
124
125
|
free(buf);
|
|
@@ -374,18 +375,27 @@ MPZ_to_bytes(MPZ_Object *u, Py_ssize_t length, int is_little, int is_signed)
|
|
|
374
375
|
}
|
|
375
376
|
return bytes;
|
|
376
377
|
}
|
|
377
|
-
Py_DECREF(bytes);
|
|
378
378
|
if (ret == ZZ_BUF) {
|
|
379
379
|
if (zz_isneg(&u->z) && !is_signed) {
|
|
380
380
|
PyErr_SetString(PyExc_OverflowError,
|
|
381
381
|
"can't convert negative mpz to unsigned");
|
|
382
382
|
}
|
|
383
383
|
else {
|
|
384
|
+
#if (PY_VERSION_HEX < 0x030D08F0 || (PY_VERSION_HEX >= 0x030E0000 \
|
|
385
|
+
&& PY_VERSION_HEX < 0x030E00C3))
|
|
386
|
+
if (!length && zz_cmp_i32(&u->z, -1) == ZZ_EQ) {
|
|
387
|
+
return bytes;
|
|
388
|
+
}
|
|
389
|
+
#endif
|
|
384
390
|
PyErr_SetString(PyExc_OverflowError, "int too big to convert");
|
|
385
391
|
}
|
|
392
|
+
Py_DECREF(bytes);
|
|
386
393
|
return NULL;
|
|
387
394
|
}
|
|
388
|
-
|
|
395
|
+
/* LCOV_EXCL_START */
|
|
396
|
+
Py_DECREF(bytes);
|
|
397
|
+
return PyErr_NoMemory();
|
|
398
|
+
/* LCOV_EXCL_STOP */
|
|
389
399
|
}
|
|
390
400
|
|
|
391
401
|
static MPZ_Object *
|
|
@@ -47,7 +47,7 @@ Documentation = "https://python-gmp.readthedocs.io/en/latest/"
|
|
|
47
47
|
[tool.setuptools_scm]
|
|
48
48
|
|
|
49
49
|
[project.optional-dependencies]
|
|
50
|
-
tests = ["pytest", "hypothesis", "mpmath>=1.4.
|
|
50
|
+
tests = ["pytest", "hypothesis", "mpmath>=1.4.0a7"]
|
|
51
51
|
docs = ["sphinx>=8.2"]
|
|
52
52
|
develop = ["python-gmp[tests,docs]", "pre-commit", "pyperf"]
|
|
53
53
|
|
|
@@ -700,8 +700,8 @@ zz_to_bytes(const zz_t *u, size_t length, bool is_signed, uint8_t **buffer)
|
|
|
700
700
|
size_t nbits = zz_bitlen(u);
|
|
701
701
|
|
|
702
702
|
if (nbits > 8*length
|
|
703
|
-
|| (is_signed && nbits
|
|
704
|
-
&& (nbits == 8 * length ? !is_negative : is_negative)))
|
|
703
|
+
|| (is_signed && ((!nbits && is_negative)
|
|
704
|
+
|| (nbits && (nbits == 8 * length ? !is_negative : is_negative)))))
|
|
705
705
|
{
|
|
706
706
|
overflow:
|
|
707
707
|
zz_clear(&tmp);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|