algorithms.c: Add missing guard for `del' to property `set' functions.
[catacomb-python] / field.c
diff --git a/field.c b/field.c
index 1f316f3..fae0365 100644 (file)
--- a/field.c
+++ b/field.c
@@ -274,7 +274,7 @@ static PyObject *fe_pylong(PyObject *x)
 #define BASEOP(name, radix, pre)                                       \
   static PyObject *fe_py##name(PyObject *x) {                          \
     mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x));                          \
-    PyObject *rc = mp_topystring(FE_X(x), radix, 0, pre, 0);           \
+    PyObject *rc = mp_topystring(xx, radix, 0, pre, 0);                        \
     MP_DROP(xx);                                                       \
     return (rc);                                                       \
   }
@@ -525,7 +525,7 @@ static PyGetSetDef field_pygetset[] = {
 static PyMethodDef field_pymethods[] = {
 #define METHNAME(name) fmeth_##name
   METH (_adopt,        "F._adopt(X) -> FE")
-  KWMETH(rand,         "F.rand(rng = rand) -> FE, uniformly distributed")
+  KWMETH(rand,         "F.rand([rng = rand]) -> FE, uniformly distributed")
 #undef METHNAME
   { 0 }
 };
@@ -801,8 +801,11 @@ end:
   return (0);
 }
 
+static PyObject *bfget_p(PyObject *me, void *hunoz)
+  { return (gf_pywrap(MP_COPY(FIELD_F(me)->m))); }
+
 static PyGetSetDef binpolyfield_pygetset[] = {
-#define GETSETNAME(op, name) pf##op##_##name
+#define GETSETNAME(op, name) bf##op##_##name
   GET  (p,             "F.p -> field polynomial")
 #undef GETSETNAME
   { 0 }
@@ -881,7 +884,7 @@ static PyObject *bnfget_beta(PyObject *me, void *hunoz)
 }
 
 static PyGetSetDef binnormfield_pygetset[] = {
-#define GETSETNAME(op, name) pf##op##_##name
+#define GETSETNAME(op, name) bf##op##_##name
   GET  (p,             "F.p -> field polynomial")
 #undef GETSETNAME
 #define GETSETNAME(op, name) bnf##op##_##name