mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update pprint.py and test_pprint.py to 3.12 (#5195)
This commit is contained in:
committed by
GitHub
parent
83d1ad8a2c
commit
4e7b3bc8f2
16
Lib/pprint.py
vendored
16
Lib/pprint.py
vendored
@@ -637,19 +637,6 @@ def _recursion(object):
|
||||
% (type(object).__name__, id(object)))
|
||||
|
||||
|
||||
def _perfcheck(object=None):
|
||||
import time
|
||||
if object is None:
|
||||
object = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100000
|
||||
p = PrettyPrinter()
|
||||
t1 = time.perf_counter()
|
||||
p._safe_repr(object, {}, None, 0, True)
|
||||
t2 = time.perf_counter()
|
||||
p.pformat(object)
|
||||
t3 = time.perf_counter()
|
||||
print("_safe_repr:", t2 - t1)
|
||||
print("pformat:", t3 - t2)
|
||||
|
||||
def _wrap_bytes_repr(object, width, allowance):
|
||||
current = b''
|
||||
last = len(object) // 4 * 4
|
||||
@@ -666,6 +653,3 @@ def _wrap_bytes_repr(object, width, allowance):
|
||||
current = candidate
|
||||
if current:
|
||||
yield repr(current)
|
||||
|
||||
if __name__ == "__main__":
|
||||
_perfcheck()
|
||||
|
||||
2
Lib/test/test_pprint.py
vendored
2
Lib/test/test_pprint.py
vendored
@@ -203,7 +203,7 @@ class QueryTestCase(unittest.TestCase):
|
||||
def test_unreadable(self):
|
||||
# Not recursive but not readable anyway
|
||||
pp = pprint.PrettyPrinter()
|
||||
for unreadable in type(3), pprint, pprint.isrecursive:
|
||||
for unreadable in object(), int, pprint, pprint.isrecursive:
|
||||
# module-level convenience functions
|
||||
self.assertFalse(pprint.isrecursive(unreadable),
|
||||
"expected not isrecursive for %r" % (unreadable,))
|
||||
|
||||
Reference in New Issue
Block a user