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

Clarify argument type of platform.platform(aliased, terse) to boolean #91038

Closed
Rotzbua mannequin opened this issue Feb 28, 2022 · 4 comments
Closed

Clarify argument type of platform.platform(aliased, terse) to boolean #91038

Rotzbua mannequin opened this issue Feb 28, 2022 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@Rotzbua
Copy link
Mannequin

Rotzbua mannequin commented Feb 28, 2022

BPO 46882
Nosy @stevendaprano, @Rotzbua
PRs
  • bpo-46882: Clarify argument type of platform.platform(aliased, terse) to boolean #31617
  • gh-91038: Change default argument value to False instead of 0 #31621
  • 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 = None
    created_at = <Date 2022-02-28.14:28:31.784>
    labels = ['3.7', '3.8', '3.9', 'type-feature', 'docs', '3.10', '3.11', 'library']
    title = 'Clarify argument type of platform.platform(aliased, terse) to boolean'
    updated_at = <Date 2022-02-28.18:49:58.262>
    user = 'https://github.com/Rotzbua'

    bugs.python.org fields:

    activity = <Date 2022-02-28.18:49:58.262>
    actor = 'Rotzbua'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2022-02-28.14:28:31.784>
    creator = 'Rotzbua'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46882
    keywords = ['patch']
    message_count = 4.0
    messages = ['414198', '414199', '414205', '414213']
    nosy_count = 3.0
    nosy_names = ['steven.daprano', 'docs@python', 'Rotzbua']
    pr_nums = ['31617', '31621']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46882'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    @Rotzbua
    Copy link
    Mannequin Author

    Rotzbua mannequin commented Feb 28, 2022

    Problem:
    Both arguments aliased and terse should be boolean instead of integer.

    Description:
    The function is as platform.platform(aliased=0, terse=0) so both arguments aliased and terse seems to be numbers.
    The documentation says: "If aliased is true,[..]" which gives a hint that the type should be boolean instead of an integer.
    Looking into the implementation both arguments used as boolean.

    Solution:
    Update documentation and set default argument values to False instead of 0.

    Reference:
    Current documentation: https://docs.python.org/3.11/library/platform.html#platform.platform

    @Rotzbua Rotzbua mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes labels Feb 28, 2022
    @Rotzbua Rotzbua mannequin assigned docspython Feb 28, 2022
    @Rotzbua Rotzbua mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes labels Feb 28, 2022
    @stevendaprano
    Copy link
    Member

    Both arguments aliased and terse should be boolean instead of integer.

    Why should they be strictly True/False booleans? I disagree strongly that they should be. Any object that duck-types as a true or false value is sufficient.

    Treated as a documentation change, your PR is wrong because it implies that only the singletons True and False are acceptable, when in fact any true and false (note the lowercase) values are acceptable.

    Personally, I prefer the terms "truthy" and "falsey", or "a true value" and "a false value" over a bare true/false, but some people do not, and it is a long-standing tradition in Python circles to understand lowercase true/false as the duck-typed values as opposed to the True and False bool singletons.

    @stevendaprano
    Copy link
    Member

    See bpo-46883

    @Rotzbua
    Copy link
    Mannequin Author

    Rotzbua mannequin commented Feb 28, 2022

    Thanks for pointing out the logical change from "true" to "True".
    I do not want to start a discussion about principles.

    Nevertheless I think a change from platform(aliased=0, terse=0) to platform(aliased=False, terse=False) makes the how-to-use more intuitive.

    The change does not change any function behavior or breaks any backwards compatibilities.

    I created a new PR without the change of "true".

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    JelleZijlstra pushed a commit that referenced this issue Feb 27, 2023
    …1621)
    
    The argument is used as a switch and corresponds to a boolean logic. Therefore it is more intuitive to use the corresponding constant `False` as default value instead of the integer `0`.
    
    Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
    Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
    carljm added a commit to carljm/cpython that referenced this issue Feb 28, 2023
    * main: (67 commits)
      pythongh-99108: Add missing md5/sha1 defines to Modules/Setup (python#102308)
      pythongh-100227: Move _str_replace_inf to PyInterpreterState (pythongh-102333)
      pythongh-100227: Move the dtoa State to PyInterpreterState (pythongh-102331)
      pythonGH-102305: Expand some macros in generated_cases.c.h (python#102309)
      Migrate to new PSF mailgun account (python#102284)
      pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (python#102193)
      pythonGH-90744: Fix erroneous doc links in the sys module (python#101319)
      pythongh-87092: Make jump target label equal to the offset of the target in the instructions sequence (python#102093)
      pythongh-101101: Unstable C API tier (PEP 689) (pythonGH-101102)
      IDLE: Simplify DynOptionsMenu __init__code (python#101371)
      pythongh-101561: Add typing.override decorator (python#101564)
      pythongh-101825: Clarify that as_integer_ratio() output is always normalized (python#101843)
      pythongh-101773: Optimize creation of Fractions in private methods (python#101780)
      pythongh-102251: Updates to test_imp Toward Fixing Some Refleaks (pythongh-102254)
      pythongh-102296 Document that inspect.Parameter kinds support ordering (pythonGH-102297)
      pythongh-102250: Fix double-decref in COMPARE_AND_BRANCH error case (pythonGH-102287)
      pythongh-101100: Fix sphinx warnings in `types` module (python#102274)
      pythongh-91038: Change default argument value to `False` instead of `0` (python#31621)
      pythongh-101765: unicodeobject: use Py_XDECREF correctly (python#102283)
      [doc] Improve grammar/fix missing word (pythonGH-102060)
      ...
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants