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.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '') #53723

Closed
pitrou opened this issue Aug 4, 2010 · 14 comments
Closed
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Aug 4, 2010

BPO 9514
Nosy @malemburg, @warsaw, @doko42, @pitrou, @tiran, @ezio-melotti, @merwok, @davidmalcolm
Files
  • use-lsb-release-first.diff: Patch to check /etc/lsb-release first (against trunk r83728)
  • 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 = None
    closed_at = <Date 2015-05-13.14:20:47.735>
    created_at = <Date 2010-08-04.17:47:47.921>
    labels = ['type-bug', 'library']
    title = "platform.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '')"
    updated_at = <Date 2015-05-13.14:20:47.734>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2015-05-13.14:20:47.734>
    actor = 'lemburg'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-05-13.14:20:47.735>
    closer = 'lemburg'
    components = ['Library (Lib)']
    creation = <Date 2010-08-04.17:47:47.921>
    creator = 'pitrou'
    dependencies = []
    files = ['18389']
    hgrepos = []
    issue_num = 9514
    keywords = ['patch']
    message_count = 14.0
    messages = ['112839', '112841', '112844', '112847', '112848', '112850', '112853', '112958', '113038', '113316', '156292', '172498', '224549', '243091']
    nosy_count = 11.0
    nosy_names = ['lemburg', 'barry', 'doko', 'pitrou', 'draghuram', 'christian.heimes', 'ezio.melotti', 'hodgestar', 'eric.araujo', 'dmalcolm', 'jaywink']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9514'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 4, 2010

    At least on one of the buildbots:

    Re-running test 'test_ssl' in verbose mode
    test_ssl: testing with 'OpenSSL 0.9.8o 01 Jun 2010' (0, 9, 8, 15, 15)
    under Linux ('debian', 'squeeze/sid', '')

    at the bottom of http://www.python.org/dev/buildbot/builders/i386%20Ubuntu%203.x/builds/1788/steps/test/logs/stdio

    Someone on IRC pointed out that on their machine, the system Python returned ('Ubuntu', '10.04', 'lucid').

    @pitrou pitrou added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 4, 2010
    @hodgestar
    Copy link
    Mannequin

    hodgestar mannequin commented Aug 4, 2010

    I can confirm that I see the ('debian', 'squeeze/sid', '') on py3k and trunk but that the Python 2.6 under Ubuntu reports ('Ubuntu', '10.04', 'lucid').

    @hodgestar
    Copy link
    Mannequin

    hodgestar mannequin commented Aug 4, 2010

    I think the problem might be that linux_distribution() reads /etc/debian_version first. The contents of the relevant files in /etc look like:

    $ cat /etc/debian_version 
    squeeze/sid
    
    $ cat /etc/lsb-release 
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=10.04
    DISTRIB_CODENAME=lucid
    DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS"

    @hodgestar
    Copy link
    Mannequin

    hodgestar mannequin commented Aug 4, 2010

    Patch attached to check /etc/lsb-release before checking other files. Taken from Ubuntu Python 2.6 copy of platform.py. Applies against trunk (r83728) with a small offset against py3k (r83728).

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 4, 2010

    FWIW, the output is a bit different here before the patch:
    $ ./python -c "import platform; print(platform.linux_distribution())"
    ('Mandriva Linux', '2010.1', 'Official')

    and after the patch:
    $ ./python -c "import platform; print(platform.linux_distribution())"
    ('MandrivaLinux', '2010.1', 'Henry_Farman')

    but I would say it's because Mandriva has inconsistent contents in their respective /etc/mandriva_release and /etc/lsb-release files.

    The patch itself is a bit imperfect and will need reworking (_u_distname, _u_version and _u_id should be initialized to '' rather than catching UnboundLocalError; remove ubuntu-specific comments).

    @hodgestar
    Copy link
    Mannequin

    hodgestar mannequin commented Aug 4, 2010

    I think the intended means of accessing this information is via the lsb_release command (http://refspecs.freestandards.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html). That said, I don't know if the file format will change drastically unless someone re-implements lsb_release.

    @draghuram
    Copy link
    Mannequin

    draghuram mannequin commented Aug 4, 2010

    Please check bpo-1322 for past discussion on similar topic (usability of lsb_release in platform.py).

    @malemburg
    Copy link
    Member

    I think we'll start to use the lsb_release command if available and as suggested in bpo-1322.

    Note that if you test the API, make sure that you use a Python build from sources available on python.org - the Debian and Ubuntu packagers tend to patch Python in their distributions (just like RedHat and others do) and we don't really want to hunt down bugs/problems that are not relevant to our code base.

    @doko42
    Copy link
    Member

    doko42 commented Aug 5, 2010

    IMO using lsb_release is not an option, because it can take some time to complete. So maybe it's better for the Ubuntu change to guard the check with the existance of /etc/debian_version.

    Please could you attach a Mandriva lsb-release file?

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 8, 2010

    Please could you attach a Mandriva lsb-release file?

    $ cat /etc/lsb-release
    LSB_VERSION=lsb-4.0-amd64:lsb-4.0-noarch
    DISTRIB_ID=MandrivaLinux
    DISTRIB_RELEASE=2010.1
    DISTRIB_CODENAME=Henry_Farman
    DISTRIB_DESCRIPTION="Mandriva Linux 2010.1"
    
    $ cat /etc/mandriva-release 
    Mandriva Linux release 2010.1 (Official) for x86_64

    @merwok
    Copy link
    Member

    merwok commented Mar 18, 2012

    @doko42
    Copy link
    Member

    doko42 commented Oct 9, 2012

    http://www.freedesktop.org/software/systemd/man/os-release.html

    is the next step, with the advantage of the definition of the file format for /etc/os-release.

    @jaywink
    Copy link
    Mannequin

    jaywink mannequin commented Aug 2, 2014

    platform.linux_distribution is being deprecated in 3.5 and removed in 3.6 as stated in comment http://bugs.python.org/issue1322#msg207427 in issue bpo-1322

    I'm guessing this issue should be closed when that patch is merged in?

    @malemburg
    Copy link
    Member

    See bpo-1322

    @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

    4 participants