Issue 3410: platform.version() don't work as expected in Vista in portuguese (original) (raw)

Issue3410

Created on 2008-07-18 19:49 by portella, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed portella,2009-07-06 11:31
Messages (17)
msg69987 - (view) Author: Felipe Portella (portella) Date: 2008-07-18 19:49
Using Vista in Portuguese platform.version is returning "32bits" instead of "6.0.6001". This is because in file platform.py line 379 thee regular expression try to search for the word "Version" in english, while in Portuguese the command ver will return "Versão". To solve this issue simple change: 'Version ([\d.]+))') for '\S+ ([\d.]+))')
msg69993 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2008-07-18 21:36
Could you please check whether this is still the case with the current version of platform.py we have in SVN ? http://svn.python.org/view/python/trunk/Lib/platform.py?rev=64233&view=markup
msg90112 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-04 11:05
I tried platform.version() on a non-English Vista and XP and I got '32bit' for Vista and '5.1.2600' for XP. With platform.platform() I got 'Windows-32bit-SP2' on Vista and 'Windows-XP-5.1.2600-SP2' on XP.
msg90115 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-07-04 12:52
Ezio Melotti wrote: > Ezio Melotti <ezio.melotti@gmail.com> added the comment: > > I tried platform.version() on a non-English Vista and XP and I got > '32bit' for Vista and '5.1.2600' for XP. With platform.platform() I got > 'Windows-32bit-SP2' on Vista and 'Windows-XP-5.1.2600-SP2' on XP. Could you please run the platform function win32_ver() through a debugger and check why it doesn't return "Vista". That function does have support for Vista.
msg90117 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-04 13:22
The Vista machine is running Py 2.5.2 but is not mine so I can't test/debug the issue properly there. FWIW I tried win32_ver() on it and I got ('', '6.0.6002', 'SP2', 'Multiprocessor Free'). Here on WinXP with 2.6 I get ('XP', '5.1.2600', 'SP2', u'Uniprocessor Free') (why only the last is unicode?). On Monday I'll have access to more Windows machines (including Vista) but they are all in English. If there's something that I should try there let me know.
msg90130 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-07-04 21:56
Ezio Melotti wrote: > Ezio Melotti <ezio.melotti@gmail.com> added the comment: > > The Vista machine is running Py 2.5.2 but is not mine so I can't > test/debug the issue properly there. FWIW I tried win32_ver() on it and > I got ('', '6.0.6002', 'SP2', 'Multiprocessor Free'). Interesting. Looking at the code in win32_ver() should be getting one of ('Vista', '2008Server', 'post2008Server'), but not '' for the release. > Here on WinXP with 2.6 I get ('XP', '5.1.2600', 'SP2', u'Uniprocessor > Free') (why only the last is unicode?). Do you have the win32 tools installed on that machine ? This could be the reason. > On Monday I'll have access to more Windows machines (including Vista) > but they are all in English. If there's something that I should try > there let me know. Please check the results of win32_ver() on those machines. The release part should always be set. Thanks, -- Marc-Andre Lemburg eGenix.com ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
msg90131 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-04 22:11
> Do you have the win32 tools installed on that machine ? This could > be the reason. On my XP machine I have them installed for Py 2.4 only, "import win32api" fails on Py 2.6. "platform.win32_ver()" returns the same with both the versions, but on Py 2.4 they are all plain strings, on Py 2.6 the last string is Unicode (and on Py 3 they are all Unicode). I'll let you know about the result of win32_ver() on the other machines.
msg90163 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-06 05:48
Here are the results. Windows Vista SP2 in English Python 3.0.1: >>> platform.platform() 'Windows-Vista-6.0.6002-SP2' >>> platform.version() '6.0.6002' >>> platform.win32_ver() ('Vista', '6.0.6002', 'SP2', 'Multiprocessor Free') Python 2.6.2: >>> platform.platform() 'Windows-Vista-6.0.6002-SP2' >>> platform.version() '6.0.6002' >>> platform.win32_ver() ('Vista', '6.0.6002', 'SP2', u'Multiprocessor Free') Windows 2003 Server SP2 in English Python 3.1 >>> platform.platform() 'Windows-2003Server-5.2.3790-SP2' >>> platform.version() '5.2.3790' >>> platform.win32_ver() ('2003Server', '5.2.3790', 'SP2', 'Uniprocessor Free') Everything seems fine, however I don't have any non-English Windows here. Do you know if it's possible to download and install language packs and if they may affect the text in the version? If so, I could try to do it and see if I can reproduce the original issue.
msg90168 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-07-06 09:04
Ezio Melotti wrote: > Ezio Melotti <ezio.melotti@gmail.com> added the comment: > > Here are the results. > Windows Vista SP2 in English > Python 3.0.1: > >>> platform.platform() > 'Windows-Vista-6.0.6002-SP2' > >>> platform.version() > '6.0.6002' > >>> platform.win32_ver() > ('Vista', '6.0.6002', 'SP2', 'Multiprocessor Free') > > Python 2.6.2: > >>> platform.platform() > 'Windows-Vista-6.0.6002-SP2' > >>> platform.version() > '6.0.6002' > >>> platform.win32_ver() > ('Vista', '6.0.6002', 'SP2', u'Multiprocessor Free') > > Windows 2003 Server SP2 in English > Python 3.1 > >>> platform.platform() > 'Windows-2003Server-5.2.3790-SP2' > >>> platform.version() > '5.2.3790' > >>> platform.win32_ver() > ('2003Server', '5.2.3790', 'SP2', 'Uniprocessor Free') Thanks. > Everything seems fine, however I don't have any non-English Windows > here. Indeed. > Do you know if it's possible to download and install language > packs and if they may affect the text in the version? If so, I could try > to do it and see if I can reproduce the original issue. I'm not sure whether that would make a difference. On XP this does not make a difference - I've tested this with a German Win XP version. I think the best strategy is to run win32_ver() through the pdb debugger in step-by-step mode and on the Vista machine where you saw the problem. BTW: Do you have the win32 tools installed on that machine ?
msg90170 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-06 10:34
On the Vista machine that returned ('', '6.0.6002', 'SP2', 'Multiprocessor Free') there is ActiveState's Python 2.5.2 that includes the pywin32 extension. I managed to run pdb on it and the result was http://dpaste.com/hold/63642/ Python 2.5 doesn't have any check for Vista, and in win32_ver(), inside the "elif plat == VER_PLATFORM_WIN32_NT:" it only checks for maj <= 4 and maj == 5. Vista is 6 and 'release' remains unset [1]. In Py 2.6 there's also if maj == 6 [2] (and now maj == 7 should be added too). However, I also tried to run what the OP said and indeed I found some problem. With pdb.run('platform._syscmd_ver()'), on Vista in English I get: -> info = pipe.read() (Pdb) s > c:\program files\python26\lib\platform.py(493)_syscmd_ver() -> if pipe.close(): (Pdb) info '\nMicrosoft Windows [Version 6.0.6002]\n' ... -> m = _ver_output.match(info) (Pdb) s > c:\program files\python26\lib\platform.py(511)_syscmd_ver() -> if m is not None: (Pdb) m <_sre.SRE_Match object at 0x0000000002812AE0> (Pdb) m.groups() ('Microsoft', 'Windows', '6.0.6002') where _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' '.*' 'Version ([\d.]+))') In non-English versions instead the regex doesn't match: -> if pipe.close(): (Pdb) p info '\nMicrosoft Windows [Versione 6.0.6002]\n' ... > c:\program files\python25\lib\platform.py(420)_syscmd_ver() -> m = _ver_output.match(info) (Pdb) n > c:\program files\python25\lib\platform.py(421)_syscmd_ver() -> if m: (Pdb) m (Pdb) Since 'Version' is translated, the regex fails if the translation is different because it checks specifically for the word 'Version'. Replacing it with \S+ as the OP suggested sounds like a reasonable solution. It is possible that even other versions of Windows (e.g. XP) have 'Version' translated, can you reproduce it with your German XP? Later I can try on another non-English XP and see if the regex match. [1]: /python/branches/release25-maint/Lib/platform.py?view=markup [2]: /python/branches/release26-maint/Lib/platform.py?view=markup
msg90171 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-07-06 10:49
Ezio Melotti wrote: > Ezio Melotti <ezio.melotti@gmail.com> added the comment: > > On the Vista machine that returned ('', '6.0.6002', 'SP2', > 'Multiprocessor Free') there is ActiveState's Python 2.5.2 that includes > the pywin32 extension. > > I managed to run pdb on it and the result was http://dpaste.com/hold/63642/ > Python 2.5 doesn't have any check for Vista, and in win32_ver(), inside > the "elif plat == VER_PLATFORM_WIN32_NT:" it only checks for maj <= 4 > and maj == 5. Vista is 6 and 'release' remains unset [1]. In Py 2.6 > there's also if maj == 6 [2] (and now maj == 7 should be added too). Ah, that makes sense: Vista support only got added in Python 2.6. We cannot add that support to Python 2.5, since that branch is closed. Note however that platform.py does work with multiple Python versions, so you can always copy the module from a later version and hand-replace the one from the original distribution with an updated one. > However, I also tried to run what the OP said and indeed I found some > problem. With pdb.run('platform._syscmd_ver()'), on Vista in English I get: > -> info = pipe.read() > (Pdb) s >> c:\program files\python26\lib\platform.py(493)_syscmd_ver() > -> if pipe.close(): > (Pdb) info > '\nMicrosoft Windows [Version 6.0.6002]\n' > ... > -> m = _ver_output.match(info) > (Pdb) s >> c:\program files\python26\lib\platform.py(511)_syscmd_ver() > -> if m is not None: > (Pdb) m > <_sre.SRE_Match object at 0x0000000002812AE0> > (Pdb) m.groups() > ('Microsoft', 'Windows', '6.0.6002') > > where _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' > '.*' > 'Version ([\d.]+))') > > In non-English versions instead the regex doesn't match: > -> if pipe.close(): > (Pdb) p info > '\nMicrosoft Windows [Versione 6.0.6002]\n' > ... >> c:\program files\python25\lib\platform.py(420)_syscmd_ver() > -> m = _ver_output.match(info) > (Pdb) n >> c:\program files\python25\lib\platform.py(421)_syscmd_ver() > -> if m: > (Pdb) m > (Pdb) Thanks for checking. > Since 'Version' is translated, the regex fails if the translation is > different because it checks specifically for the word 'Version'. > Replacing it with \S+ as the OP suggested sounds like a reasonable > solution. It is possible that even other versions of Windows (e.g. XP) > have 'Version' translated, can you reproduce it with your German XP? Interesting. In the German XP uses 'Version' as well, so the regexp matches just fine. I'll correct the regexp to only try matching on 'Ver\w+'. > Later I can try on another non-English XP and see if the regex match. > > [1]: /python/branches/release25-maint/Lib/platform.py?view=markup > [2]: /python/branches/release26-maint/Lib/platform.py?view=markup
msg90172 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-06 10:54
Won't that fail with Windows versions in Japanese, Chinese, Arab and similar? If 'Version' is translated in all the languages as a single word and it's between whitespaces (or even between a [ and a space), \S+ should be safe enough, otherwise \w+ with the re.U flag should work.
msg90173 - (view) Author: Felipe Portella (portella) Date: 2009-07-06 11:31
The same happens in Portuguese version ... the regex fails because ver returns "Versão" ... []'s On Mon, Jul 6, 2009 at 7:54 AM, Ezio Melotti <report@bugs.python.org> wrote: > > Ezio Melotti <ezio.melotti@gmail.com> added the comment: > > Won't that fail with Windows versions in Japanese, Chinese, Arab and > similar? > If 'Version' is translated in all the languages as a single word and > it's between whitespaces (or even between a [ and a space), \S+ should > be safe enough, otherwise \w+ with the re.U flag should work. > > ---------- > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue3410> > _______________________________________ >
msg90174 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-06 11:59
According to Google Translate, in Vietnamese 'Version' is 'Phiên bản'. If this is true both \S+ and \w+ will fail. I also noticed a few more regex (namely _release_filename, _lsb_release_version and _release_version) which contain the words 'version' and 'release' and may fail if these are translated. I guess I'll have to check with some live cd (since these regex are used for Linux apparently) and some other language to see if it works.
msg90504 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-07-13 21:29
I've checked in patch r74005 to address the problem. Could you check whether the current SVN version of platform.py works on your Portuguese Windows version ? Thanks.
msg176358 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-11-25 14:30
Beemp.
msg176359 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-25 14:36
I couldn't find a non-English Windows machine to test this, so I'm just going to close it. Feel free to reopen it or create a new issue if there are other problems.
History
Date User Action Args
2022-04-11 14:56:36 admin set github: 47660
2012-11-25 14:36:02 ezio.melotti set status: open -> closedresolution: fixedmessages: + stage: resolved
2012-11-25 14:30:25 Ramchandra Apte set nosy: + Ramchandra Aptemessages: +
2009-07-13 21:29:39 lemburg set messages: +
2009-07-06 11:59:26 ezio.melotti set messages: +
2009-07-06 11:31:38 portella set files: + unnamedmessages: + title: platform.version() don't work as expected in Vista in portuguese -> platform.version() don't work as expected in Vista in portuguese
2009-07-06 10:54:47 ezio.melotti set messages: +
2009-07-06 10:49:19 lemburg set messages: +
2009-07-06 10:34:35 ezio.melotti set messages: +
2009-07-06 09:04:35 lemburg set messages: +
2009-07-06 05:48:54 ezio.melotti set messages: +
2009-07-04 22:11:32 ezio.melotti set messages: +
2009-07-04 21:56:13 lemburg set messages: +
2009-07-04 13:22:39 ezio.melotti set messages: +
2009-07-04 12:52:57 lemburg set messages: + title: platform.version() don't work as expected in Vista in portuguese -> platform.version() don't work as expected in Vista in portuguese
2009-07-04 11:05:36 ezio.melotti set priority: normalversions: + Python 2.7, - Python 2.5nosy: + ezio.melottimessages: +
2008-07-18 21:36:22 lemburg set messages: +
2008-07-18 20:51:39 benjamin.peterson set assignee: lemburgnosy: + lemburg
2008-07-18 19:49:54 portella create