Accepting request 1136629 from home:bnavigator:branches:devel:languages:python

- Remove six from the rpm requirements. Why would we have
  remove_six.patch in the first place if we still require it?
- Enable unit tests

OBS-URL: https://build.opensuse.org/request/show/1136629
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-configobj?expand=0&rev=47
This commit is contained in:
Dirk Mueller 2024-01-03 17:31:00 +00:00 committed by Git OBS Bridge
parent 1c11e32e06
commit 78e35eec4f
5 changed files with 198 additions and 19 deletions

BIN
configobj-5.0.8-gh.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
configobj-5.0.8.tar.gz (Stored with Git LFS)

Binary file not shown.

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Jan 3 16:47:32 UTC 2024 - Ben Greiner <code@bnavigator.de>
- Remove six from the rpm requirements. Why would we have
remove_six.patch in the first place if we still require it?
- Enable unit tests
-------------------------------------------------------------------
Wed Jan 3 09:46:30 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@ -24,7 +24,8 @@ Summary: Config file reading, writing and validation
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/DiffSK/configobj
Source: https://files.pythonhosted.org/packages/source/c/configobj/configobj-%{version}.tar.gz
# No tests in PyPI sdist
Source: https://github.com/DiffSK/configobj/archive/refs/tags/v%{version}.tar.gz#/configobj-%{version}-gh.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/DiffSK/configobj/pull/236 Address CVE-2023-26112 ReDoS
Patch0: CVE-2023-26112.patch
# PATCH-FIX-UPSTREAM remove_six.patch gh#DiffSK/configobj#239 mcepl@suse.com
@ -35,8 +36,10 @@ BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-six
BuildArch: noarch
# SECTION test
BuildRequires: %{python_module pytest}
# /SECTION
%python_subpackages
%description
@ -68,9 +71,12 @@ It has lots of other features though:
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
%files %{python_files}
%{python_sitelib}/configobj
%{python_sitelib}/validate
%{python_sitelib}/configobj-%{version}*-info
%{python_sitelib}/configobj-%{version}.dist-info
%changelog

View File

