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

errno not being set #49562

Closed
benjaminp opened this issue Feb 19, 2009 · 3 comments
Closed

errno not being set #49562

benjaminp opened this issue Feb 19, 2009 · 3 comments
Assignees

Comments

@benjaminp
Copy link
Contributor

BPO 5312
Nosy @birkenfeld, @benjaminp

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 = 'https://github.com/benjaminp'
closed_at = <Date 2009-02-20.03:20:12.472>
created_at = <Date 2009-02-19.04:16:22.822>
labels = []
title = 'errno not being set'
updated_at = <Date 2009-02-20.03:20:12.471>
user = 'https://github.com/benjaminp'

bugs.python.org fields:

activity = <Date 2009-02-20.03:20:12.471>
actor = 'benjamin.peterson'
assignee = 'benjamin.peterson'
closed = True
closed_date = <Date 2009-02-20.03:20:12.472>
closer = 'benjamin.peterson'
components = []
creation = <Date 2009-02-19.04:16:22.822>
creator = 'benjamin.peterson'
dependencies = []
files = []
hgrepos = []
issue_num = 5312
keywords = []
message_count = 3.0
messages = ['82456', '82470', '82512']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'benjamin.peterson']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue5312'
versions = ['Python 3.0', 'Python 3.1']

@benjaminp
Copy link
Contributor Author

def test_leaking_fds_on_error(self):
        # see bug python/cpython#49429: Popen leaks file descriptors to PIPEs if
        # the child fails to execute; this will eventually exhaust
        # the maximum number of open fds. 1024 seems a very common
        # value for that limit, but Windows has 2048, so we loop
        # 1024 times (each call leaked two fds).
        for i in range(1024):
            try:
                subprocess.Popen(['nonexisting_i_hope'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            # Windows raises IOError
            except (IOError, OSError) as err:
                self.assertEqual(err.errno, 2) 

This test is failing in py3k because errno is not being set on the
exception and is None. I don't have time to investigate more at the moment.

@birkenfeld
Copy link
Member

The problem is in os.py. This patch fixes it:

Index: Lib/os.py
===================================================================

--- Lib/os.py   (Revision 69769)
+++ Lib/os.py   (Arbeitskopie)
@@ -372,8 +372,8 @@
                 saved_exc = e
                 saved_tb = tb
     if saved_exc:
-        raise error(saved_exc).with_traceback(saved_tb)
-    raise error(last_exc).with_traceback(tb)
+        raise saved_exc.with_traceback(saved_tb)
+    raise last_exc.with_traceback(tb)

I suspect there may be other instances of this problem (I guess 2to3
converted that).

@benjaminp benjaminp self-assigned this Feb 19, 2009
@benjaminp
Copy link
Contributor Author

Thanks for the diagnostic, Georg! Fixed in r69794.

@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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants