diff --git a/pymongo/asynchronous/pool.py b/pymongo/asynchronous/pool.py index f521091e3c..4e1e7c0638 100644 --- a/pymongo/asynchronous/pool.py +++ b/pymongo/asynchronous/pool.py @@ -104,21 +104,6 @@ from pymongo.typings import _Address, _CollationIn from pymongo.write_concern import WriteConcern -try: - from fcntl import F_GETFD, F_SETFD, FD_CLOEXEC, fcntl - - def _set_non_inheritable_non_atomic(fd: int) -> None: - """Set the close-on-exec flag on the given file descriptor.""" - flags = fcntl(fd, F_GETFD) - fcntl(fd, F_SETFD, flags | FD_CLOEXEC) - -except ImportError: - # Windows, various platforms we don't claim to support - # (Jython, IronPython, ..), systems that don't provide - # everything we need from fcntl, etc. - def _set_non_inheritable_non_atomic(fd: int) -> None: # noqa: ARG001 - """Dummy function for platforms that don't provide fcntl.""" - _IS_SYNC = False @@ -706,8 +691,6 @@ class PoolState: CLOSED = 3 -# Do *not* explicitly inherit from object or Jython won't call __del__ -# https://bugs.jython.org/issue1057 class Pool: def __init__( self, diff --git a/pymongo/message.py b/pymongo/message.py index 0f3aaaba77..b0d1ceb105 100644 --- a/pymongo/message.py +++ b/pymongo/message.py @@ -1298,8 +1298,6 @@ def _batched_write_command_impl( # Start of payload buf.seek(-1, 2) - # Work around some Jython weirdness. - buf.truncate() try: buf.write(_OP_MAP[operation]) except KeyError: diff --git a/pymongo/pool_options.py b/pymongo/pool_options.py index a5d76007b0..d4c00ac46c 100644 --- a/pymongo/pool_options.py +++ b/pymongo/pool_options.py @@ -79,17 +79,6 @@ # Windows patch level (e.g. 10.0.17763-SP0). "version": ".".join(map(str, _ver[:3])) + f"-SP{_ver[-1] or '0'}", } -elif sys.platform.startswith("java"): - _name, _ver, _arch = platform.java_ver()[-1] - _METADATA["os"] = { - # Linux, Windows 7, Mac OS X, etc. - "type": _name, - "name": _name, - # x86, x86_64, AMD64, etc. - "architecture": _arch, - # Linux kernel version, OSX version, etc. - "version": _ver, - } else: # Get potential alias (e.g. SunOS 5.11 becomes Solaris 2.11) _aliased = platform.system_alias(platform.system(), platform.release(), platform.version()) @@ -108,14 +97,6 @@ "(Python %s)" % ".".join(map(str, sys.version_info)), ) ) -elif sys.platform.startswith("java"): - _METADATA["platform"] = " ".join( - ( - platform.python_implementation(), - ".".join(map(str, sys.version_info)), - "(%s)" % " ".join((platform.system(), platform.release())), - ) - ) else: _METADATA["platform"] = " ".join( (platform.python_implementation(), ".".join(map(str, sys.version_info))) diff --git a/pymongo/pool_shared.py b/pymongo/pool_shared.py index 8db26ccead..a6f434885b 100644 --- a/pymongo/pool_shared.py +++ b/pymongo/pool_shared.py @@ -237,8 +237,7 @@ async def _async_create_connection(address: _Address, options: PoolOptions) -> s else: # This likely means we tried to connect to an IPv6 only # host with an OS/kernel or Python interpreter that doesn't - # support IPv6. The test case is Jython2.5.1 which doesn't - # support IPv6 at all. + # support IPv6. raise OSError("getaddrinfo failed") @@ -418,8 +417,7 @@ def _create_connection(address: _Address, options: PoolOptions) -> socket.socket else: # This likely means we tried to connect to an IPv6 only # host with an OS/kernel or Python interpreter that doesn't - # support IPv6. The test case is Jython2.5.1 which doesn't - # support IPv6 at all. + # support IPv6. raise OSError("getaddrinfo failed") diff --git a/pymongo/socket_checker.py b/pymongo/socket_checker.py index 78861854ab..a2f65ebc38 100644 --- a/pymongo/socket_checker.py +++ b/pymongo/socket_checker.py @@ -17,12 +17,9 @@ import errno import select -import sys from typing import Any, Optional, cast -# PYTHON-2320: Jython does not fully support poll on SSL sockets, -# https://bugs.jython.org/issue2900 -_HAVE_POLL = hasattr(select, "poll") and not sys.platform.startswith("java") +_HAVE_POLL = hasattr(select, "poll") _SelectError = getattr(select, "error", OSError) diff --git a/pymongo/synchronous/pool.py b/pymongo/synchronous/pool.py index 66258fda18..89d2080bc8 100644 --- a/pymongo/synchronous/pool.py +++ b/pymongo/synchronous/pool.py @@ -104,21 +104,6 @@ from pymongo.typings import _Address, _CollationIn from pymongo.write_concern import WriteConcern -try: - from fcntl import F_GETFD, F_SETFD, FD_CLOEXEC, fcntl - - def _set_non_inheritable_non_atomic(fd: int) -> None: - """Set the close-on-exec flag on the given file descriptor.""" - flags = fcntl(fd, F_GETFD) - fcntl(fd, F_SETFD, flags | FD_CLOEXEC) - -except ImportError: - # Windows, various platforms we don't claim to support - # (Jython, IronPython, ..), systems that don't provide - # everything we need from fcntl, etc. - def _set_non_inheritable_non_atomic(fd: int) -> None: # noqa: ARG001 - """Dummy function for platforms that don't provide fcntl.""" - _IS_SYNC = True @@ -704,8 +689,6 @@ class PoolState: CLOSED = 3 -# Do *not* explicitly inherit from object or Jython won't call __del__ -# https://bugs.jython.org/issue1057 class Pool: def __init__( self, diff --git a/test/asynchronous/test_client.py b/test/asynchronous/test_client.py index 6794605339..15b32c4e99 100644 --- a/test/asynchronous/test_client.py +++ b/test/asynchronous/test_client.py @@ -1066,9 +1066,6 @@ async def test_close(self): await coll.count_documents({}) async def test_close_kills_cursors(self): - if sys.platform.startswith("java"): - # We can't figure out how to make this test reliable with Jython. - raise SkipTest("Can't test with Jython") test_client = await self.async_rs_or_single_client() # Kill any cursors possibly queued up by previous tests. gc.collect() @@ -1088,7 +1085,7 @@ async def test_close_kills_cursors(self): cursor = await coll.aggregate([], batchSize=10) self.assertTrue(bool(await anext(cursor))) del cursor - # Required for PyPy, Jython and other Python implementations that + # Required for PyPy and other Python implementations that # don't use reference counting garbage collection. gc.collect() @@ -1456,12 +1453,6 @@ async def test_contextlib(self): @async_client_context.require_sync def test_interrupt_signal(self): - if sys.platform.startswith("java"): - # We can't figure out how to raise an exception on a thread that's - # blocked on a socket, whether that's the main thread or a worker, - # without simply killing the whole thread in Jython. This suggests - # PYTHON-294 can't actually occur in Jython. - raise SkipTest("Can't test interrupts in Jython") if is_greenthread_patched(): raise SkipTest("Can't reliably test interrupts with green threads") diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index b49183a852..c1edb7a296 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -475,7 +475,7 @@ async def test_id_ordering(self): # when you iterate key/value pairs in a document. # This isn't reliable since python dicts don't # guarantee any particular order. This will never - # work right in Jython or any Python or environment + # work right in any Python or environment # with hash randomization enabled (e.g. tox). db = self.client.pymongo_test await db.test.drop() diff --git a/test/asynchronous/utils_spec_runner.py b/test/asynchronous/utils_spec_runner.py index 496c28a045..63e7e9e150 100644 --- a/test/asynchronous/utils_spec_runner.py +++ b/test/asynchronous/utils_spec_runner.py @@ -597,9 +597,7 @@ async def run_test_ops(self, sessions, collection, test): def parse_client_options(self, opts): """Allow encryption spec to override a clientOptions parsing.""" - # Convert test['clientOptions'] to dict to avoid a Jython bug using - # "**" with ScenarioDict. - return dict(opts) + return opts async def setup_scenario(self, scenario_def): """Allow specs to override a test's setup.""" diff --git a/test/test_bson.py b/test/test_bson.py index f49ae680e0..ffc02965fb 100644 --- a/test/test_bson.py +++ b/test/test_bson.py @@ -135,10 +135,6 @@ def assertInvalid(self, data): self.assertRaises(InvalidBSON, decode, data) def check_encode_then_decode(self, doc_class=dict, decoder=decode, encoder=encode): - # Work around http://bugs.jython.org/issue1728 - if sys.platform.startswith("java"): - doc_class = SON - def helper(doc): self.assertEqual(doc, (decoder(encoder(doc_class(doc))))) self.assertEqual(doc, decoder(encoder(doc))) diff --git a/test/test_bson_corpus.py b/test/test_bson_corpus.py index 504025e766..3370c18bda 100644 --- a/test/test_bson_corpus.py +++ b/test/test_bson_corpus.py @@ -160,11 +160,6 @@ def run_test(self): self.assertIsInstance(decoded_bson[test_key], _DEPRECATED_BSON_TYPES[bson_type]) continue - # Jython can't handle NaN with a payload from - # struct.(un)pack if endianness is specified in the format string. - if not (sys.platform.startswith("java") and description == "NaN with payload"): - # Test round-tripping canonical bson. - self.assertEqual(encode_bson(decoded_bson), cB, description) self.assertJsonEqual(encode_extjson(decoded_bson), cEJ) # Test round-tripping canonical extended json. diff --git a/test/test_client.py b/test/test_client.py index 9d201c663b..d07ce32365 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -1039,9 +1039,6 @@ def test_close(self): coll.count_documents({}) def test_close_kills_cursors(self): - if sys.platform.startswith("java"): - # We can't figure out how to make this test reliable with Jython. - raise SkipTest("Can't test with Jython") test_client = self.rs_or_single_client() # Kill any cursors possibly queued up by previous tests. gc.collect() @@ -1061,7 +1058,7 @@ def test_close_kills_cursors(self): cursor = coll.aggregate([], batchSize=10) self.assertTrue(bool(next(cursor))) del cursor - # Required for PyPy, Jython and other Python implementations that + # Required for PyPy and other Python implementations that # don't use reference counting garbage collection. gc.collect() @@ -1415,12 +1412,6 @@ def test_contextlib(self): @client_context.require_sync def test_interrupt_signal(self): - if sys.platform.startswith("java"): - # We can't figure out how to raise an exception on a thread that's - # blocked on a socket, whether that's the main thread or a worker, - # without simply killing the whole thread in Jython. This suggests - # PYTHON-294 can't actually occur in Jython. - raise SkipTest("Can't test interrupts in Jython") if is_greenthread_patched(): raise SkipTest("Can't reliably test interrupts with green threads") diff --git a/test/test_database.py b/test/test_database.py index ebbf6e55c6..25c3275238 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -470,7 +470,7 @@ def test_id_ordering(self): # when you iterate key/value pairs in a document. # This isn't reliable since python dicts don't # guarantee any particular order. This will never - # work right in Jython or any Python or environment + # work right in any Python or environment # with hash randomization enabled (e.g. tox). db = self.client.pymongo_test db.test.drop() diff --git a/test/utils_spec_runner.py b/test/utils_spec_runner.py index 46adeaefb5..9bf155e8f3 100644 --- a/test/utils_spec_runner.py +++ b/test/utils_spec_runner.py @@ -597,9 +597,7 @@ def run_test_ops(self, sessions, collection, test): def parse_client_options(self, opts): """Allow encryption spec to override a clientOptions parsing.""" - # Convert test['clientOptions'] to dict to avoid a Jython bug using - # "**" with ScenarioDict. - return dict(opts) + return opts def setup_scenario(self, scenario_def): """Allow specs to override a test's setup."""