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.fdopen doesn't raise on invalid file descriptors #49241

Closed
benjaminp opened this issue Jan 18, 2009 · 8 comments
Closed

os.fdopen doesn't raise on invalid file descriptors #49241

benjaminp opened this issue Jan 18, 2009 · 8 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@benjaminp
Copy link
Contributor

BPO 4991
Nosy @pitrou, @benjaminp
Files
  • raise_on_bad_fd.patch
  • raise_on_bad_fd2.patch
  • 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 2009-01-19.00:09:38.764>
    created_at = <Date 2009-01-18.21:02:02.491>
    labels = ['type-bug', 'library']
    title = "os.fdopen doesn't raise on invalid file descriptors"
    updated_at = <Date 2009-01-19.15:14:38.202>
    user = 'https://github.com/benjaminp'

    bugs.python.org fields:

    activity = <Date 2009-01-19.15:14:38.202>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-01-19.00:09:38.764>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2009-01-18.21:02:02.491>
    creator = 'benjamin.peterson'
    dependencies = []
    files = ['12790', '12791']
    hgrepos = []
    issue_num = 4991
    keywords = ['patch']
    message_count = 8.0
    messages = ['80125', '80128', '80130', '80135', '80136', '80137', '80138', '80176']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'benjamin.peterson']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4991'
    versions = ['Python 3.0', 'Python 3.1']

    @benjaminp
    Copy link
    Contributor Author

    Since os.fdopen is now implemented with io.open, it doesn't use fdopen
    and check for invalid file descriptors. This isn't a huge issue since
    subsequent actions on the file will raise an error.

    @benjaminp benjaminp added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 18, 2009
    @pitrou
    Copy link
    Member

    pitrou commented Jan 18, 2009

    Perhaps io.open should be fixed, then?
    (or the _FileIO constructor)

    @benjaminp
    Copy link
    Contributor Author

    Here's a patch for _FileIO.

    @pitrou
    Copy link
    Member

    pitrou commented Jan 18, 2009

    I think EBADF is defined everywhere, so you can drop the defined()
    conditional.

    @benjaminp
    Copy link
    Contributor Author

    Attaching new patch...

    @pitrou
    Copy link
    Member

    pitrou commented Jan 19, 2009

    I'm not sure Windows has a valid fstat btw, I'll guess we'll see on the
    Windows buildbots (in that case, some code can be taken from
    posixmodule.c to emulate fstat behaviour...). Other than that, the patch
    looks fine to me.

    @benjaminp
    Copy link
    Contributor Author

    Applied in r68755. Will watch Windows.

    @benjaminp
    Copy link
    Contributor Author

    Well, the Windows bot is failing but not from test_fileio, so I'll go
    ahead and merge it. r68767.

    @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