View | Details | Raw Unified | Return to bug 244405
Collapse All | Expand All

(-)mail/py-milter/Makefile (-9 / +2 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	milter
4
PORTNAME=	milter
5
PORTVERSION=	1.0.2
5
PORTVERSION=	1.0.4
6
PORTREVISION=	1
7
DISTVERSIONPREFIX=	${GH_PROJECT}-
6
DISTVERSIONPREFIX=	${GH_PROJECT}-
8
CATEGORIES=	mail python
7
CATEGORIES=	mail python
9
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
8
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
Lines 29-38 Link Here
29
post-install:
28
post-install:
30
	${STRIP_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/milter.so
29
	${STRIP_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/milter.so
31
30
32
.include <bsd.port.pre.mk>
31
.include <bsd.port.mk>
33
34
.if ${FLAVOR:Upy36:Mpy3*}
35
EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-miltermodule.c
36
.endif
37
38
.include <bsd.port.post.mk>
(-)mail/py-milter/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1528123349
1
TIMESTAMP = 1582652875
2
SHA256 (sdgathman-pymilter-pymilter-1.0.2_GH0.tar.gz) = f513053f5fc9b0c31d886d8412a411bdc958786a673d7071b1bd521498b01153
2
SHA256 (sdgathman-pymilter-pymilter-1.0.4_GH0.tar.gz) = f871e29d2bb4bb192e9d9a1f205278f55cb0092a6c8c84ab698171924e4d2a2c
3
SIZE (sdgathman-pymilter-pymilter-1.0.2_GH0.tar.gz) = 1022535
3
SIZE (sdgathman-pymilter-pymilter-1.0.4_GH0.tar.gz) = 1023222
(-)mail/py-milter/files/extra-patch-miltermodule.c (-172 lines)
Lines 1-172 Link Here
1
--- miltermodule.c.orig	2016-12-13 19:17:34 UTC
2
+++ miltermodule.c
3
@@ -343,7 +343,7 @@ static struct MilterCallback {
4
       { NULL , NULL }
5
     };
6
 
7
-staticforward struct smfiDesc description; /* forward declaration */
8
+static struct smfiDesc description; /* forward declaration */
9
 
10
 static PyObject *MilterError;
11
 /* The interpreter instance that called milter.main */
12
@@ -355,7 +355,7 @@ typedef struct {
13
 
14
 static milter_Diag diag;
15
 
16
-staticforward PyTypeObject milter_ContextType;
17
+static PyTypeObject milter_ContextType;
18
 
19
 typedef struct {
20
   PyObject_HEAD
21
@@ -700,7 +700,7 @@ _generic_wrapper(milter_ContextObject *s
22
   result = PyEval_CallObject(cb, arglist);
23
   Py_DECREF(arglist);
24
   if (result == NULL) return _report_exception(self);
25
-  if (!PyInt_Check(result)) {
26
+  if (!PyLong_Check(result)) {
27
     const struct MilterCallback *p;
28
     const char *cbname = "milter";
29
     char buf[40];
30
@@ -715,7 +715,7 @@ _generic_wrapper(milter_ContextObject *s
31
     PyErr_SetString(MilterError,buf);
32
     return _report_exception(self);
33
   }
34
-  retval = PyInt_AS_LONG(result);
35
+  retval = PyLong_AS_LONG(result);
36
   Py_DECREF(result);
37
   _release_thread(self->t);
38
   return retval;
39
@@ -732,7 +732,7 @@ makeipaddr(struct sockaddr_in *addr) {
40
 	sprintf(buf, "%d.%d.%d.%d",
41
 		(int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
42
 		(int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
43
-	return PyString_FromString(buf);
44
+	return PyUnicode_FromString(buf);
45
 }
46
 
47
 #ifdef HAVE_IPV6_SUPPORT
48
@@ -740,8 +740,8 @@ static PyObject *
49
 makeip6addr(struct sockaddr_in6 *addr) {
50
 	char buf[100]; /* must be at least INET6_ADDRSTRLEN + 1 */
51
 	const char *s = inet_ntop(AF_INET6, &addr->sin6_addr, buf, sizeof buf);
52
-	if (s) return PyString_FromString(s);
53
-	return PyString_FromString("inet6:unknown");
54
+	if (s) return PyUnicode_FromString(s);
55
+	return PyUnicode_FromString("inet6:unknown");
56
 }
57
 #endif
58
 
59
@@ -832,7 +832,7 @@ generic_env_wrapper(SMFICTX *ctx, PyObje
60
    for (i=0;i<count;i++) {
61
      /* There's some error checking performed in do_mkvalue() for a string */
62
      /* that's not currently done here - it probably should be */
63
-     PyObject *o = PyString_FromStringAndSize(argv[i], strlen(argv[i]));
64
+     PyObject *o = PyUnicode_FromStringAndSize(argv[i], strlen(argv[i]));
65
      if (o == NULL) {	/* out of memory */
66
        Py_DECREF(arglist);
67
        return _report_exception(self);
68
@@ -889,7 +889,7 @@ milter_wrap_body(SMFICTX *ctx, u_char *b
69
    c = _get_context(ctx);
70
    if (!c) return SMFIS_TEMPFAIL;
71
    /* Unclear whether this should be s#, z#, or t# */
72
-   arglist = Py_BuildValue("(Os#)", c, bodyp, bodylen);
73
+   arglist = Py_BuildValue("(Oy#)", c, bodyp, bodylen);
74
    return _generic_wrapper(c, body_callback, arglist);
75
 }
76
 
77
@@ -963,7 +963,7 @@ milter_wrap_negotiate(SMFICTX *ctx,
78
     int i;
79
     for (i = 0; i < 4; ++i) {
80
       *pa[i] = (i <= len)
81
-      	? PyInt_AsUnsignedLongMask(PyList_GET_ITEM(optlist,i))
82
+      	? PyLong_AsUnsignedLongMask(PyList_GET_ITEM(optlist,i))
83
 	: fa[i];
84
     }
85
     if (PyErr_Occurred()) {
86
@@ -1551,11 +1551,6 @@ static PyMethodDef context_methods[] = {
87
   { NULL, NULL }
88
 };
89
 
90
-static PyObject *
91
-milter_Context_getattr(PyObject *self, char *name) {
92
-  return Py_FindMethod(context_methods, self, name);
93
-}
94
-
95
 static struct smfiDesc description = {  /* Set some reasonable defaults */
96
   "pythonfilter",
97
   SMFI_VERSION,
98
@@ -1604,14 +1599,13 @@ static PyMethodDef milter_methods[] = {
99
 };
100
 
101
 static PyTypeObject milter_ContextType = {
102
-  PyObject_HEAD_INIT(&PyType_Type)
103
-  0,
104
-  "milterContext",
105
+  PyVarObject_HEAD_INIT(&PyType_Type,0)
106
+  "milter.Context",
107
   sizeof(milter_ContextObject),
108
   0,
109
         milter_Context_dealloc,            /* tp_dealloc */
110
         0,               /* tp_print */
111
-        milter_Context_getattr,           /* tp_getattr */
112
+        0,           /* tp_getattr */
113
         0,			/* tp_setattr */
114
         0,                                      /* tp_compare */
115
         0,                 /* tp_repr */
116
@@ -1625,6 +1619,13 @@ static PyTypeObject milter_ContextType =
117
         0,                                      /* tp_setattro */
118
         0,                                      /* tp_as_buffer */
119
         Py_TPFLAGS_DEFAULT,                     /* tp_flags */
120
+	NULL,	/* Documentation string */
121
+	0, 	/* call function for all accessible objects */
122
+    	0,	/* delete references to contained objects */
123
+    	0,	/* rich comparisons */
124
+    	0,	/* weak reference enabler */
125
+    	0, 0,	/* Iterators */
126
+    	context_methods, /* Attribute descriptor and subclassing stuff */
127
 };
128
 
129
 static const char milter_documentation[] =
130
@@ -1634,17 +1635,31 @@ Libmilter is currently marked FFR, and n
131
 See <sendmailsource>/libmilter/README for details on setting it up.\n";
132
 
133
 static void setitem(PyObject *d,const char *name,long val) {
134
-  PyObject *v = PyInt_FromLong(val);
135
+  PyObject *v = PyLong_FromLong(val);
136
   PyDict_SetItemString(d,name,v);
137
   Py_DECREF(v);
138
 }
139
 
140
-void
141
-initmilter(void) {
142
+static struct PyModuleDef moduledef = {
143
+    PyModuleDef_HEAD_INIT,
144
+    "milter",     	 /* m_name */
145
+    milter_documentation,/* m_doc */
146
+    -1,                  /* m_size */
147
+    milter_methods,      /* m_methods */
148
+    NULL,                /* m_reload */
149
+    NULL,                /* m_traverse */
150
+    NULL,                /* m_clear */
151
+    NULL,                /* m_free */
152
+};
153
+
154
+PyMODINIT_FUNC PyInit_milter(void) {
155
    PyObject *m, *d;
156
 
157
-   m = Py_InitModule4("milter", milter_methods, milter_documentation,
158
-		      (PyObject*)NULL, PYTHON_API_VERSION);
159
+   if (PyType_Ready(&milter_ContextType) < 0)
160
+          return NULL;
161
+
162
+   m = PyModule_Create(&moduledef);
163
+   if (m == NULL) return NULL;
164
    d = PyModule_GetDict(m);
165
    MilterError = PyErr_NewException("milter.error", NULL, NULL);
166
    PyDict_SetItemString(d,"error", MilterError);
167
@@ -1710,4 +1725,5 @@ initmilter(void) {
168
    setitem(d,"DISCARD",  SMFIS_DISCARD);
169
    setitem(d,"ACCEPT",  SMFIS_ACCEPT);
170
    setitem(d,"TEMPFAIL",  SMFIS_TEMPFAIL);
171
+   return m;
172
 }
(-)mail/py-milter/files/patch-Milter-dns.py (-13 lines)
Lines 1-13 Link Here
1
--- Milter/dns.py.orig	2016-12-13 19:17:34 UTC
2
+++ Milter/dns.py
3
@@ -26,8 +26,8 @@ def DNSLookup(name, qtype):
4
         # A RR as dotted quad.  For consistency, this driver should
5
         # return both as binary string.
6
         return [((a['name'], a['typename']), a['data']) for a in resp.answers]
7
-    except IOError, x:
8
-        raise DNSError, str(x)
9
+    except IOError as x:
10
+        raise DNSError(str(x))
11
 
12
 class Session(object):
13
   """A Session object has a simple cache with no TTL that is valid
(-)mail/py-milter/files/patch-Milter-dsn.py (-19 lines)
Lines 1-19 Link Here
1
--- Milter/dsn.py.orig	2016-12-13 19:17:34 UTC
2
+++ Milter/dsn.py
3
@@ -142,13 +142,13 @@ def send_dsn(mailfrom,receiver,msg=None,
4
         if badrcpts:
5
           return badrcpts
6
       return None			# success
7
-    except smtplib.SMTPRecipientsRefused,x:
8
+    except smtplib.SMTPRecipientsRefused as x:
9
       if len(x.recipients) == 1:
10
         return x.recipients.values()[0]	# permanent error
11
       return x.recipients
12
-    except smtplib.SMTPSenderRefused,x:
13
+    except smtplib.SMTPSenderRefused as x:
14
       return x.args[:2]			# does not accept DSN
15
-    except smtplib.SMTPDataError,x:
16
+    except smtplib.SMTPDataError as x:
17
       return x.args			# permanent error
18
     except smtplib.SMTPException:
19
       pass		# any other error, try next MX
(-)mail/py-milter/pkg-descr (-1 / +1 lines)
Lines 2-5 Link Here
2
sendmail's libmilter functionality. Additional python modules provide for
2
sendmail's libmilter functionality. Additional python modules provide for
3
navigating and modifying MIME parts, and sending DSNs or doing CBVs.
3
navigating and modifying MIME parts, and sending DSNs or doing CBVs.
4
4
5
WWW: http://www.bmsi.com/python/milter.html
5
WWW: https://pythonhosted.org/milter/

Return to bug 244405