From 50653c5cb4475ceeb7c63b9cc685ff532c9148e2 Mon Sep 17 00:00:00 2001 From: MementoMori <1003350679@qq.com> Date: Tue, 18 Jan 2022 10:05:34 +0800 Subject: [PATCH] delete 2to3 --- fix_up_2to3.patch | 152 ++++++++++++++++++++++++++++++++++++++++++++ python-anyjson.spec | 11 +++- 2 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 fix_up_2to3.patch diff --git a/fix_up_2to3.patch b/fix_up_2to3.patch new file mode 100644 index 0000000..361a84d --- /dev/null +++ b/fix_up_2to3.patch @@ -0,0 +1,152 @@ + +diff -Naru anyjson-0.3.3/anyjson/__init__.py anyjson-0.3.3/anyjson/__init__.py +--- anyjson-0.3.3/anyjson/__init__.py 2012-06-22 07:08:51.000000000 +0800 ++++ anyjson-0.3.3/anyjson/__init__.py 2022-01-18 09:42:42.000000000 +0800 +@@ -23,9 +23,9 @@ + from io import StringIO + else: + try: +- from cStringIO import StringIO # noqa ++ from io import StringIO # noqa + except ImportError: +- from StringIO import StringIO # noqa ++ from io import StringIO # noqa + + #: List of known json modules, and the names of their loads/dumps + #: methods, as well as the exceptions they throw. Exception can be either +@@ -47,7 +47,7 @@ + """Incapsulates a JSON implementation""" + + def __init__(self, modspec): +- modinfo = dict(zip(_fields, modspec)) ++ modinfo = dict(list(zip(_fields, modspec))) + + if modinfo["modname"] == "cjson": + import warnings +@@ -64,9 +64,9 @@ + self._encode_error = modinfo["encerror"] + self._decode_error = modinfo["decerror"] + +- if isinstance(modinfo["encerror"], basestring): ++ if isinstance(modinfo["encerror"], str): + self._encode_error = getattr(module, modinfo["encerror"]) +- if isinstance(modinfo["decerror"], basestring): ++ if isinstance(modinfo["decerror"], str): + self._decode_error = getattr(module, modinfo["decerror"]) + + self.name = modinfo["modname"] +@@ -85,8 +85,8 @@ + TypeError if the object could not be serialized.""" + try: + return self._encode(data) +- except self._encode_error, exc: +- raise TypeError, TypeError(*exc.args), sys.exc_info()[2] ++ except self._encode_error as exc: ++ raise TypeError(TypeError(*exc.args)).with_traceback(sys.exc_info()[2]) + serialize = dumps + + def loads(self, s): +@@ -94,11 +94,11 @@ + ValueError if the string could not be parsed.""" + # uses StringIO to support buffer objects. + try: +- if self._filedecode and not isinstance(s, basestring): ++ if self._filedecode and not isinstance(s, str): + return self._filedecode(StringIO(s)) + return self._decode(s) +- except self._decode_error, exc: +- raise ValueError, ValueError(*exc.args), sys.exc_info()[2] ++ except self._decode_error as exc: ++ raise ValueError(ValueError(*exc.args)).with_traceback(sys.exc_info()[2]) + deserialize = loads + + +@@ -117,7 +117,7 @@ + # We do NOT try to load a compatible module because that may throw an + # exception, which renders the package uninstallable with easy_install + # (It trys to execfile the script when installing, to make sure it works) +- print "Running anyjson as a stand alone script is not supported" ++ print("Running anyjson as a stand alone script is not supported") + sys.exit(1) + else: + for modspec in _modules: +diff -Naru anyjson-0.3.3/setup.py anyjson-0.3.3/setup.py +--- anyjson-0.3.3/setup.py 2012-06-22 06:59:59.000000000 +0800 ++++ anyjson-0.3.3/setup.py 2022-01-18 09:51:44.000000000 +0800 +@@ -1,9 +1,6 @@ + import os +-import sys + + extra = {} +-if sys.version_info >= (3, 0): +- extra.update(use_2to3=True) + + try: + from setuptools import setup, find_packages +diff -Naru anyjson-0.3.3/tests/benchmark.py anyjson-0.3.3/tests/benchmark.py +--- anyjson-0.3.3/tests/benchmark.py 2012-06-22 06:59:59.000000000 +0800 ++++ anyjson-0.3.3/tests/benchmark.py 2022-01-18 09:44:38.000000000 +0800 +@@ -4,7 +4,7 @@ + + import sys + import time +-import urllib ++import urllib.request, urllib.parse, urllib.error + + _small = """ + { +@@ -77,8 +77,8 @@ + + def load_external_json(): + global _reddit, _twitter +- _reddit = urllib.urlopen("http://reddit.com/.json").read() +- _twitter = urllib.urlopen("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitterapi&count=200").read() ++ _reddit = urllib.request.urlopen("http://reddit.com/.json").read() ++ _twitter = urllib.request.urlopen("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitterapi&count=200").read() + + + def do_benchmark(impspec, json, runs=10): +@@ -93,13 +93,13 @@ + return None + + start = time.time() +- for n in xrange(runs): ++ for n in range(runs): + data = reads(json) + + readtime = time.time() - start + + start = time.time() +- for n in xrange(runs): ++ for n in range(runs): + devnull = dumps(data) + + return readtime, time.time() - start # tuple (readtime, writetime) +@@ -131,13 +131,13 @@ + + no_res = set([e for e in res if e[1] is None]) + res = list(set(res) - no_res) +-res = [(e[0], sum(map(lambda x:x[0], e[1:])), sum(map(lambda x:x[1], e[1:]))) for e in res] ++res = [(e[0], sum([x[0] for x in e[1:]]), sum([x[1] for x in e[1:]])) for e in res] + + res.sort(lambda a,b: cmp((a[1]+a[2]), b[1]+b[2])) + +-print "Total Read Write Implementation" +-print "-----------------------------------" ++print("Total Read Write Implementation") ++print("-----------------------------------") + for e in res: +- print "%.3f %.3f %.3f %s" % (e[1]+e[2], e[1], e[2], e[0]) ++ print("%.3f %.3f %.3f %s" % (e[1]+e[2], e[1], e[2], e[0])) + for e in no_res: +- print "Not installed:", e[0] ++ print("Not installed:", e[0]) +diff -Naru anyjson-0.3.3/tests/test_implementations.py anyjson-0.3.3/tests/test_implementations.py +--- anyjson-0.3.3/tests/test_implementations.py 2012-06-22 06:59:59.000000000 +0800 ++++ anyjson-0.3.3/tests/test_implementations.py 2022-01-18 09:44:49.000000000 +0800 +@@ -54,4 +54,4 @@ + except ImportError: + return + +- assert "foo" in anyjson.loads(u'{"foo": "bar"}') ++ assert "foo" in anyjson.loads('{"foo": "bar"}') diff --git a/python-anyjson.spec b/python-anyjson.spec index 34c6173..1bc4a3e 100644 --- a/python-anyjson.spec +++ b/python-anyjson.spec @@ -1,11 +1,15 @@ %global _empty_manifest_terminate_build 0 Name: python-anyjson Version: 0.3.3 -Release: 1 +Release: 2 Summary: Wraps the best available JSON implementation available in a common interface License: BSD URL: http://bitbucket.org/runeh/anyjson/ Source0: https://files.pythonhosted.org/packages/c3/4d/d4089e1a3dd25b46bebdb55a992b0797cff657b4477bc32ce28038fdecbc/anyjson-0.3.3.tar.gz + +#Patch to fix up 2to3 +Patch0: fix_up_2to3.patch + BuildArch: noarch @@ -30,7 +34,7 @@ Anyjson loads whichever is the fastest JSON module installed and provides a uniform API regardless of which JSON implementation is used. %prep -%autosetup -n anyjson-0.3.3 +%autosetup -n anyjson-0.3.3 -p1 %build %py3_build @@ -70,5 +74,8 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog +* Tue Jan 18 2022 Chengshaowei - 0.3.3-2 +- delete 2to3 + * Mon Jul 06 2020 Python_Bot - Package Spec generated -- Gitee