@ -1,11 +1,9 @@
---
setup.py | 1
src/configobj.egg-info/requires.txt | 1
src/configobj/__init__.py | 49 ++++++++++++++++--------------------
3 files changed, 22 insertions(+), 29 deletions(-)
https://github.com/DiffSK/configobj/issues/239
--- a/setup.py
+++ b/setup.py
Index: configobj-5.0.8/setup.py
===================================================================
--- configobj-5.0.8.orig/setup.py
+++ configobj-5.0.8/setup.py
@@ -41,7 +41,6 @@ DESCRIPTION = 'Config file reading, writ
URL = 'https://github.com/DiffSK/configobj'
@ -14,12 +12,10 @@
"""
VERSION = ''
--- a/src/configobj.egg-info/requires.txt
+++ b/src/configobj.egg-info/requires.txt
@@ -1 +0,0 @@
-six
--- a/src/configobj/__init__.py
+++ b/src/configobj/__init__.py
Index: configobj-5.0.8/src/configobj/__init__.py
===================================================================
--- configobj-5.0.8.orig/src/configobj/__init__.py
+++ configobj-5.0.8/src/configobj/__init__.py
@@ -19,7 +19,6 @@ import sys
from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE
@ -211,3 +207,173 @@
raise ReloadError()
filename = self.filename
Index: configobj-5.0.8/src/tests/test_configobj.py
===================================================================
--- configobj-5.0.8.orig/src/tests/test_configobj.py
+++ configobj-5.0.8/src/tests/test_configobj.py
@@ -1,5 +1,6 @@
# coding=utf-8
from __future__ import unicode_literals
+import io
import os
import re
@@ -8,7 +9,6 @@ from warnings import catch_warnings
from tempfile import NamedTemporaryFile
import pytest
-import six
import configobj as co
from configobj import ConfigObj, flatten_errors, ReloadError, DuplicateError, MissingInterpolationOption, InterpolationLoopError, ConfigObjError
@@ -36,13 +36,13 @@ def cfg_lines(config_string_representati
'{!r}'.format(config_string_representation))
first_content = lines[line_no_with_content]
- if isinstance(first_content, six.binary_type):
+ if isinstance(first_content, bytes):
first_content = first_content.decode('utf-8')
ws_chars = len(re.search('^(\s*)', first_content).group(1))
def yield_stringified_line():
for line in lines:
- if isinstance(line, six.binary_type):
+ if isinstance(line, bytes):
yield line.decode('utf-8')
else:
yield line
@@ -70,7 +70,7 @@ def cfg_contents(request):
with NamedTemporaryFile(delete=False, mode='wb') as cfg_file:
for line in lines:
- if isinstance(line, six.binary_type):
+ if isinstance(line, bytes):
cfg_file.write(line + os.linesep.encode('utf-8'))
else:
cfg_file.write((line + os.linesep).encode('utf-8'))
@@ -186,11 +186,7 @@ class TestEncoding(object):
c = ConfigObj(cfg, encoding='utf8')
- if six.PY2:
- assert not isinstance(c['test'], str)
- assert isinstance(c['test'], unicode)
- else:
- assert isinstance(c['test'], str)
+ assert isinstance(c['test'], str)
#issue #18
@@ -198,11 +194,7 @@ class TestEncoding(object):
cfg = cfg_contents(b"test = some string")
c = ConfigObj(cfg)
- if six.PY2:
- assert isinstance(c['test'], str)
- assert not isinstance(c['test'], unicode)
- else:
- assert isinstance(c['test'], str)
+ assert isinstance(c['test'], str)
#issue #44
def test_that_encoding_using_list_of_strings(self):
@@ -210,11 +202,7 @@ class TestEncoding(object):
c = ConfigObj(cfg, encoding='utf8')
- if six.PY2:
- assert isinstance(c['test'], unicode)
- assert not isinstance(c['test'], str)
- else:
- assert isinstance(c['test'], str)
+ assert isinstance(c['test'], str)
assert c['test'] == '\U0001f41c'
@@ -223,7 +211,7 @@ class TestEncoding(object):
c = cfg_contents(ant_cfg)
cfg = ConfigObj(c, encoding='utf-8')
- assert isinstance(cfg['tags']['bug']['translated'], six.text_type)
+ assert isinstance(cfg['tags']['bug']['translated'], str)
#issue #44 and #55
def test_encoding_in_config_files(self, request, ant_cfg):
@@ -233,7 +221,7 @@ class TestEncoding(object):
request.addfinalizer(lambda : os.unlink(cfg_file.name))
cfg = ConfigObj(cfg_file.name, encoding='utf-8')
- assert isinstance(cfg['tags']['bug']['translated'], six.text_type)
+ assert isinstance(cfg['tags']['bug']['translated'], str)
cfg.write()
@pytest.fixture
@@ -500,7 +488,7 @@ def test_unicode_handling():
'section': {'test': 'test', 'test2': 'test2'}}
uc = ConfigObj(u, encoding='utf_8', default_encoding='latin-1')
assert uc.BOM
- assert isinstance(uc['test1'], six.text_type)
+ assert isinstance(uc['test1'], str)
assert uc.encoding == 'utf_8'
assert uc.newlines == '\n'
assert len(uc.write()) == 13
@@ -508,14 +496,14 @@ def test_unicode_handling():
a_list = uc.write()
assert 'latin1' in str(a_list)
assert len(a_list) == 14
- assert isinstance(a_list[0], six.binary_type)
+ assert isinstance(a_list[0], bytes)
assert a_list[0].startswith(BOM_UTF8)
u = u_base.replace('\n', '\r\n').encode('utf-8').splitlines(True)
uc = ConfigObj(u)
assert uc.newlines == '\r\n'
uc.newlines = '\r'
- file_like = six.BytesIO()
+ file_like = io.BytesIO()
uc.write(file_like)
file_like.seek(0)
uc2 = ConfigObj(file_like)
@@ -723,7 +711,7 @@ class TestSectionBehavior(object):
val = section[key]
newkey = key.replace('XXXX', 'CLIENT1')
section.rename(key, newkey)
- if isinstance(val, six.string_types):
+ if isinstance(val, str):
val = val.replace('XXXX', 'CLIENT1')
section[newkey] = val
@@ -811,7 +799,7 @@ class TestReloading(object):
return content
def test_handle_no_filename(self):
- for bad_args in ([six.BytesIO()], [], [[]]):
+ for bad_args in ([io.BytesIO()], [], [[]]):
cfg = ConfigObj(*bad_args)
with pytest.raises(ReloadError) as excinfo:
cfg.reload()
@@ -1264,21 +1252,21 @@ class TestEdgeCasesWhenWritingOut(object
def test_newline_terminated(self, empty_cfg):
empty_cfg.newlines = '\n'
empty_cfg['a'] = 'b'
- collector = six.BytesIO()
+ collector = io.BytesIO()
empty_cfg.write(collector)
assert collector.getvalue() == b'a = b\n'
def test_hash_escaping(self, empty_cfg):
empty_cfg.newlines = '\n'
empty_cfg['#a'] = 'b # something'
- collector = six.BytesIO()
+ collector = io.BytesIO()
empty_cfg.write(collector)
assert collector.getvalue() == b'"#a" = "b # something"\n'
empty_cfg = ConfigObj()
empty_cfg.newlines = '\n'
empty_cfg['a'] = 'b # something', 'c # something'
- collector = six.BytesIO()
+ collector = io.BytesIO()
empty_cfg.write(collector)
assert collector.getvalue() == b'a = "b # something", "c # something"\n'