git: b088cd6d6d2d - main - devel/py-omnijson: Fix build with setuptools 58.0.0+

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

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

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

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

diff --git a/devel/py-omnijson/files/patch-2to3 b/devel/py-omnijson/files/patch-2to3
new file mode 100644
index 000000000000..72fcd402ce7a
--- /dev/null
+++ b/devel/py-omnijson/files/patch-2to3
@@ -0,0 +1,209 @@
+--- omnijson/packages/simplejson/decoder.py.orig	2011-06-19 16:43:47 UTC
++++ omnijson/packages/simplejson/decoder.py
+@@ -87,8 +87,8 @@ _CONSTANTS = {
+ 
+ STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
+ BACKSLASH = {
+-    '"': u'"', '\\': u'\\', '/': u'/',
+-    'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
++    '"': '"', '\\': '\\', '/': '/',
++    'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t',
+ }
+ 
+ DEFAULT_ENCODING = "utf-8"
+@@ -117,8 +117,8 @@ def py_scanstring(s, end, encoding=None, strict=True,
+         content, terminator = chunk.groups()
+         # Content is contains zero or more unescaped string characters
+         if content:
+-            if not isinstance(content, unicode):
+-                content = unicode(content, encoding)
++            if not isinstance(content, str):
++                content = str(content, encoding)
+             _append(content)
+         # Terminator is the end of string, a literal control character,
+         # or a backslash denoting that an escape sequence follows
+@@ -164,11 +164,11 @@ def py_scanstring(s, end, encoding=None, strict=True,
+                 uni2 = int(esc2, 16)
+                 uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
+                 next_end += 6
+-            char = unichr(uni)
++            char = chr(uni)
+             end = next_end
+         # Append the unescaped character
+         _append(char)
+-    return u''.join(chunks), end
++    return ''.join(chunks), end
+ 
+ 
+ # Use speedup if available
+@@ -177,10 +177,11 @@ scanstring = c_scanstring or py_scanstring
+ WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
+ WHITESPACE_STR = ' \t\n\r'
+ 
+-def JSONObject((s, end), encoding, strict, scan_once, object_hook,
++def JSONObject(xxx_todo_changeme, encoding, strict, scan_once, object_hook,
+         object_pairs_hook, memo=None,
+         _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+     # Backwards compatibility
++    (s, end) = xxx_todo_changeme
+     if memo is None:
+         memo = {}
+     memo_get = memo.setdefault
+@@ -269,7 +270,8 @@ def JSONObject((s, end), encoding, strict, scan_once, 
+         pairs = object_hook(pairs)
+     return pairs, end
+ 
+-def JSONArray((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
++def JSONArray(xxx_todo_changeme1, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
++    (s, end) = xxx_todo_changeme1
+     values = []
+     nextchar = s[end:end + 1]
+     if nextchar in _ws:
+--- omnijson/packages/simplejson/encoder.py.orig	2011-06-19 16:43:47 UTC
++++ omnijson/packages/simplejson/encoder.py
+@@ -39,7 +39,7 @@ def encode_basestring(s):
+         s = s.decode('utf-8')
+     def replace(match):
+         return ESCAPE_DCT[match.group(0)]
+-    return u'"' + ESCAPE.sub(replace, s) + u'"'
++    return '"' + ESCAPE.sub(replace, s) + '"'
+ 
+ 
+ def py_encode_basestring_ascii(s):
+@@ -160,7 +160,7 @@ class JSONEncoder(object):
+         self.allow_nan = allow_nan
+         self.sort_keys = sort_keys
+         self.use_decimal = use_decimal
+-        if isinstance(indent, (int, long)):
++        if isinstance(indent, int):
+             indent = ' ' * indent
+         self.indent = indent
+         if separators is not None:
+@@ -200,7 +200,7 @@ class JSONEncoder(object):
+ 
+         """
+         # This is for extremely simple cases and benchmarks.
+-        if isinstance(o, basestring):
++        if isinstance(o, str):
+             if isinstance(o, str):
+                 _encoding = self.encoding
+                 if (_encoding is not None
+@@ -219,7 +219,7 @@ class JSONEncoder(object):
+         if self.ensure_ascii:
+             return ''.join(chunks)
+         else:
+-            return u''.join(chunks)
++            return ''.join(chunks)
+ 
+     def iterencode(self, o, _one_shot=False):
+         """Encode the given object and yield each string
+@@ -302,7 +302,7 @@ class JSONEncoderForHTML(JSONEncoder):
+         if self.ensure_ascii:
+             return ''.join(chunks)
+         else:
+-            return u''.join(chunks)
++            return ''.join(chunks)
+ 
+     def iterencode(self, o, _one_shot=False):
+         chunks = super(JSONEncoderForHTML, self).iterencode(o, _one_shot)
+@@ -317,10 +317,8 @@ def _make_iterencode(markers, _default, _encoder, _ind
+         _key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,
+         _use_decimal,
+         ## HACK: hand-optimized bytecode; turn globals into locals
+-        False=False,
+-        True=True,
+         ValueError=ValueError,
+-        basestring=basestring,
++        str=str,
+         Decimal=Decimal,
+         dict=dict,
+         float=float,
+@@ -328,8 +326,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+         int=int,
+         isinstance=isinstance,
+         list=list,
+-        long=long,
+-        str=str,
++        long=int,
+         tuple=tuple,
+     ):
+ 
+@@ -357,7 +354,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+                 first = False
+             else:
+                 buf = separator
+-            if isinstance(value, basestring):
++            if isinstance(value, str):
+                 yield buf + _encoder(value)
+             elif value is None:
+                 yield buf + 'null'
+@@ -365,7 +362,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+                 yield buf + 'true'
+             elif value is False:
+                 yield buf + 'false'
+-            elif isinstance(value, (int, long)):
++            elif isinstance(value, int):
+                 yield buf + str(value)
+             elif isinstance(value, float):
+                 yield buf + _floatstr(value)
+@@ -408,12 +405,12 @@ def _make_iterencode(markers, _default, _encoder, _ind
+             item_separator = _item_separator
+         first = True
+         if _sort_keys:
+-            items = dct.items()
++            items = list(dct.items())
+             items.sort(key=lambda kv: kv[0])
+         else:
+-            items = dct.iteritems()
++            items = iter(dct.items())
+         for key, value in items:
+-            if isinstance(key, basestring):
++            if isinstance(key, str):
+                 pass
+             # JavaScript is weakly typed for these, so it makes sense to
+             # also allow them.  Many encoders seem to do something like this.
+@@ -425,7 +422,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+                 key = 'false'
+             elif key is None:
+                 key = 'null'
+-            elif isinstance(key, (int, long)):
++            elif isinstance(key, int):
+                 key = str(key)
+             elif _skipkeys:
+                 continue
+@@ -437,7 +434,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+                 yield item_separator
+             yield _encoder(key)
+             yield _key_separator
+-            if isinstance(value, basestring):
++            if isinstance(value, str):
+                 yield _encoder(value)
+             elif value is None:
+                 yield 'null'
+@@ -445,7 +442,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+                 yield 'true'
+             elif value is False:
+                 yield 'false'
+-            elif isinstance(value, (int, long)):
++            elif isinstance(value, int):
+                 yield str(value)
+             elif isinstance(value, float):
+                 yield _floatstr(value)
+@@ -468,7 +465,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+             del markers[markerid]
+ 
+     def _iterencode(o, _current_indent_level):
+-        if isinstance(o, basestring):
++        if isinstance(o, str):
+             yield _encoder(o)
+         elif o is None:
+             yield 'null'
+@@ -476,7 +473,7 @@ def _make_iterencode(markers, _default, _encoder, _ind
+             yield 'true'
+         elif o is False:
+             yield 'false'
+-        elif isinstance(o, (int, long)):
++        elif isinstance(o, int):
+             yield str(o)
+         elif isinstance(o, float):
+             yield _floatstr(o)