Merge lp:~gz/bzr/get_environ_unicode_262874 into lp:bzr
Status: | Merged |
---|---|
Approved by: | Vincent Ladeuil |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6358 |
Proposed branch: | lp:~gz/bzr/get_environ_unicode_262874 |
Merge into: | lp:bzr |
Diff against target: |
111 lines (+83/-2) 2 files modified
bzrlib/tests/test_win32utils.py (+53/-0) bzrlib/win32utils.py (+30/-2) |
To merge this branch: | bzr merge lp:~gz/bzr/get_environ_unicode_262874 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Review via email: mp+84311@code.launchpad.net |
Commit message
Add get_environ_unicode for accessing variables without mbcs mangling on windows
Description of the change
Adds a mechanism for getting unicode values from the environment directly on windows without the lossy encode/decode used by Python 2 environ access. For most uses, just doing correct encoding and decoding is enough, but this should be an easier interface to get right with less risk of corrupting the environment block by mistake.
An equivalent function for putting unicode values has not been added. While it's nice to cope with all inputs, it's also best not to export values we know may cause problems for other applications. Also, bypassing the os.environ dict cache is fine in the getenv direction, but in the putenv direction leads means future access will get old values.
Hmm, warming up for the fix-the-oldest-bug challenge are you ?
79 + A large enough buffer will be allocated to retrieve the value, unless
80 + unless `_size` is set which will act as a hard limit.
s/unless unless/unless/
84 + f = getattr( get_environ_ unicode, "_func", None)
I have a few concerns here:
- 'f' is too short :)
- using function attributes is unusal and could be explained,
- this is addressing a lot of issues that aren't documented ;)
Fix as best as you can so some unaware hacker won't go crazy searching for a mythical '_func' attribute on docs.python.org tricked by the resemblance with say, 'im_func' ;)
Also, teach your win editor about not mixing line endings in test_win32utils ;-p