Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bug in pprint module #92546

Closed
ArturKhuziakhmetov opened this issue May 9, 2022 · 9 comments
Closed

Minor bug in pprint module #92546

ArturKhuziakhmetov opened this issue May 9, 2022 · 9 comments
Labels
easy type-bug An unexpected behavior, bug, or error

Comments

@ArturKhuziakhmetov
Copy link

ArturKhuziakhmetov commented May 9, 2022

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

@ArturKhuziakhmetov ArturKhuziakhmetov added the type-bug An unexpected behavior, bug, or error label May 9, 2022
@ericvsmith
Copy link
Member

ericvsmith commented May 9, 2022

Please provide the code that triggered this problem.

@arhadthedev
Copy link
Contributor

arhadthedev commented May 9, 2022

@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()

@ericvsmith
Copy link
Member

ericvsmith commented May 9, 2022

Ah, I misunderstood. Thanks.

@rhettinger
Copy link
Contributor

rhettinger commented May 9, 2022

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

@ddurgoji
Copy link

ddurgoji commented Jul 26, 2022

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?

@arhadthedev
Copy link
Contributor

arhadthedev commented Jul 27, 2022

@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.

@ddurgoji
Copy link

ddurgoji commented Jul 27, 2022

@arhadthedev , Yes I am going through it thanks.

@denballakh
Copy link

denballakh commented Oct 5, 2022

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

@iritkatriel
Copy link
Member

iritkatriel commented Oct 5, 2022

Indeed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants