Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform.version() don't work as expected in Vista in portuguese #47660

Closed
portella mannequin opened this issue Jul 18, 2008 · 17 comments
Closed

platform.version() don't work as expected in Vista in portuguese #47660

portella mannequin opened this issue Jul 18, 2008 · 17 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@portella
Copy link
Mannequin

portella mannequin commented Jul 18, 2008

BPO 3410
Nosy @malemburg, @ezio-melotti
Files
  • unnamed
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/malemburg'
    closed_at = <Date 2012-11-25.14:36:02.149>
    created_at = <Date 2008-07-18.19:49:54.353>
    labels = ['type-bug', 'library']
    title = "platform.version() don't work as expected in Vista in portuguese"
    updated_at = <Date 2012-11-25.14:36:02.148>
    user = 'https://bugs.python.org/portella'

    bugs.python.org fields:

    activity = <Date 2012-11-25.14:36:02.148>
    actor = 'ezio.melotti'
    assignee = 'lemburg'
    closed = True
    closed_date = <Date 2012-11-25.14:36:02.149>
    closer = 'ezio.melotti'
    components = ['Library (Lib)']
    creation = <Date 2008-07-18.19:49:54.353>
    creator = 'portella'
    dependencies = []
    files = ['14457']
    hgrepos = []
    issue_num = 3410
    keywords = []
    message_count = 17.0
    messages = ['69987', '69993', '90112', '90115', '90117', '90130', '90131', '90163', '90168', '90170', '90171', '90172', '90173', '90174', '90504', '176358', '176359']
    nosy_count = 4.0
    nosy_names = ['lemburg', 'ezio.melotti', 'portella', 'Ramchandra Apte']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3410'
    versions = ['Python 2.7']

    @portella
    Copy link
    Mannequin Author

    portella mannequin commented Jul 18, 2008

    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.]+))')

    @portella portella mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jul 18, 2008
    @malemburg
    Copy link
    Member

    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

    @ezio-melotti
    Copy link
    Member

    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.

    @malemburg
    Copy link
    Member

    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.

    @malemburg malemburg changed the title platform.version() don't work as expected in Vista in portuguese platform.version() don't work as expected in Vista in portuguese Jul 4, 2009
    @ezio-melotti
    Copy link
    Member

    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.

    @malemburg
    Copy link
    Member

    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/

    @ezio-melotti
    Copy link
    Member

    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.

    @ezio-melotti
    Copy link
    Member

    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.

    @malemburg
    Copy link
    Member

    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 ?

    @ezio-melotti
    Copy link
    Member

    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.

    @malemburg
    Copy link
    Member

    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.

    @ezio-melotti
    Copy link
    Member

    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.

    @portella
    Copy link
    Mannequin Author

    portella mannequin commented Jul 6, 2009

    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\>


    @portella portella mannequin changed the title platform.version() don't work as expected in Vista in portuguese platform.version() don't work as expected in Vista in portuguese Jul 6, 2009
    @ezio-melotti
    Copy link
    Member

    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.

    @malemburg
    Copy link
    Member

    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.

    @RamchandraApte
    Copy link
    Mannequin

    RamchandraApte mannequin commented Nov 25, 2012

    Beemp.

    @ezio-melotti
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants