git: 617bcc40fc1c - main - devel/py-Products.ExternalEditor: Fix build with setuptools 58.0.0+

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Fri, 25 Mar 2022 13:49:50 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=617bcc40fc1cf7f5dced580e0d471a8839c2a807

commit 617bcc40fc1cf7f5dced580e0d471a8839c2a807
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-03-25 13:32:10 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-03-25 13:38:07 +0000

    devel/py-Products.ExternalEditor: Fix build with setuptools 58.0.0+
    
    With hat:       python
---
 devel/py-Products.ExternalEditor/files/patch-2to3 | 64 +++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/devel/py-Products.ExternalEditor/files/patch-2to3 b/devel/py-Products.ExternalEditor/files/patch-2to3
new file mode 100644
index 000000000000..55bdf96341c3
--- /dev/null
+++ b/devel/py-Products.ExternalEditor/files/patch-2to3
@@ -0,0 +1,64 @@
+--- Products/ExternalEditor/ExternalEditor.py.orig	2010-12-03 03:58:58 UTC
++++ Products/ExternalEditor/ExternalEditor.py
+@@ -18,7 +18,7 @@
+ 
+ from string import join # For Zope 2.3 compatibility
+ import types
+-import urllib
++import urllib.request, urllib.parse, urllib.error
+ from Acquisition import aq_inner, aq_base, aq_parent, Implicit
+ try:
+     from App.class_init import InitializeClass
+@@ -55,11 +55,11 @@ class PDataStreamIterator:
+     def __iter__(self):
+         return self
+ 
+-    def next(self):
++    def __next__(self):
+         if self.data is None:
+-            raise StopIteration
++            raise(StopIteration)
+         data = self.data.data
+-        self.data = self.data.next
++        self.data = self.data.__next__
+         return data
+ 
+ def registerCallback(cb):
+@@ -125,8 +125,8 @@ class ExternalEditor(Implicit):
+         if title is not None:
+             if callable(title):
+                 title = title()
+-            if isinstance(title, types.UnicodeType):
+-                title = unicode.encode(title, 'utf-8')
++            if isinstance(title, str):
++                title = str.encode(title, 'utf-8')
+             r.append('title:%s' % title)
+ 
+         if hasattr(aq_base(ob), 'content_type'):
+@@ -214,7 +214,7 @@ class ExternalEditor(Implicit):
+             body = ob.read()
+         else:
+             # can't read it!
+-            raise 'BadRequest', 'Object does not support external editing'
++            raise BadRequest('Object does not support external editing')
+ 
+         if (HAVE_Z3_IFACE and IStreamIterator.providedBy(body) or
+             (not HAVE_Z3_IFACE) and IStreamIterator.isImplementedBy(body)):
+@@ -287,7 +287,7 @@ def EditLink(self, object, borrow_lock=0, skip_data=0)
+         if skip_data:
+             query['skip_data'] = 1
+         url = "%s/externalEdit_/%s%s%s" % (aq_parent(aq_inner(object)).absolute_url(),
+-                                           urllib.quote(object.getId()),
++                                           urllib.parse.quote(object.getId()),
+                                            ext, querystr(query))
+         return ('<a href="%s" '
+                 'title="Edit using external editor">'
+@@ -302,7 +302,7 @@ def querystr(d):
+     """Create a query string from a dict"""
+     if d:
+         return '?' + '&'.join(
+-            ['%s=%s' % (name, val) for name, val in d.items()])
++            ['%s=%s' % (name, val) for name, val in list(d.items())])
+     else:
+         return ''
+