[Patches] [ python-Patches-1231336 ] Add unicode for sys.argv, os.environ, os.system

SourceForge.net noreply at sourceforge.net
Thu Jul 14 20:10:39 CEST 2005


Patches item #1231336, was opened at 2005-07-02 03:55
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1231336&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: Python 2.5
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Neil Hodgson (nyamatongwe)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add unicode for sys.argv, os.environ, os.system

Initial Comment:
Most installations of Windows (2000, XP) are unicode
native with narrow character APIs only providing a
distorted view of the system. Python does not currently
provide access to some basic features through wide
character calls and so may see distorted values. This
patch adds unicode compatibility for sys.argv,
os.environ, and os.system. os.system accepts a unicode
argument in the same way as described in PEP 277 for
file APIs. For sys.argv and os.environ, new parallel
unicode attributes sys.argvu and os.environu are added
as it would cause too many problems to use unicode
values for the existing attributes or to use unicode
only for non-ASCII values. The features are only
enabled on unicode native versions of Windows.
The three features are demonstrated at
http://www.scintilla.org/pyunicode.png
The patch contains some documentation additions for
sys.argvu and os.environu. 
There are no test cases as test cases involving running
extra processes can be messy and fail for uninteresting
reasons.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-07-14 20:10

Message:
Logged In: YES 
user_id=21627

os.environ is not a dictionary, it is a
UserDict.IterableUserDict. Discerning strings and Unicode
object would well be possible. As you are not willing to
discuss the issues on python-dev, I'm rejecting the patch.

----------------------------------------------------------------------

Comment By: Neil Hodgson (nyamatongwe)
Date: 2005-07-14 12:35

Message:
Logged In: YES 
user_id=12579

os.environ is a dictionary and unicode keys can not be
discerned from string keys.
For sys.argv it appears that there is no support for the
"parallel universe" approach with sys.argvu and I expect one
of the "promotion" models will be chosen.
The patch should be rejected (or parked?) until consensus
emerges.
os.system was only included to allow testing but I saw
difficulties in writing robust unit tests for these features
so didn't include any.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-07-11 18:42

Message:
Logged In: YES 
user_id=21627

For os.environ, I think I would prefer a solution where
Unicode keys result in Unicode values and string keys result
in string values, with the canonical conversion through
"mbcs" in place.

For argv, I agree something should be done, but I'm not
certain that the introduction of argvu is the best thing to
do; this should be dicsussed on python-dev, and with all
people originally involved in PEP 277.

The change to system() is not mentioned at all in your
message. It doesn't seem to belong into this patch, either,
so please submit it as a separate patch. If system() is
changed to support Unicode commands, I think spawn*() should
be changed as well. These seem less debatable, as they come
as natural extensions to PEP 277 (i.e. pass Unicode through
to the system).

----------------------------------------------------------------------

Comment By: Neil Hodgson (nyamatongwe)
Date: 2005-07-05 06:27

Message:
Logged In: YES 
user_id=12579

Added a description to diff file.

----------------------------------------------------------------------

Comment By: Neil Hodgson (nyamatongwe)
Date: 2005-07-05 06:25

Message:
Logged In: YES 
user_id=12579

There are problems in sys.argvu as the current argument
processing code removes some option arguments where these
are processed by python. This can be almost fixed by storing
the argc last elements into sys.argvu. However, when using
[-c command], the command is removed from sys.argv as this
allows the Python code to determine that it is either
running with a command line command ("-c") or the name of
the file.
Attached patch fixes these problems.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1231336&group_id=5470


More information about the Patches mailing list