Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7310] Unhelpful __repr__() in os.environ

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 12, 2009, 3:54 AM

Post #1 of 6 (331 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ

New submission from Kent Johnson <kent [at] kentsjohnson>:

In Python 2.x, os.environ extends UserDict.IterableUserDict and
therefore os.environ.__repr__() shows the environment. This makes it
easy and intuitive to view the entire environment in the interactive
interpreter.

In Python 3.1, os.environ extends _abcoll.MutableMapping and uses
object.__repr__(). This is a much less useful representation.

I suggest adding this __repr__() method to class os._Environ (os.py line
380):

def __repr__(self): return repr(self.data)

----------
components: Library (Lib)
messages: 95160
nosy: kjohnson
severity: normal
status: open
title: Unhelpful __repr__() in os.environ
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 13, 2009, 5:34 PM

Post #2 of 6 (289 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ [In reply to]

Ezio Melotti <ezio.melotti [at] gmail> added the comment:

Here is a patch against py3k.

----------
assignee: -> ezio.melotti
keywords: +easy, patch
nosy: +ezio.melotti
priority: -> normal
stage: -> patch review
versions: +Python 3.2
Added file: http://bugs.python.org/file15327/issue7310.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 13, 2009, 6:09 PM

Post #3 of 6 (287 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ [In reply to]

Changes by Ezio Melotti <ezio.melotti [at] gmail>:


----------
keywords: +needs review

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 16, 2009, 11:11 AM

Post #4 of 6 (263 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ [In reply to]

Amaury Forgeot d'Arc <amauryfa [at] gmail> added the comment:

A unit test would be appreciated. It should check that the output looks
like a dict.

----------
nosy: +amaury.forgeotdarc

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 16, 2009, 11:21 PM

Post #5 of 6 (260 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ [In reply to]

Changes by Ezio Melotti <ezio.melotti [at] gmail>:


Removed file: http://bugs.python.org/file15327/issue7310.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 16, 2009, 11:42 PM

Post #6 of 6 (271 views)
Permalink
[issue7310] Unhelpful __repr__() in os.environ [In reply to]

Ezio Melotti <ezio.melotti [at] gmail> added the comment:

New patch that includes a unittest.

I was also considering to replace the repr() with something that looks
like _Environ({dict-here}). That will still contain all the information
and also clarify that os.environ is not just a simple dict. (Even if
it's probably not relevant, if we want eval(repr(os.environ)) to work,
the repr() should also include the other args accepted by the _Environ()
constructor.)

If you think this is a good idea I can make a new patch, otherwise, if
the current patch is fine, I'll commit it as it is.

----------
Added file: http://bugs.python.org/file15348/issue7310.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.