ec p = EC_INIT;
mp *y = 0;
ge *xx = 0;
+ size_t n;
mptext_stringctx sc;
g = GROUP_G(ty);
if (G_FROMINT(g, xx, y))
TYERR("can't convert from integer");
MP_DROP(y);
- } else if (PyString_Check(x)) {
- sc.buf = PyString_AS_STRING(x);
- sc.lim = sc.buf + PyString_GET_SIZE(x);
+ } else if (TEXT_CHECK(x)) {
+ TEXT_PTRLEN(x, sc.buf, n); sc.lim = sc.buf + n;
if (G_READ(g, xx, &mptext_stringops, &sc) || sc.buf < sc.lim)
VALERR("malformed group element string");
} else
mp *nn;
ge *z;
- if (m != Py_None || !GE_PYCHECK(x) || (nn = getmp(n)) == 0)
+ if (m != Py_None || !GE_PYCHECK(x)) RETURN_NOTIMPL;
+ if (FE_PYCHECK(n) && FE_F(n)->ops->ty == FTY_PRIME)
+ nn = F_OUT(FE_F(n), MP_NEW, FE_X(n));
+ else if ((nn = implicitmp(n)) == 0)
RETURN_NOTIMPL;
z = G_CREATE(GE_G(x));
G_EXP(GE_G(x), z, GE_X(x), nn);
PyObject *rc;
group_writedstr(GE_G(me), GE_X(me), &d);
- rc = PyString_FromStringAndSize(d.buf, d.len);
+ rc = TEXT_FROMSTRLEN(d.buf, d.len);
DDESTROY(&d);
return (rc);
}
+#ifdef PY2
static PyObject *ge_pylong(PyObject *me)
{
mp *x = 0;
mp_drop(x);
return (rc);
}
+#endif
static PyObject *ge_pyint(PyObject *me)
{
n = GE_G(me)->noctets + 4;
rc = bytestring_pywrap(0, n);
- buf_init(&b, PyString_AS_STRING(rc), n);
+ buf_init(&b, BIN_PTR(rc), n);
G_TOBUF(GE_G(me), &b, GE_X(me));
assert(BOK(&b));
- _PyString_Resize(&rc, BLEN(&b));
+ BIN_SETLEN(rc, BLEN(&b));
return (rc);
}
n = GE_G(me)->noctets;
rc = bytestring_pywrap(0, n);
- buf_init(&b, PyString_AS_STRING(rc), n);
+ buf_init(&b, BIN_PTR(rc), n);
G_TORAW(GE_G(me), &b, GE_X(me));
assert(BOK(&b));
- _PyString_Resize(&rc, BLEN(&b));
+ BIN_SETLEN(rc, BLEN(&b));
return (rc);
}
0, /* @nb_add@ */
0, /* @nb_subtract@ */
ge_pymul, /* @nb_multiply@ */
+#ifdef PY2
ge_pydiv, /* @nb_divide@ */
+#endif
0, /* @nb_remainder@ */
0, /* @nb_divmod@ */
ge_pyexp, /* @nb_power@ */
0, /* @nb_and@ */
0, /* @nb_xor@ */
0, /* @nb_or@ */
+#ifdef PY2
0, /* @nb_coerce@ */
+#endif
ge_pyint, /* @nb_int@ */
- ge_pylong, /* @nb_long@ */
+ PY23(ge_pylong, 0), /* @nb_long@ */
0 /* meaningless */, /* @nb_float@ */
+#ifdef PY2
0, /* @nb_oct@ */
0, /* @nb_hex@ */
+#endif
0, /* @nb_inplace_add@ */
0, /* @nb_inplace_subtract@ */
0, /* @nb_inplace_multiply@ */
+#ifdef PY2
0, /* @nb_inplace_divide@ */
+#endif
0, /* @nb_inplace_remainder@ */
0, /* @nb_inplace_power@ */
0, /* @nb_inplace_lshift@ */