Skip to content

Minor bug in pprint module #92546

Description

@ArturKhuziakhmetov

Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32

pprint.py
Traceback (most recent call last):
File "C:\Python\Python310\Lib\pprint.py", line 670, in
_perfcheck()
File "C:\Python\Python310\Lib\pprint.py", line 645, in _perfcheck
p._safe_repr(object, {}, None, 0, True)
TypeError: PrettyPrinter._safe_repr() takes 5 positional arguments but 6 were given

Activity

  1. ericvsmith commented on May 9, 2022

    @ericvsmith
    Member

    Please provide the code that triggered this problem.

  2. arhadthedev commented on May 9, 2022

    @arhadthedev
    Member

    @ericvsmith _perfcheck() is called from if __name__ == "__main__":

    cpython/Lib/pprint.py

    Lines 640 to 671 in be3cdd6

    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
    for i in range(0, len(object), 4):
    part = object[i: i+4]
    candidate = current + part
    if i == last:
    width -= allowance
    if len(repr(candidate)) > width:
    if current:
    yield repr(current)
    current = part
    else:
    current = candidate
    if current:
    yield repr(current)
    if __name__ == "__main__":
    _perfcheck()

  3. ericvsmith commented on May 9, 2022

    @ericvsmith
    Member

    Ah, I misunderstood. Thanks.

  4. rhettinger commented on May 9, 2022

    @rhettinger
    Contributor

    Irit, 'git annotate' indicates that you made this change.

  5. removed their assignment
    on Jun 3, 2022
  6. added a commit that references this issue on Jul 5, 2022
    3b25c91
  7. added a commit that references this issue on Jul 25, 2022
  8. ddurgoji commented on Jul 26, 2022

    @ddurgoji

    I recently started working towards becoming python core developer. I came across this issue marked as easy. Can I take up and fix this issue?

  9. arhadthedev commented on Jul 27, 2022

    @arhadthedev
    Member

    @ddurgoji It's an open project, no preliminary assignment is required. The only thing you need is to follow the contributor's manual at https://devguide.python.org/ where conventions and processes are described.

  10. ddurgoji commented on Jul 27, 2022

    @ddurgoji

    @arhadthedev , Yes I am going through it thanks.

  11. denballakh commented on Oct 5, 2022

    @denballakh
    Contributor

    I think this issue is no longer relevant because it is solved in #94613

  12. iritkatriel commented on Oct 5, 2022

    @iritkatriel
    Member

    Indeed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    easytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions