Skip to content

Commit d5825cc

Browse files
committed
Take advantage of the frozenset constant optimization.
1 parent 0d739d7 commit d5825cc

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Lib/_markupbase.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def parse_declaration(self, i):
122122
# this could be handled in a separate doctype parser
123123
if decltype == "doctype":
124124
j = self._parse_doctype_subset(j + 1, i)
125-
elif decltype in ("attlist", "linktype", "link", "element"):
125+
elif decltype in {"attlist", "linktype", "link", "element"}:
126126
# must tolerate []'d groups in a content model in an element declaration
127127
# also in data attribute specifications of attlist declaration
128128
# also link type declaration subsets in linktype declarations
@@ -145,10 +145,10 @@ def parse_marked_section(self, i, report=1):
145145
sectName, j = self._scan_name( i+3, i )
146146
if j < 0:
147147
return j
148-
if sectName in ("temp", "cdata", "ignore", "include", "rcdata"):
148+
if sectName in {"temp", "cdata", "ignore", "include", "rcdata"}:
149149
# look for standard ]]> ending
150150
match= _markedsectionclose.search(rawdata, i+3)
151-
elif sectName in ("if", "else", "endif"):
151+
elif sectName in {"if", "else", "endif"}:
152152
# look for MS Office ]> ending
153153
match= _msmarkedsectionclose.search(rawdata, i+3)
154154
else:
@@ -203,7 +203,7 @@ def _parse_doctype_subset(self, i, declstartpos):
203203
name, j = self._scan_name(j + 2, declstartpos)
204204
if j == -1:
205205
return -1
206-
if name not in ("attlist", "element", "entity", "notation"):
206+
if name not in {"attlist", "element", "entity", "notation"}:
207207
self.updatepos(declstartpos, j + 2)
208208
self.error(
209209
"unknown declaration %r in internal subset" % name)

Lib/ftplib.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def set_pasv(self, val):
171171
def sanitize(self, s):
172172
if s[:5] == 'pass ' or s[:5] == 'PASS ':
173173
i = len(s)
174-
while i > 5 and s[i-1] in '\r\n':
174+
while i > 5 and s[i-1] in {'\r', '\n'}:
175175
i = i-1
176176
s = s[:5] + '*'*(i-5) + s[i:]
177177
return repr(s)
@@ -221,7 +221,7 @@ def getresp(self):
221221
if self.debugging: print('*resp*', self.sanitize(resp))
222222
self.lastresp = resp[:3]
223223
c = resp[:1]
224-
if c in ('1', '2', '3'):
224+
if c in {'1', '2', '3'}:
225225
return resp
226226
if c == '4':
227227
raise error_temp(resp)
@@ -245,7 +245,7 @@ def abort(self):
245245
if self.debugging > 1: print('*put urgent*', self.sanitize(line))
246246
self.sock.sendall(line, MSG_OOB)
247247
resp = self.getmultiline()
248-
if resp[:3] not in ('426', '225', '226'):
248+
if resp[:3] not in {'426', '225', '226'}:
249249
raise error_proto(resp)
250250

251251
def sendcmd(self, cmd):
@@ -375,7 +375,7 @@ def login(self, user = '', passwd = '', acct = ''):
375375
if not user: user = 'anonymous'
376376
if not passwd: passwd = ''
377377
if not acct: acct = ''
378-
if user == 'anonymous' and passwd in ('', '-'):
378+
if user == 'anonymous' and passwd in {'', '-'}:
379379
# If there is no anonymous ftp password specified
380380
# then we'll just use anonymous@
381381
# We don't send any other thing because:
@@ -534,7 +534,7 @@ def rename(self, fromname, toname):
534534
def delete(self, filename):
535535
'''Delete a file.'''
536536
resp = self.sendcmd('DELE ' + filename)
537-
if resp[:3] in ('250', '200'):
537+
if resp[:3] in {'250', '200'}:
538538
return resp
539539
else:
540540
raise error_reply(resp)
@@ -897,9 +897,9 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
897897
# transfer request.
898898
# So: STOR before RETR, because here the target is a "user".
899899
treply = target.sendcmd('STOR ' + targetname)
900-
if treply[:3] not in ('125', '150'): raise error_proto # RFC 959
900+
if treply[:3] not in {'125', '150'}: raise error_proto # RFC 959
901901
sreply = source.sendcmd('RETR ' + sourcename)
902-
if sreply[:3] not in ('125', '150'): raise error_proto # RFC 959
902+
if sreply[:3] not in {'125', '150'}: raise error_proto # RFC 959
903903
source.voidresp()
904904
target.voidresp()
905905

0 commit comments

Comments
 (0)