Navigation Menu

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

os: Some functions may report bogus errors on Windows #77071

Closed
izbyshev mannequin opened this issue Feb 20, 2018 · 6 comments
Closed

os: Some functions may report bogus errors on Windows #77071

izbyshev mannequin opened this issue Feb 20, 2018 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@izbyshev
Copy link
Mannequin

izbyshev mannequin commented Feb 20, 2018

BPO 32890
Nosy @vstinner, @izbyshev, @miss-islington
PRs
  • bpo-32890: os: Use errno instead of GetLastError() where appropriate #5784
  • [3.7] bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784) #9984
  • [3.6] bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784) #9985
  • 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 2018-10-20.00:53:37.560>
    created_at = <Date 2018-02-20.23:54:16.434>
    labels = ['3.8', 'type-bug', '3.7']
    title = 'os: Some functions may report bogus errors on Windows'
    updated_at = <Date 2018-10-22.17:29:14.286>
    user = 'https://github.com/izbyshev'

    bugs.python.org fields:

    activity = <Date 2018-10-22.17:29:14.286>
    actor = 'izbyshev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-20.00:53:37.560>
    closer = 'vstinner'
    components = []
    creation = <Date 2018-02-20.23:54:16.434>
    creator = 'izbyshev'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32890
    keywords = ['patch']
    message_count = 6.0
    messages = ['312446', '328101', '328110', '328113', '328118', '328265']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'izbyshev', 'miss-islington']
    pr_nums = ['5784', '9984', '9985']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32890'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @izbyshev
    Copy link
    Mannequin Author

    izbyshev mannequin commented Feb 20, 2018

    Demo:

    >>> os.execve('', ['a'], {})
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: [WinError 0] The operation completed successfully: ''

    The reason is that path_error() used throughout os module always uses GetLastError() on Windows, but some functions are implemented via CRT calls which report errors via errno. It seems that commit 292c835 caused this issue.

    @izbyshev izbyshev mannequin added 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Feb 20, 2018
    @vstinner
    Copy link
    Member

    New changeset 8346031 by Victor Stinner (Alexey Izbyshev) in branch 'master':
    bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
    8346031

    @miss-islington
    Copy link
    Contributor

    New changeset 8f53dcd by Miss Islington (bot) in branch '3.7':
    bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
    8f53dcd

    @miss-islington
    Copy link
    Contributor

    New changeset d9a2665 by Miss Islington (bot) in branch '3.6':
    bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
    d9a2665

    @vstinner
    Copy link
    Member

    Thanks Alexey Izbyshev!

    @vstinner vstinner added the 3.8 only security fixes label Oct 22, 2018
    @izbyshev
    Copy link
    Mannequin Author

    izbyshev mannequin commented Oct 22, 2018

    Python 2.7 doesn't have the same issue.

    In os.execve(), posix_error() is used, but it is based on errno, which is correct. (A funny bit is that os.execve('', ['a'], {}) crashes in 2.7, probably because of some checks in CRT).

    And os.truncate() is not implemented in 2.7 at all.

    @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
    3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants