!15 Decoding in slab funcs, replacing 1 with True in while

From: @XIE-JING-2022 
Reviewed-by: @yangzhao_kl 
Signed-off-by: @yangzhao_kl
This commit is contained in:
openeuler-ci-bot 2024-05-13 10:41:25 +00:00 committed by Gitee
commit 72babb1bd9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,57 @@
From f5e4d4f39cee3d3489242387409af0de917fb84c Mon Sep 17 00:00:00 2001
From: Sean Reifschneider <sean@realgo.com>
Date: Sat, 15 Apr 2023 14:45:18 -0600
Subject: [PATCH] Decoding in slab funcs, replacing "1" with "True" in while.
The slab functions needed a decode (as noted in
https://github.com/linsomniac/python-memcached/pull/175), adapted that
patch. Also converted "while 1" to "while True" while I was in there.
---
memcache.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/memcache.py b/memcache.py
index 8c38e56..1aa9987 100644
--- a/memcache.py
+++ b/memcache.py
@@ -323,11 +323,13 @@ class Client(threading.local):
serverData = {}
data.append((name, serverData))
readline = s.readline
- while 1:
+ while True:
line = readline()
- if not line or line.decode('ascii').strip() == 'END':
+ if line:
+ line = line.decode('ascii')
+ if not line or line.strip() == 'END':
break
- stats = line.decode('ascii').split(' ', 2)
+ stats = line.split(' ', 2)
serverData[stats[1]] = stats[2]
return data
@@ -347,8 +349,10 @@ class Client(threading.local):
data.append((name, serverData))
s.send_cmd('stats slabs')
readline = s.readline
- while 1:
+ while True:
line = readline()
+ if line:
+ line = line.decode('ascii')
if not line or line.strip() == 'END':
break
item = line.split(' ', 2)
@@ -378,7 +382,7 @@ class Client(threading.local):
data.append((name, serverData))
s.send_cmd('stats items')
readline = s.readline
- while 1:
+ while True:
line = readline()
if not line or line.strip() == 'END':
break
--
2.43.0

View File

@ -1,12 +1,13 @@
Name: python-memcached
Version: 1.59
Release: 2
Release: 3
Summary: A Python memcached client library
License: Python
URL: https://github.com/linsomniac/python-memcached
Source0: https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
BuildArch: noarch
Patch0: backport-Decoding-in-slab-funcs-replacing-1-with-True-in-while.patch
%bcond_without python3
%bcond_without check
@ -43,7 +44,7 @@ Summary: %{summary}
%{python3_sitelib}/python_memcached-%{version}-py*.egg-info/
%prep
%autosetup -n %{name}-%{version}
%autosetup -n %{name}-%{version} -p1
%build
@ -56,6 +57,9 @@ Summary: %{summary}
%changelog
* Fri May 10 2024 xiejing <xiejing@kylinos.cn> - 1.59-3
- Decoding in slab funcs, replacing "1" with "True" in while
* Mon Jan 10 2022 yanglongkang <yanglongkang@huawei.com> - 1.59-2
- delete python-nose Buildrequires