This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients christian.heimes, cstratak, doko, matrixise, pmpp, r.david.murray, vstinner
Date 2020-11-24.16:51:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The distro module has been mentioned multiple times. I looked at its code base and I suggest to not add it to  the Python stdlib. It contains code specific to some Linux distributions. Examples.

elif 'ubuntu_codename' in props:
    # Same as above but a non-standard field name used on older Ubuntus
    props['codename'] = props['ubuntu_codename']

    'enterpriseenterpriseas': 'oracle',  # Oracle Enterprise Linux 4
    'enterpriseenterpriseserver': 'oracle',  # Oracle Linux 5
    'redhatenterpriseworkstation': 'rhel',  # RHEL 6, 7 Workstation
    'redhatenterpriseserver': 'rhel',  # RHEL 6, 7 Server
    'redhatenterprisecomputenode': 'rhel',  # RHEL 6 ComputeNode

basenames = ['SuSE-release',

platform.linux_distribution() has been removed because it was difficult to keep the implementation up to date, whereas Python are rarely or not updated during the lifecycle of a Linux distribution version.


The os-release file is different: the filename is standardized and the file format is standardized. I expect really minor maintenance on a function parsing it.

Note: distro doesn't specify an encoding when opening os-release, but use the locale encoding. I suggest to use UTF-8.

The distro module remains useful since it tries to better API. For example, variable names are converted to lowercase and it extracts the codebase from the version variable:

        elif 'version' in props:
            # If there is no version_codename, parse it from the version
            codename ='(\(\D+\))|,(\s+)?\D+', props['version'])
            if codename:
                codename =
                codename = codename.strip('()')
                codename = codename.strip(',')
                codename = codename.strip()
                # codename appears within paranthese.
                props['codename'] = codename

But again, I don't think that we should implement such heuristics (code specific to some Linux distributions) in the stdlib, to minimize the maintenance burden.
Date User Action Args
2020-11-24 16:51:15vstinnersetrecipients: + vstinner, doko, christian.heimes, r.david.murray, pmpp, matrixise, cstratak
2020-11-24 16:51:15vstinnersetmessageid: <>
2020-11-24 16:51:15vstinnerlinkissue28468 messages
2020-11-24 16:51:14vstinnercreate