Skip to content

Commit

Permalink
Add python 3.11 support (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedepad authored Jan 7, 2023
1 parent 851e752 commit 3d5f326
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]

steps:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/pythonpackage-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Python package

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:
name: Test on python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [macos-12]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install certifi urllib3 mock pytest
- name: Add to PATH if Python version >= 3.11
if: matrix.python-version == '3.11' && matrix.os == 'macos-12'
run: |
echo "/Users/runner/Library/Python/3.11/bin" >> $GITHUB_PATH
- name: Add to PATH for Python version < 3.11
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "/Users/runner/.local/bin" >> $GITHUB_PATH
- name: Run checks
run: |
make check
- name: Run unit tests
run: |
python setup.py install
pytest
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [windows-latest]

steps:
Expand Down
28 changes: 14 additions & 14 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _handle_redirect_response(
307: ("Redirect", "Temporary redirect"),
400: ("BadRequest", "Bad request"),
}.get(response.status, (None, None))
region = response.getheader("x-amz-bucket-region")
region = response.headers.get("x-amz-bucket-region")
if message and region:
message += "; use region " + region

Expand Down Expand Up @@ -297,7 +297,7 @@ def _url_open( # pylint: disable=too-many-branches

if (
method != "HEAD" and
"application/xml" not in response.getheader(
"application/xml" not in response.headers.get(
"content-type", "",
).split(";")
):
Expand All @@ -310,7 +310,7 @@ def _url_open( # pylint: disable=too-many-branches
)
raise InvalidResponseError(
response.status,
response.getheader("content-type"),
response.headers.get("content-type"),
response.data.decode() if response.data else None,
)

Expand All @@ -319,7 +319,7 @@ def _url_open( # pylint: disable=too-many-branches
self._trace_stream.write("----------END-HTTP----------\n")
raise InvalidResponseError(
response.status,
response.getheader("content-type"),
response.headers.get("content-type"),
None,
)

Expand Down Expand Up @@ -373,8 +373,8 @@ def _url_open( # pylint: disable=too-many-branches
code,
message,
url.path,
response.getheader("x-amz-request-id"),
response.getheader("x-amz-id-2"),
response.headers.get("x-amz-request-id"),
response.headers.get("x-amz-id-2"),
response,
bucket_name=bucket_name,
object_name=object_name,
Expand Down Expand Up @@ -1287,7 +1287,7 @@ def copy_object(self, bucket_name, object_name, source,
return ObjectWriteResult(
bucket_name,
object_name,
response.getheader("x-amz-version-id"),
response.headers.get("x-amz-version-id"),
etag,
response.headers,
last_modified=last_modified,
Expand Down Expand Up @@ -1587,8 +1587,8 @@ def _put_object(self, bucket_name, object_name, data, headers,
return ObjectWriteResult(
bucket_name,
object_name,
response.getheader("x-amz-version-id"),
response.getheader("etag").replace('"', ""),
response.headers.get("x-amz-version-id"),
response.headers.get("etag").replace('"', ""),
response.headers,
)

Expand Down Expand Up @@ -1873,19 +1873,19 @@ def stat_object(self, bucket_name, object_name, ssec=None, version_id=None,
query_params=query_params,
)

last_modified = response.getheader("last-modified")
last_modified = response.headers.get("last-modified")
if last_modified:
last_modified = time.from_http_header(last_modified)

return Object(
bucket_name,
object_name,
last_modified=last_modified,
etag=response.getheader("etag", "").replace('"', ""),
size=int(response.getheader("content-length", "0")),
content_type=response.getheader("content-type"),
etag=response.headers.get("etag", "").replace('"', ""),
size=int(response.headers.get("content-length", "0")),
content_type=response.headers.get("content-type"),
metadata=response.headers,
version_id=response.getheader("x-amz-version-id"),
version_id=response.headers.get("x-amz-version-id"),
)

def remove_object(self, bucket_name, object_name, version_id=None):
Expand Down
2 changes: 1 addition & 1 deletion minio/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def __init__(self, response):
self._etag = findtext(element, "ETag")
if self._etag:
self._etag = self._etag.replace('"', "")
self._version_id = response.getheader("x-amz-version-id")
self._version_id = response.headers.get("x-amz-version-id")
self._http_headers = response.headers

@property
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
],
long_description=readme,
Expand Down

0 comments on commit 3d5f326

Please sign in to comment.