Accepting request 1042427 from home:pgajdos:python

- do not require six
- added patches
  fix c54ad6006b
  + python-python-multipart-no-six.patch

OBS-URL: https://build.opensuse.org/request/show/1042427
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-multipart?expand=0&rev=6
This commit is contained in:
Dirk Mueller 2022-12-12 21:00:19 +00:00 committed by Git OBS Bridge
parent 9b1979738f
commit 073e6564af
3 changed files with 140 additions and 3 deletions

View File

@ -0,0 +1,127 @@
Index: python-multipart-0.0.5/multipart/multipart.py
===================================================================
--- python-multipart-0.0.5.orig/multipart/multipart.py
+++ python-multipart-0.0.5/multipart/multipart.py
@@ -1,11 +1,5 @@
from __future__ import with_statement, absolute_import, print_function
-from six import (
- binary_type,
- text_type,
- PY3,
-)
-
from .decoders import *
from .exceptions import *
@@ -74,14 +68,9 @@ NULL = b'\x00'[0]
# str on Py2, and bytes on Py3. Same with getting the ordinal value of a byte,
# and joining a list of bytes together.
# These functions abstract that.
-if PY3: # pragma: no cover
- lower_char = lambda c: c | 0x20
- ord_char = lambda c: c
- join_bytes = lambda b: bytes(list(b))
-else: # pragma: no cover
- lower_char = lambda c: c.lower()
- ord_char = lambda c: ord(c)
- join_bytes = lambda b: b''.join(list(b))
+lower_char = lambda c: c | 0x20
+ord_char = lambda c: c
+join_bytes = lambda b: bytes(list(b))
# These are regexes for parsing header values.
SPECIAL_CHARS = re.escape(b'()<>@,;:\\"/[]?={} \t')
@@ -104,7 +93,7 @@ def parse_options_header(value):
# If we are passed a string, we assume that it conforms to WSGI and does
# not contain any code point that's not in latin-1.
- if isinstance(value, text_type): # pragma: no cover
+ if isinstance(value, str): # pragma: no cover
value = value.encode('latin-1')
# If we have no options, return the string as-is.
@@ -454,13 +443,13 @@ class File(object):
options = {}
if keep_extensions:
ext = self._ext
- if isinstance(ext, binary_type):
+ if isinstance(ext, bytes):
ext = ext.decode(sys.getfilesystemencoding())
options['suffix'] = ext
if file_dir is not None:
d = file_dir
- if isinstance(d, binary_type):
+ if isinstance(d, bytes):
d = d.decode(sys.getfilesystemencoding())
options['dir'] = d
@@ -478,7 +467,7 @@ class File(object):
fname = tmp_file.name
# Encode filename as bytes.
- if isinstance(fname, text_type):
+ if isinstance(fname, str):
fname = fname.encode(sys.getfilesystemencoding())
self._actual_file_name = fname
@@ -1037,7 +1026,7 @@ class MultipartParser(BaseParser):
# self.skip = tuple(skip)
# Save our boundary.
- if isinstance(boundary, text_type): # pragma: no cover
+ if isinstance(boundary, str): # pragma: no cover
boundary = boundary.encode('latin-1')
self.boundary = b'\r\n--' + boundary
Index: python-multipart-0.0.5/multipart/tests/test_multipart.py
===================================================================
--- python-multipart-0.0.5.orig/multipart/tests/test_multipart.py
+++ python-multipart-0.0.5/multipart/tests/test_multipart.py
@@ -14,7 +14,6 @@ from .compat import (
unittest,
)
from io import BytesIO
-from six import binary_type, text_type
try:
from unittest.mock import MagicMock, Mock, patch
@@ -29,7 +28,7 @@ curr_dir = os.path.abspath(os.path.dirna
def force_bytes(val):
- if isinstance(val, text_type):
+ if isinstance(val, str):
val = val.encode(sys.getfilesystemencoding())
return val
@@ -799,7 +798,7 @@ class TestFormParser(unittest.TestCase):
def test_http(self, param):
# Firstly, create our parser with the given boundary.
boundary = param['result']['boundary']
- if isinstance(boundary, text_type):
+ if isinstance(boundary, str):
boundary = boundary.encode('latin-1')
self.make(boundary)
Index: python-multipart-0.0.5/multipart/exceptions.py
===================================================================
--- python-multipart-0.0.5.orig/multipart/exceptions.py
+++ python-multipart-0.0.5/multipart/exceptions.py
@@ -1,7 +1,5 @@
import binascii
-from six import PY3
-
class FormParserError(ValueError):
"""Base error class for our form parser."""
@@ -52,7 +50,4 @@ else: # pragma
# We check which version of Python we're on to figure out what error we need
# to catch for invalid Base64.
-if PY3: # pragma: no cover
Base64Error = binascii.Error
-else: # pragma: no cover
- Base64Error = TypeError

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Dec 12 16:51:23 UTC 2022 - pgajdos@suse.com
- do not require six
- added patches
fix https://github.com/andrew-d/python-multipart/commit/c54ad6006bacc77623864ec8e5c96bfd32230e01
+ python-python-multipart-no-six.patch
-------------------------------------------------------------------
Fri Apr 8 09:51:38 UTC 2022 - pgajdos@suse.com

View File

@ -16,8 +16,6 @@
#
%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
Name: python-python-multipart
Version: 0.0.5
Release: 0
@ -27,7 +25,10 @@ URL: http://github.com/andrew-d/python-multipart
Source: https://files.pythonhosted.org/packages/source/p/python-multipart/python-multipart-%{version}.tar.gz
Patch0: support-pyyaml-6.patch
# https://github.com/andrew-d/python-multipart/commit/8cff1aac7479fbb69087e355f66315b21640bab0
# https://github.com/andrew-d/python-multipart/commit/2c7e95c7236fcecdb5660823936403d1359fdb85
Patch1: python-python-multipart-no-mock.patch
# https://github.com/andrew-d/python-multipart/commit/c54ad6006bacc77623864ec8e5c96bfd32230e01
Patch2: python-python-multipart-no-six.patch
BuildRequires: %{python_module setuptools}
BuildRequires: python-rpm-macros
# SECTION test requirements
@ -60,6 +61,7 @@ A streaming multipart parser for Python.
%files %{python_files}
%doc README.rst
%license LICENSE.txt
%{python_sitelib}/*
%{python_sitelib}/multipart
%{python_sitelib}/python_multipart-*.egg-info
%changelog