diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index be6a7228..abd387cf 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -38,6 +38,7 @@ jobs: - {python-version: '3.10', os: windows-2019} - {python-version: '3.11', os: windows-2019} - {python-version: '3.12', os: windows-2019} + - {python-version: '3.13', os: windows-2019} steps: - uses: actions/checkout@v2 @@ -78,6 +79,9 @@ jobs: # - {python-version: '3.8', os: windows-2019} # - {python-version: '3.9', os: windows-2019} # - {python-version: '3.10', os: windows-2019} + # - {python-version: '3.11', os: windows-2019} + # - {python-version: '3.12', os: windows-2019} + # - {python-version: '3.13', os: windows-2019} steps: - uses: actions/checkout@v2 @@ -114,6 +118,9 @@ jobs: # - {python-version: '3.8', os: windows-2019} # - {python-version: '3.9', os: windows-2019} # - {python-version: '3.10', os: windows-2019} + # - {python-version: '3.11', os: windows-2019} + # - {python-version: '3.12', os: windows-2019} + # - {python-version: '3.13', os: windows-2019} steps: - uses: actions/checkout@v2 @@ -162,6 +169,9 @@ jobs: # - {python-version: '3.8', os: windows-2019} # - {python-version: '3.9', os: windows-2019} # - {python-version: '3.10', os: windows-2019} + # - {python-version: '3.11', os: windows-2019} + # - {python-version: '3.12', os: windows-2019} + # - {python-version: '3.13', os: windows-2019} steps: - uses: actions/checkout@v2 diff --git a/smart_open/azure.py b/smart_open/azure.py index 1c991f05..ef072329 100644 --- a/smart_open/azure.py +++ b/smart_open/azure.py @@ -394,19 +394,17 @@ def __init__( ): self._is_closed = False self._container_name = container - - self._blob = _get_blob_client(client, container, blob) self._blob_kwargs = blob_kwargs or {} - # type: azure.storage.blob.BlobClient - self._min_part_size = min_part_size - self._total_size = 0 self._total_parts = 0 self._bytes_uploaded = 0 self._current_part = io.BytesIO() self._block_list = [] + # type: azure.storage.blob.BlobClient + self._blob = _get_blob_client(client, container, blob) + # # This member is part of the io.BufferedIOBase interface. # @@ -535,6 +533,7 @@ def __repr__(self): return "%s(container=%r, blob=%r, min_part_size=%r)" % ( self.__class__.__name__, self._container_name, - self._blob.blob_name, + # python 3.13 calls __repr__ during error handling of exception in __init__ + self._blob.blob_name if hasattr(self, "_blob") else "failed_init", self._min_part_size ) diff --git a/smart_open/hdfs.py b/smart_open/hdfs.py index a247d3e3..083e793f 100644 --- a/smart_open/hdfs.py +++ b/smart_open/hdfs.py @@ -78,12 +78,18 @@ def __init__(self, uri): # self.raw = None + @property + def closed(self): + return self._sub is None + # # Override some methods from io.IOBase. # def close(self): """Flush and close this stream.""" logger.debug("close: called") + if self.closed: + return self._sub.terminate() self._sub = None @@ -135,10 +141,17 @@ def __init__(self, uri): # self.raw = None + @property + def closed(self): + return self._sub is None + def close(self): + if self.closed: + return self.flush() self._sub.stdin.close() self._sub.wait() + self._sub = None def flush(self): self._sub.stdin.flush()