From e9b307a5a751b92e209a892cc457f154473914f306071739b3f4756fcc62a44d Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Sun, 15 Dec 2024 23:34:12 +0000 Subject: [PATCH] - Add patch support-python-313.patch: * Fall back to mimetypes if imghdr isn't available. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-tweepy?expand=0&rev=31 --- python-tweepy.changes | 6 +++++ python-tweepy.spec | 4 ++- support-python-313.patch | 57 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 support-python-313.patch diff --git a/python-tweepy.changes b/python-tweepy.changes index ca00d7f..beeb44a 100644 --- a/python-tweepy.changes +++ b/python-tweepy.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sun Dec 15 23:33:36 UTC 2024 - Steve Kowalik + +- Add patch support-python-313.patch: + * Fall back to mimetypes if imghdr isn't available. + ------------------------------------------------------------------- Wed Mar 13 06:06:29 UTC 2024 - Steve Kowalik diff --git a/python-tweepy.spec b/python-tweepy.spec index 01a8e0f..77b5a1c 100644 --- a/python-tweepy.spec +++ b/python-tweepy.spec @@ -23,6 +23,8 @@ Summary: Twitter library for python License: MIT URL: https://github.com/tweepy/tweepy Source: https://github.com/tweepy/tweepy/archive/v%{version}.tar.gz +# PATCH-FIX-UPSTREAM Based on gh#tweepy/tweepy#2205 +Patch0: support-python-313.patch BuildRequires: %{python_module aiohttp} BuildRequires: %{python_module async-lru} BuildRequires: %{python_module pip} @@ -45,7 +47,7 @@ A library for accessing the Twitter.com API. Supports OAuth, covers the entire API, and streaming API. %prep -%setup -q -n tweepy-%{version} +%autosetup -p1 -n tweepy-%{version} %build %pyproject_wheel diff --git a/support-python-313.patch b/support-python-313.patch new file mode 100644 index 0000000..b58f201 --- /dev/null +++ b/support-python-313.patch @@ -0,0 +1,57 @@ +From 1cd1f4e51948b20dea9814ba27dfda271f299b99 Mon Sep 17 00:00:00 2001 +From: Christian Clauss +Date: Sat, 11 May 2024 07:24:17 +0200 +Subject: [PATCH 1/2] GitHub Actions: Test on Python 3.13 beta + +https://www.python.org/downloads/release/python-3130b1/ + +Raises an error because https://docs.python.org/3/library/imghdr.html was removed from the Standard Library in Python 3.13. +--- + .github/workflows/test.yml | 7 ++++--- + tests/test_api.py | 4 ++++ + tweepy/api.py | 5 ++++- + 3 files changed, 12 insertions(+), 4 deletions(-) + +Index: tweepy-4.14.0/tweepy/api.py +=================================================================== +--- tweepy-4.14.0.orig/tweepy/api.py ++++ tweepy-4.14.0/tweepy/api.py +@@ -4,7 +4,6 @@ + + import contextlib + import functools +-import imghdr + import logging + import mimetypes + from platform import python_version +@@ -3382,15 +3381,22 @@ class API: + ---------- + https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview + """ +- h = None +- if file is not None: +- location = file.tell() +- h = file.read(32) +- file.seek(location) +- file_type = imghdr.what(filename, h=h) +- if file_type is not None: +- file_type = 'image/' + file_type ++ file_type = None ++ try: ++ import imghdr ++ except ModuleNotFoundError: ++ # imghdr was removed in Python 3.13 ++ pass + else: ++ h = None ++ if file is not None: ++ location = file.tell() ++ h = file.read(32) ++ file.seek(location) ++ file_type = imghdr.what(filename, h=h) ++ if file_type is not None: ++ file_type = 'image/' + file_type ++ if file_type is None: + file_type = mimetypes.guess_type(filename)[0] + + if chunked or file_type.startswith('video/'):