Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6cb5ba1

Browse files
committed
Fix compiler warnings
This fixes all remaining compiler warnings that GCC 10 reports. Reshuffling in `scram.pyx` is due to the weirdness in Cython's handling of string iteration.
1 parent 69bcdf5 commit 6cb5ba1

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

‎asyncpg/protocol/record/recordobj.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,11 @@ record_length(ApgRecordObject *o)
132132
static Py_hash_t
133133
record_hash(ApgRecordObject *v)
134134
{
135-
Py_ssize_t i;
136135
Py_uhash_t acc = _PyHASH_XXPRIME_5;
137-
Py_ssize_tlen = Py_SIZE(v);
136+
size_ti, len = (size_t)Py_SIZE(v);
138137
PyObject **els = v->ob_item;
139138
for (i = 0; i < len; i++) {
140-
Py_uhash_t lane = PyObject_Hash(els[i]);
139+
Py_uhash_t lane = (Py_uhash_t)PyObject_Hash(els[i]);
141140
if (lane == (Py_uhash_t)-1) {
142141
return -1;
143142
}

‎asyncpg/protocol/scram.pyx‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ cdef class SCRAMAuthentication:
291291
# Table C.1.2 -- non-ASCII spaces
292292
# Table B.1 -- "Commonly mapped to nothing"
293293
normalized_password = u"".join(
294-
[' ' if stringprep.in_table_c12(c) else c
295-
for c in normalized_password if not stringprep.in_table_b1(c)])
294+
' ' if stringprep.in_table_c12(c) else c
295+
for c in tuple(normalized_password) if not stringprep.in_table_b1(c)
296+
)
296297

297298
# If at this point the password is empty, PostgreSQL uses the original
298299
# password
@@ -307,17 +308,20 @@ cdef class SCRAMAuthentication:
307308
if not normalized_password:
308309
return original_password
309310

311+
normalized_password_tuple = tuple(normalized_password)
312+
310313
# Step 3 of SASLPrep: Prohobited characters. If PostgreSQL detects any
311314
# of the prohibited characters in SASLPrep, it will use the original
312315
# password
313316
# We also include "unassigned code points" in the prohibited character
314317
# category as PostgreSQL does the same
315-
for c in normalized_password:
316-
if any([in_prohibited_table(c) for in_prohibited_table in
317-
self.SASLPREP_PROHIBITED]):
318+
for c in normalized_password_tuple:
319+
if any(
320+
in_prohibited_table(c)
321+
for in_prohibited_table in self.SASLPREP_PROHIBITED
322+
):
318323
return original_password
319324

320-
321325
# Step 4 of SASLPrep: Bi-directional characters. PostgreSQL follows the
322326
# rules for bi-directional characters laid on in RFC3454 Sec. 6 which
323327
# are:
@@ -327,15 +331,17 @@ cdef class SCRAMAuthentication:
327331
# 3. If the string contains any RandALCat character, an RandALCat
328332
# character must be the first and last character of the string
329333
# RandALCat characters are found in table D.1, whereas LCat are in D.2
330-
if any([stringprep.in_table_d1(c) for c in normalized_password]):
334+
if any(stringprep.in_table_d1(c) for c in normalized_password_tuple):
331335
# if the first character or the last character are not in D.1,
332336
# return the original password
333-
if not (stringprep.in_table_d1(normalized_password[0]) and
334-
stringprep.in_table_d1(normalized_password[-1])):
337+
if not (stringprep.in_table_d1(normalized_password_tuple[0]) and
338+
stringprep.in_table_d1(normalized_password_tuple[-1])):
335339
return original_password
336340

337341
# if any characters are in D.2, use the original password
338-
if any([stringprep.in_table_d2(c) for c in normalized_password]):
342+
if any(
343+
stringprep.in_table_d2(c) for c in normalized_password_tuple
344+
):
339345
return original_password
340346

341347
# return the normalized password

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /