- Add remove-six.patch (gh#gruns/furl#175) removing the

dependency on six.
- Add fix-test_odd_urls.patch fixing the failure of
  tests/test_furl.py::TestFurl::test_odd_urls test with the
  recent Python interpreters (gh#gruns/furl#176).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-furl?expand=0&rev=24
This commit is contained in:
Matej Cepl 2024-09-13 19:07:55 +00:00 committed by Git OBS Bridge
commit d88237f0c4
9 changed files with 591 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,145 @@
From 38587f3dca7e2f75b04cb0d80e4fc30ea6e139dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89loi=20Rivard?= <eloi.rivard@aquilenet.fr>
Date: Sat, 24 Sep 2022 15:40:59 +0200
Subject: [PATCH] Use ipaddress to detect valid and invalid IPs
---
furl/furl.py | 47 +++++++++++++++++++++++++++++++++++++---------
setup.py | 1 +
tests/test_furl.py | 21 +++++++++++----------
3 files changed, 50 insertions(+), 19 deletions(-)
Index: furl-2.1.3/furl/furl.py
===================================================================
--- furl-2.1.3.orig/furl/furl.py
+++ furl-2.1.3/furl/furl.py
@@ -12,6 +12,7 @@
import re
import abc
+import ipaddress
import warnings
from copy import deepcopy
from posixpath import normpath
@@ -241,6 +242,37 @@ def is_valid_host(hostname):
return '' not in toks # Adjacent periods aren't allowed.
+def is_valid_ipv4(ip):
+ if isinstance(ip, six.binary_type):
+ ip = ip.decode()
+
+ try:
+ ipaddress.IPv4Address(ip)
+ return True
+ except ValueError:
+ return False
+
+
+def is_valid_ipv6(ip):
+ if isinstance(ip, six.binary_type):
+ ip = ip.decode()
+
+ # ipaddress handle IPs without brackets
+ if (
+ callable_attr(ip, 'startswith')
+ and callable_attr(ip, 'endswith')
+ and ip.startswith("[")
+ and ip.endswith("]")
+ ):
+ ip = ip[1:-1]
+
+ try:
+ ipaddress.IPv6Address(ip)
+ return True
+ except ValueError:
+ return False
+
+
def get_scheme(url):
if url.startswith(':'):
return ''
@@ -1434,15 +1466,12 @@ class furl(URLPathCompositionInterface,
"""
Raises: ValueError on invalid host or malformed IPv6 address.
"""
- # Invalid IPv6 literal.
- urllib.parse.urlsplit('http://%s/' % host) # Raises ValueError.
-
- # Invalid host string.
- resembles_ipv6_literal = (
- host is not None and lget(host, 0) == '[' and ':' in host and
- lget(host, -1) == ']')
- if (host is not None and not resembles_ipv6_literal and
- not is_valid_host(host)):
+ if (
+ host
+ and not is_valid_host(host)
+ and not is_valid_ipv4(host)
+ and not is_valid_ipv6(host)
+ ):
errmsg = (
"Invalid host '%s'. Host strings must have at least one "
"non-period character, can't contain any of '%s', and can't "
Index: furl-2.1.3/setup.py
===================================================================
--- furl-2.1.3.orig/setup.py
+++ furl-2.1.3/setup.py
@@ -109,6 +109,7 @@ setup(
install_requires=[
'six>=1.8.0',
'orderedmultidict>=1.0.1',
+ 'ipaddress>=1.0.23; python_version < "3.3"',
],
cmdclass={
'test': RunTests,
Index: furl-2.1.3/tests/test_furl.py
===================================================================
--- furl-2.1.3.orig/tests/test_furl.py
+++ furl-2.1.3/tests/test_furl.py
@@ -1666,10 +1666,10 @@ class TestFurl(unittest.TestCase):
# addresses.
f = furl.furl('http://1.2.3.4.5.6/')
- # Invalid, but well-formed, IPv6 addresses shouldn't raise an
- # exception because urlparse.urlsplit() doesn't raise an
- # exception on invalid IPv6 addresses.
- furl.furl('http://[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]/')
+ # Invalid, but well-formed, IPv6 addresses should raise an
+ # exception.
+ with self.assertRaises(ValueError):
+ furl.furl('http://[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]/')
# Malformed IPv6 should raise an exception because urlparse.urlsplit()
# raises an exception on malformed IPv6 addresses.
@@ -1695,12 +1695,17 @@ class TestFurl(unittest.TestCase):
assert f.host == '1.2.3.4.5.6'
assert f.port == 999
- netloc = '[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]:888'
+ netloc = '[1:2:3:4:5:6:7:8]:888'
f.netloc = netloc
assert f.netloc == netloc
- assert f.host == '[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]'
+ assert f.host == '[1:2:3:4:5:6:7:8]'
assert f.port == 888
+ # Well-formed but invalid IPv6 should raise an exception
+ netloc = '[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]:888'
+ with self.assertRaises(ValueError):
+ f.netloc = netloc
+
# Malformed IPv6 should raise an exception because
# urlparse.urlsplit() raises an exception
with self.assertRaises(ValueError):
@@ -1714,10 +1719,6 @@ class TestFurl(unittest.TestCase):
with self.assertRaises(ValueError):
f.netloc = 'pump2pump.org:777777777777'
- # No side effects.
- assert f.host == '[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]'
- assert f.port == 888
-
# Empty netloc.
f = furl.furl('//')
assert f.scheme is None and f.netloc == '' and f.url == '//'

15
fix-test_odd_urls.patch Normal file
View File

@ -0,0 +1,15 @@
---
tests/test_furl.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tests/test_furl.py
+++ b/tests/test_furl.py
@@ -1637,7 +1637,7 @@ class TestFurl(unittest.TestCase):
# of a netloc, even if the netloc is empty.
f = furl.furl('////path')
assert f.netloc == '' and str(f.path) == '//path'
- assert f.url == '////path'
+ assert f.url in ('//////path', '////path')
# TODO(grun): Test more odd URLs.

BIN
furl-2.1.3.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

22
netloc-tests.patch Normal file
View File

@ -0,0 +1,22 @@
Index: furl-2.1.3/tests/test_furl.py
===================================================================
--- furl-2.1.3.orig/tests/test_furl.py
+++ furl-2.1.3/tests/test_furl.py
@@ -1635,11 +1635,12 @@ class TestFurl(unittest.TestCase):
f.port = None
assert f.url == '' and f.netloc is None
- # urlparse.urlsplit() treats the first two '//' as the beginning
- # of a netloc, even if the netloc is empty.
- f = furl.furl('////path')
- assert f.netloc == '' and str(f.path) == '//path'
- assert f.url == '////path'
+ if sys.version_info < (3, 12):
+ # urlparse.urlsplit() treats the first two '//' as the beginning
+ # of a netloc, even if the netloc is empty.
+ f = furl.furl('////path')
+ assert f.netloc == '' and str(f.path) == '//path'
+ assert f.url == '////path'
# TODO(grun): Test more odd URLs.

98
python-furl.changes Normal file
View File

@ -0,0 +1,98 @@
-------------------------------------------------------------------
Fri Sep 13 18:56:20 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Add remove-six.patch (gh#gruns/furl#175) removing the
dependency on six.
- Add fix-test_odd_urls.patch fixing the failure of
tests/test_furl.py::TestFurl::test_odd_urls test with the
recent Python interpreters (gh#gruns/furl#176).
-------------------------------------------------------------------
Tue Jul 2 20:29:03 UTC 2024 - Dirk Müller <dmueller@suse.com>
- add netloc-tests.patch to skip failing test with python 3.12
-------------------------------------------------------------------
Tue Jul 4 22:28:07 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Add 165-use-ipaddress-library.patch to use standard ipaddress
library to parse IP addresses (gh#gruns/furl#164).
-------------------------------------------------------------------
Fri Apr 21 12:24:55 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Wed Sep 28 19:47:43 UTC 2022 - Yogalakshmi Arunachalam <yarunachalam@suse.com>
- version update to v2.1.3
Fixed: Actually drop ';' as a query delimiter. See furl v2.1.2's
changelog and https://bugs.python.org/issue42967.
-------------------------------------------------------------------
Fri Aug 19 16:28:12 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Skip python2: Fixes 15.X build
- Remove flake8 test requirement: no code linting required for
packaging
-------------------------------------------------------------------
Mon May 17 10:41:58 UTC 2021 - pgajdos@suse.com
- version update to 2.1.2
Fixed: Support Python 3.9's changed urllib.parse.urljoin() behavior.
Changed: Drop semicolon query delimiters. See https://bugs.python.org/issue42967.
Changed: Drop support for EOL Python 3.4 and Python 3.5.
- deleted patches
- furl-py39-join.patch (upstreamed)
- tests_overcome_bpo42967.patch (upstreamed)
-------------------------------------------------------------------
Mon Mar 29 22:10:03 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Add furl-py39-join.patch to fix Python 3.9 test failure
gh#gruns/furl#139
- Submitted tests_overcome_bpo42967.patch as gh#gruns/furl#140
-------------------------------------------------------------------
Tue Feb 23 16:19:20 UTC 2021 - Matej Cepl <mcepl@suse.com>
- Switch testing to pytest, it is just more convenient to debug.
- Add tests_overcome_bpo42967.patch to overcome changes in Python
interpreter after fixing bpo#42967 (gh#gruns/furl#135).
-------------------------------------------------------------------
Thu Mar 5 12:33:35 UTC 2020 - pgajdos@suse.com
- version update to 2.1.0
Added: a dont_quote= parameter to Query.encode() and a
query_dont_quote= parameter to furl.tostr() that exempt valid query
characters from being percent-encoded, either in their entirety with
dont_quote=True, or selectively with dont_quote=<string>, like
dont_quote='/?@_'.
Changed: Move package info from __init__.py into the more standard
__version__.py.
Fixed: Support Unicode usernames and passwords in Python 2.
Fixed: Update orderedmultdict to v1.0.1 to resolve a DeprecationWarning.
Fixed: Encode '/' consistently in query strings across both
quote_plus=True and quote_plus=False.
-------------------------------------------------------------------
Sat Aug 24 16:20:56 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
- Use noun phrase in descriptions.
-------------------------------------------------------------------
Wed Jul 24 09:54:00 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Format with spec-cleaner
-------------------------------------------------------------------
Sun Jun 2 04:03:55 AM UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Initial spec for v2.0.0

74
python-furl.spec Normal file
View File

@ -0,0 +1,74 @@
#
# spec file for package python-furl
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
%define skip_python2 1
Name: python-furl
Version: 2.1.3
Release: 0
Summary: A Python URL manipulation library
License: Unlicense
Group: Development/Languages/Python
URL: https://github.com/gruns/furl
Source: https://files.pythonhosted.org/packages/source/f/furl/furl-%{version}.tar.gz
# PATCH-FIX-UPSTREAM 165-use-ipaddress-library.patch gh#gruns/furl#164 mcepl@suse.com
# use ipaddress to parse IP addresses
Patch0: 165-use-ipaddress-library.patch
Patch1: netloc-tests.patch
# PATCH-FEATURE-UPSTREAM remove-six.patch gh#gruns/furl#175 mcepl@suse.com
# remove the need of using six
Patch2: remove-six.patch
# PATCH-FIX-UPSTREAM fix-test_odd_urls.patch gh#gruns/furl#176 mcepl@suse.com
# Python currently parses '////path' URL in a different way
Patch3: fix-test_odd_urls.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-orderedmultidict >= 1.0.1
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module orderedmultidict >= 1.0.1}
BuildRequires: %{python_module pytest}
# /SECTION
%python_subpackages
%description
furl is a Python library for parsing and manipulating URLs.
%prep
%autosetup -p1 -n furl-%{version}
chmod -x *.md furl.egg-info/*
%build
%pyproject_wheel
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
%files %{python_files}
%doc README.md
%license LICENSE.md
%{python_sitelib}/furl
%{python_sitelib}/furl-%{version}*-info
%changelog

210
remove-six.patch Normal file
View File

@ -0,0 +1,210 @@
---
furl.egg-info/requires.txt | 1 -
furl/furl.py | 34 ++++++++++++++--------------------
setup.py | 2 --
tests/test_furl.py | 7 ++-----
tests/test_omdict1D.py | 7 +++----
5 files changed, 19 insertions(+), 32 deletions(-)
--- a/furl.egg-info/requires.txt
+++ b/furl.egg-info/requires.txt
@@ -1,2 +1 @@
-six>=1.8.0
orderedmultidict>=1.0.1
--- a/furl/furl.py
+++ b/furl/furl.py
@@ -17,9 +17,8 @@ import warnings
from copy import deepcopy
from posixpath import normpath
-import six
-from six.moves import urllib
-from six.moves.urllib.parse import quote, unquote
+import urllib
+from urllib.parse import quote, unquote
try:
from icecream import ic
except ImportError: # Graceful fallback if IceCream isn't installed.
@@ -138,7 +137,7 @@ def is_valid_port(port):
def static_vars(**kwargs):
def decorator(func):
- for key, value in six.iteritems(kwargs):
+ for key, value in kwargs.items():
setattr(func, key, value)
return func
return decorator
@@ -243,7 +242,7 @@ def is_valid_host(hostname):
def is_valid_ipv4(ip):
- if isinstance(ip, six.binary_type):
+ if isinstance(ip, bytes):
ip = ip.decode()
try:
@@ -254,7 +253,7 @@ def is_valid_ipv4(ip):
def is_valid_ipv6(ip):
- if isinstance(ip, six.binary_type):
+ if isinstance(ip, bytes):
ip = ip.decode()
# ipaddress handle IPs without brackets
@@ -733,8 +732,7 @@ class Path(object):
return '/'.join(segments)
-@six.add_metaclass(abc.ABCMeta)
-class PathCompositionInterface(object):
+class PathCompositionInterface(object, metaclass=abc.ABCMeta):
"""
Abstract class interface for a parent class that contains a Path.
@@ -784,8 +782,7 @@ class PathCompositionInterface(object):
return False
-@six.add_metaclass(abc.ABCMeta)
-class URLPathCompositionInterface(PathCompositionInterface):
+class URLPathCompositionInterface(PathCompositionInterface, metaclass=abc.ABCMeta):
"""
Abstract class interface for a parent class that contains a URL
@@ -812,8 +809,7 @@ class URLPathCompositionInterface(PathCo
return bool(path) and self.netloc
-@six.add_metaclass(abc.ABCMeta)
-class FragmentPathCompositionInterface(PathCompositionInterface):
+class FragmentPathCompositionInterface(PathCompositionInterface, metaclass=abc.ABCMeta):
"""
Abstract class interface for a parent class that contains a Fragment
@@ -1125,7 +1121,7 @@ class Query(object):
elif callable_attr(items, 'iteritems'):
items = list(items.iteritems())
# Encoded query string. e.g. 'a=1&b=2&c=3'
- elif isinstance(items, six.string_types):
+ elif isinstance(items, str):
items = self._extract_items_from_querystr(items)
# Default to list of key:value items interface. e.g. [('a','1'),
# ('b','2')]
@@ -1141,7 +1137,7 @@ class Query(object):
pairs = [item.split('=', 1) for item in pairstrs]
pairs = [(p[0], lget(p, 1, '')) for p in pairs] # Pad with value ''.
- for pairstr, (key, value) in six.moves.zip(pairstrs, pairs):
+ for pairstr, (key, value) in zip(pairstrs, pairs):
valid_key = is_valid_encoded_query_key(key)
valid_value = is_valid_encoded_query_value(value)
if self.strict and (not valid_key or not valid_value):
@@ -1163,8 +1159,7 @@ class Query(object):
return items
-@six.add_metaclass(abc.ABCMeta)
-class QueryCompositionInterface(object):
+class QueryCompositionInterface(object, metaclass=abc.ABCMeta):
"""
Abstract class interface for a parent class that contains a Query.
@@ -1331,8 +1326,7 @@ class Fragment(FragmentPathCompositionIn
return "%s('%s')" % (self.__class__.__name__, str(self))
-@six.add_metaclass(abc.ABCMeta)
-class FragmentCompositionInterface(object):
+class FragmentCompositionInterface(object, metaclass=abc.ABCMeta):
"""
Abstract class interface for a parent class that contains a
@@ -1430,7 +1424,7 @@ class furl(URLPathCompositionInterface,
if url is None:
url = ''
- if not isinstance(url, six.string_types):
+ if not isinstance(url, str):
url = str(url)
# urlsplit() raises a ValueError on malformed IPv6 addresses in
@@ -1874,7 +1868,7 @@ class furl(URLPathCompositionInterface,
def join(self, *urls):
for url in urls:
- if not isinstance(url, six.string_types):
+ if not isinstance(url, str):
url = str(url)
newurl = urljoin(self.url, url)
self.load(newurl)
--- a/setup.py
+++ b/setup.py
@@ -104,10 +104,8 @@ setup(
],
tests_require=[
'flake8',
- 'six>=1.8.0',
],
install_requires=[
- 'six>=1.8.0',
'orderedmultidict>=1.0.1',
'ipaddress>=1.0.23; python_version < "3.3"',
],
--- a/tests/test_furl.py
+++ b/tests/test_furl.py
@@ -16,9 +16,7 @@ import warnings
from abc import ABCMeta, abstractmethod
import sys
-import six
-from six.moves import zip
-from six.moves.urllib.parse import (
+from urllib.parse import (
quote, quote_plus, parse_qsl, urlsplit, SplitResult)
import furl
@@ -35,8 +33,7 @@ import unittest
#
-@six.add_metaclass(ABCMeta)
-class itemcontainer(object):
+class itemcontainer(object, metaclass=ABCMeta):
"""
Utility list subclasses to expose allitems() and iterallitems()
--- a/tests/test_omdict1D.py
+++ b/tests/test_omdict1D.py
@@ -13,7 +13,6 @@
import unittest
from itertools import chain, product, permutations
-import six
from furl.omdict1D import omdict1D
from orderedmultidict import omdict
@@ -48,12 +47,12 @@ class TestOmdict1D(unittest.TestCase):
data.update(update)
omd1.update(update)
omd2.updateall(update)
- for key in six.iterkeys(omd1):
+ for key in omd1.keys():
if isinstance(data[key], list):
assert omd1[key] == data[key][-1]
else:
assert omd1[key] == data[key]
- for key in six.iterkeys(omd2):
+ for key in omd2.keys():
data_values_unpacked = []
for value in data.getlist(key):
if isinstance(value, list):
@@ -149,7 +148,7 @@ class TestOmdict1D(unittest.TestCase):
def test_setitem(self):
omd = omdict1D()
- for value, valuelist in six.moves.zip(self.values, self.valuelists):
+ for value, valuelist in zip(self.values, self.valuelists):
if valuelist:
omd[self.key] = valuelist
assert omd[self.key] == omd.get(self.key) == valuelist[0]