[issue39994] Redundant code in pprint module.

2020-08-15 Thread Irit Katriel


Irit Katriel  added the comment:

Thanks, I'll create a new PR and credit @Palak Kumar Jha as co-author.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-15 Thread Eric V. Smith


Eric V. Smith  added the comment:

I went ahead and closed the PR. Either @Palak Kumar Jha or someone else can 
create a new PR. The suggestions in the original PR should be addresses.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-14 Thread Mariatta


Mariatta  added the comment:

@Palak Kumar Jha, you created a PR for this ticket but it seems that your 
GitHub account is inactive/has been removed. Do you have a new GitHub account? 
Are you still interested in continuing on this PR?

--
nosy: +Mariatta

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-12 Thread Fred Drake


Fred Drake  added the comment:

Ah, good find!  It's been so long since the first version of that code, but the 
implementation was surprisingly nuanced.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

bpo-23741 did not change the behavior. The specified code was added specially 
to preserve the existing behavior. For other base types the condition was like 
`issubclass(typ, list) and r is list.__repr__`, but for dict it was just 
`issubclass(typ, dict)`.

Actually the initial behavior was changed by 
bad3c88094f43f3bc7dcce22f47b8c2a8dddabcf (no issue number), with adding support 
of OrderedDict.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-12 Thread Fred Drake


Fred Drake  added the comment:

Adding serhiy.storchaka to nosy list since it looks like he introduced the 
isinstance check on purpose (see bpo-23741).

Though bpo-23741 asserts that no behavior was changed with the patch applied 
then, reading through the change leads me to think this did change for cases 
like the MyDict example from iritkatriel.

The intent of the original code was that MyDict.__repr__ would be used; only 
the small handful of "known" reprs would be handled specially.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Yes, this code was kept for backward compatibility when the dispatch mapping 
was added.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-08-12 Thread Irit Katriel


Irit Katriel  added the comment:

This change makes a difference in semantics (perhaps a good one) in this case:

import pprint

class MyDict(dict):
def __repr__(self):
return 'I do my own thing'*50

if __name__ == '__main__':
d=MyDict()
for i in range(50):
d['a%s'%i] = i

pprint.pprint(d)


Before the change MyDict.__repr__ is ignored and the dict contents are printed. 
After the change it prints "I do my own thing" 50 times.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-03-19 Thread Palak Kumar Jha


Change by Palak Kumar Jha :


--
nosy: +fdrake
versions:  -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-03-17 Thread Palak Kumar Jha


Change by Palak Kumar Jha :


--
keywords: +patch
pull_requests: +18397
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19046

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39994] Redundant code in pprint module.

2020-03-17 Thread Palak Kumar Jha


New submission from Palak Kumar Jha :

In the PrettyPrinter._format method, since self._dispatch has dict.__repr__ 
[key] mapped to self._pprint_dict [value] the elif block is not needed. Its 
work is already being done by the if block above, which searches self._dispatch 
to fetch the appropriate value.

--
messages: 364442
nosy: palakjha
priority: normal
severity: normal
status: open
title: Redundant code in pprint module.
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com