Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions pymongo/asynchronous/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions pymongo/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 0 additions & 19 deletions pymongo/pool_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)))
Expand Down
6 changes: 2 additions & 4 deletions pymongo/pool_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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")


Expand Down
5 changes: 1 addition & 4 deletions pymongo/socket_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
17 changes: 0 additions & 17 deletions pymongo/synchronous/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
11 changes: 1 addition & 10 deletions test/asynchronous/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions test/asynchronous/utils_spec_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 0 additions & 4 deletions test/test_bson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
5 changes: 0 additions & 5 deletions test/test_bson_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 1 addition & 10 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions test/utils_spec_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading