From e5c550f200c8c1b0e42842dc57f39c9dd4392349 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 8 Jun 2026 14:30:51 -0400 Subject: [PATCH] Avoird warning on nodeconsole -tv exit with newer python --- confluent_client/bin/nodeconsole | 6 +++--- confluent_client/confluent/vnc.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 5464a870..b8ae0b66 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -631,7 +631,7 @@ def draw_text(text, width, height): nd.rectangle((0, 0, nerr.width - 1, nerr.height -1), outline='white') outfile = io.BytesIO() nerr.save(outfile, format='PNG') - draw_image(outfile.getbuffer(), width, height, doscale=False) + draw_image(outfile.getvalue(), width, height, doscale=False) else: sys.stdout.write(text) cursor_left(len(text)) @@ -666,7 +666,7 @@ def draw_image(bindata, width, height, doscale=True): nimg.paste(img, box=(2, 2)) outfile = io.BytesIO() nimg.save(outfile, format='PNG') - bindata = outfile.getbuffer() + bindata = outfile.getvalue() if imageformat == 'sixel': sixel_draw(bindata) elif imageformat == 'iterm': @@ -1033,7 +1033,7 @@ async def do_vnc(node, url): # Save as PNG using PIL/pillow outfile = io.BytesIO() image.save(outfile, format='PNG') - imgdata = outfile.getbuffer() + imgdata = outfile.getvalue() if imgdata: draw_node(node, imgdata, '', '', cwidth, cheight) else: diff --git a/confluent_client/confluent/vnc.py b/confluent_client/confluent/vnc.py index 8d12a24d..c8d04d74 100644 --- a/confluent_client/confluent/vnc.py +++ b/confluent_client/confluent/vnc.py @@ -256,9 +256,10 @@ class VNCClient: raise NotImplementedError(f'tight encoding with comptype {comptype} not implemented') compressed_data_length = await self._read_tight_length() compressed_data = await self.reader.readexactly(compressed_data_length) - jpgimg = io.BytesIO(compressed_data) - img = Image.open(jpgimg) - self.framebuffer.paste(img, (x, y)) + with io.BytesIO(compressed_data) as jpgimg: + img = Image.open(jpgimg) + img.load() + self.framebuffer.paste(img, (x, y)) else: raise Exception(f'Unsupported encoding type: {encoding_type}')