SHA256
1
0
forked from pool/python-bson

4 Commits

4 changed files with 71 additions and 1 deletions

35
fix2038.patch Normal file
View File

@@ -0,0 +1,35 @@
Index: bson-0.5.8/bson/objectid.py
===================================================================
--- bson-0.5.8.orig/bson/objectid.py
+++ bson-0.5.8/bson/objectid.py
@@ -158,7 +158,7 @@ class ObjectId(object):
generation_time = generation_time - generation_time.utcoffset()
timestamp = calendar.timegm(generation_time.timetuple())
oid = struct.pack(
- ">i", int(timestamp)) + b"\x00\x00\x00\x00\x00\x00\x00\x00"
+ ">L", int(timestamp) & 0xFFFFFFFF) + b"\x00\x00\x00\x00\x00\x00\x00\x00"
return cls(oid)
@classmethod
@@ -184,7 +184,7 @@ class ObjectId(object):
"""
# 4 bytes current time
- oid = struct.pack(">i", int(time.time()))
+ oid = struct.pack(">L", int(time.time()) & 0xFFFFFFFF)
# 3 bytes machine
oid += ObjectId._machine_bytes
Index: bson-0.5.8/bson/tests/test_objectid.py
===================================================================
--- bson-0.5.8.orig/bson/tests/test_objectid.py
+++ bson-0.5.8/bson/tests/test_objectid.py
@@ -522,7 +522,7 @@ class TestObjectId(unittest.TestCase):
if 'PyPy 1.8.0' in sys.version:
# See https://bugs.pypy.org/issue1092
raise SkipTest("datetime.timedelta is broken in pypy 1.8.0")
- d = datetime.datetime.utcnow()
+ d = datetime.datetime.utcfromtimestamp(2000000000)
d = d - datetime.timedelta(microseconds=d.microsecond)
oid = ObjectId.from_datetime(d)
self.assertEqual(d, oid.generation_time.replace(tzinfo=None))

View File

@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Tue Oct 28 05:29:28 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-python314.patch:
* Support Python 3.14 removals.
-------------------------------------------------------------------
Thu Nov 14 20:23:54 UTC 2024 - Bernhard Wiedemann <bwiedemann@suse.com>
- Add fix2038.patch to fix an issue with year 2038
-------------------------------------------------------------------
Fri Dec 29 13:44:20 UTC 2023 - Antonio Larrosa <alarrosa@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-bson
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -28,6 +28,8 @@ Source: https://github.com/py-bson/bson/archive/%{version}.tar.gz#/bson-
Patch0: drop-python2-support.patch
# PATCH-FIX-OPENSUSE Use assertEqual to support Python 3.12
Patch1: support-python312.patch
Patch2: fix2038.patch
Patch3: support-python314.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}

22
support-python314.patch Normal file
View File

@@ -0,0 +1,22 @@
Index: bson-0.5.10/setup.py
===================================================================
--- bson-0.5.10.orig/setup.py
+++ bson-0.5.10/setup.py
@@ -4,7 +4,7 @@
# Copyright (c) 2015, Ayun Park. All rights reserved.
# For licensing, see LICENSE file included in the package.
import sys
-import pkgutil
+import importlib.util
from setuptools import setup
from setuptools.command.install import install
@@ -13,7 +13,7 @@ class NewInstall(install):
@staticmethod
def check_pymongo():
- if pkgutil.find_loader('pymongo'):
+ if importlib.util.find_spec('pymongo'):
return True
return False