WIP: use assignment expression in stdlib (combined PR) #8122

Closed
wants to merge 6 commits into
from
View
@@ -49,8 +49,7 @@ def updatepos(self, i, j):
if i >= j:
return j
rawdata = self.rawdata
- nlines = rawdata.count("\n", i, j)
- if nlines:
+ if (nlines := rawdata.count("\n", i, j)):
self.lineno = self.lineno + nlines
pos = rawdata.rindex("\n", i, j) # Should not fail
self.offset = j-(pos+1)
@@ -291,8 +290,7 @@ def _parse_doctype_attlist(self, i, declstartpos):
if not c:
return -1
if c in "'\"":
- m = _declstringlit_match(rawdata, j)
- if m:
+ if (m := _declstringlit_match(rawdata, j)):
j = m.end()
else:
return -1
@@ -359,8 +357,7 @@ def _parse_doctype_entity(self, i, declstartpos):
if not c:
return -1
if c in "'\"":
- m = _declstringlit_match(rawdata, j)
- if m:
+ if (m := _declstringlit_match(rawdata, j)):
j = m.end()
else:
return -1 # incomplete
@@ -378,8 +375,7 @@ def _scan_name(self, i, declstartpos):
n = len(rawdata)
if i == n:
return None, -1
- m = _declname_match(rawdata, i)
- if m:
+ if (m := _declname_match(rawdata, i)):
s = m.group()
name = s.strip()
if (i + len(s)) == n:
View
@@ -287,8 +287,7 @@ def _check_for_unavailable_sdk(_config_vars):
# to /usr and /System/Library by either a standalone CLT
# package or the CLT component within Xcode.
cflags = _config_vars.get('CFLAGS', '')
- m = re.search(r'-isysroot\s+(\S+)', cflags)
- if m is not None:
+ if (m := re.search(r'-isysroot\s+(\S+)', cflags)) is not None:
sdk = m.group(1)
if not os.path.exists(sdk):
for cv in _UNIVERSAL_CONFIG_VARS:
Oops, something went wrong.