Author lemburg
Recipients lemburg, pitrou, vstinner
Date 2010-08-10.17:56:27
SpamBayes Score 1.32572e-12
Marked as misclassified No
Message-id <4C6192CA.8080808@egenix.com>
In-reply-to <1281460894.18.0.756161940799.issue9560@psf.upfronthosting.co.za>
Content
STINNER Victor wrote:
> 
> New submission from STINNER Victor <victor.stinner@haypocalc.com>:
> 
> Lib/platform.py was created 7 years ago by r32391. _syscmd_file() docstring was never changed whereas it is inconsistent with the implementation:
> ---
> def _syscmd_file(target,default=''):
> 
>     """ Interface to the system's file command.
> 
>         The function uses the -b option of the file command to have it
>         ommit the filename in its output and if possible the -L option
>         to have the command follow symlinks. It returns default in
>         case the command should fail.
> 
>     """
>     ...
>     target = _follow_symlinks(target).replace('"', '\\"')
>     ...
>     f = os.popen('file "%s" 2> %s' % (target, DEV_NULL))
>     ...
> ---
> 
> It doesn't use -L option but use Python to follow the link, and use an regex to remove the filename.
> 
> Attached patch enables -b option to avoid problem with non-ascii filenames but ascii locale encoding (see #8611 and #9425) and updates the docstring.

The patch looks good. Just one nit: could you please indent the doc-string
to match the original indentation ?

BTW: I had a look in my archive for platform.py, but couldn't find
where the symlink logic was changed to use Python's APIs instead.

> --
> 
> To fix the non-ascii problem, I tried a different approach by using subprocess API which gives a bytes version of stdout and so avoid the encoding issue. But I commited the patch on python trunk (2.7) which had a bootstrap issue. py3k had no bootstrap issue, but the new patch (use -b option) is simpler.
> 
> Commits: r80166 (trunk), r80167 (py3k). Reverted: r80171+r80189 (trunk) and r80190 (py3k).
> 
> More details in the following mail thread:
> http://mail.python.org/pipermail/python-checkins/2010-April/092092.html

The main reason why this doesn't work on trunk is that platform.py is
supposed to work for many different Python versions, since it's
original use case was to provide platform information to build systems
targeting multiple Python versions.

On Python3, the same is true, but only for the 3.x versions.
History
Date User Action Args
2010-08-10 17:56:30lemburgsetrecipients: + lemburg, pitrou, vstinner
2010-08-10 17:56:28lemburglinkissue9560 messages
2010-08-10 17:56:27lemburgcreate