-
Notifications
You must be signed in to change notification settings - Fork 126
Tests/t_ldapobject.py fails on pypy3 CI run #460
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
Comments
Fixed by e5959b3 |
Reopening as the new failure has appeared in the same test as the tearDown issue was fixed:
|
While working on #507 I created this patch: It removed one testing From 26d417d97f4aae2bd47b7205d86b24407285dfb8 Mon Sep 17 00:00:00 2001
Message-Id: <26d417d97f4aae2bd47b7205d86b24407285dfb8.1674804446.git.hahn@univention.de>
From: Philipp Hahn <hahn@univention.de>
Date: Wed, 25 Jan 2023 16:14:44 +0100
Subject: [PATCH] fix(Tests/t_ldapobject): Handle closed socket
`pypy3` may have already closed the socket as it is unspecified, when objects
are really freed.
Do not double-close it.
> =================================== FAILURES ===================================
> ________________ Test03_SimpleLDAPObjectWithFileno.test_slapadd ________________
>
> self = <Tests.t_ldapobject.Test03_SimpleLDAPObjectWithFileno testMethod=test_slapadd>
>
> def test_slapadd(self):
> with self.assertRaises(ldap.INVALID_DN_SYNTAX):
> self._ldap_conn.add_s("myAttribute=foobar,ou=Container,%s" % self.server.suffix, [
> ("objectClass", b'myClass'),
> ("myAttribute", b'foobar'),
> ])
>
> self.server.slapadd(SCHEMA_TEMPLATE, ["-n0"])
> self.server.restart()
> > self.reset_connection()
>
> Tests/t_ldapobject.py:561:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> Tests/t_ldapobject.py:665: in reset_connection
> self._sock.close()
> /usr/lib64/pypy3.9/socket.py:501: in close
> self._real_close()
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
> _ss = <class '_socket.socket'>
>
> def _real_close(self, _ss=_socket.socket):
> # This function should not reference any globals. See issue #808164.
> > _ss.close(self)
> E OSError: [Errno 9] Bad file descriptor
>
> /usr/lib64/pypy3.9/socket.py:495: OSError
---
Tests/t_ldapobject.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git Tests/t_ldapobject.py Tests/t_ldapobject.py
index ccc7d21..5617b63 100644
--- Tests/t_ldapobject.py
+++ Tests/t_ldapobject.py
@@ -656,14 +656,20 @@ class Test03_SimpleLDAPObjectWithFileno(Test00_SimpleLDAPObject):
who=who, cred=cred, fileno=self._sock.fileno(), **kwargs
)
- def tearDown(self):
- self._sock.close()
+ def __close_sock(self):
+ try:
+ self._sock.close()
+ except OSError as exc:
+ if exc.errno != errno.EBADF:
+ raise
delattr(self, '_sock')
+
+ def tearDown(self):
+ self.__close_sock()
super().tearDown()
def reset_connection(self):
- self._sock.close()
- delattr(self, '_sock')
+ self.__close_sock()
super(Test03_SimpleLDAPObjectWithFileno, self).reset_connection()
--
2.30.2 |
mistotebe
added a commit
to mistotebe/python-ldap
that referenced
this issue
Nov 1, 2023
mistotebe
added a commit
to mistotebe/python-ldap
that referenced
this issue
Nov 1, 2023
mistotebe
added a commit
to mistotebe/python-ldap
that referenced
this issue
Nov 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CI tests start to fail in Tests/t_ldapobject.py with the next error:
But always it points to:
Possibly, we're trying to close the socket that was already closed.
And, it's possibly a race condition because sometimes it happens and sometimes it's not (and only on pypy3 runs).
Further investigation is required.
The text was updated successfully, but these errors were encountered: