Skip to content

Commit 1f61818

Browse files
committed
Fix PendingDeprecationWarning in numeric_convert_digits
1 parent 2f2df7a commit 1f61818

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

postgresql/types/io/stdlib_decimal.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,17 @@ def numeric_pack(x,
130130

131131
def numeric_convert_digits(d, str = str, int = int):
132132
i = iter(d)
133-
for x in str(next(i)):
134-
# no leading zeros
135-
yield int(x)
136-
# leading digit should not include zeros
137-
for y in i:
138-
for x in str(y).rjust(4, '0'):
133+
try:
134+
for x in str(next(i)):
135+
# no leading zeros
139136
yield int(x)
137+
# leading digit should not include zeros
138+
for y in i:
139+
for x in str(y).rjust(4, '0'):
140+
yield int(x)
141+
except StopIteration:
142+
# Python 3.5+ does not like generators raising StopIteration
143+
return
140144

141145
numeric_signs = {
142146
numeric_negative : 1,

0 commit comments

Comments
 (0)