@@ -53,11 +53,11 @@ def parse_test_cases(
5353 while i < len (p ) and p [i ].id != 'case' :
5454 if p [i ].id == 'file' :
5555 # Record an extra file needed for the test case.
56- files .append ((os .path .join (base_path , p [i ].arg ),
56+ files .append ((os .path .join (base_path , p [i ].arg or '' ),
5757 '\n ' .join (p [i ].data )))
5858 elif p [i ].id in ('builtins' , 'builtins_py2' ):
5959 # Use a custom source file for the std module.
60- mpath = os .path .join (os .path .dirname (path ), p [i ].arg )
60+ mpath = os .path .join (os .path .dirname (path ), p [i ].arg or '' )
6161 if p [i ].id == 'builtins' :
6262 fnam = 'builtins.pyi'
6363 else :
@@ -66,15 +66,17 @@ def parse_test_cases(
6666 with open (mpath ) as f :
6767 files .append ((os .path .join (base_path , fnam ), f .read ()))
6868 elif p [i ].id == 'stale' :
69- if p [i ].arg is None :
69+ arg = p [i ].arg
70+ if arg is None :
7071 stale_modules = set ()
7172 else :
72- stale_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
73+ stale_modules = {item .strip () for item in arg .split (',' )}
7374 elif p [i ].id == 'rechecked' :
74- if p [i ].arg is None :
75+ arg = p [i ].arg
76+ if arg is None :
7577 rechecked_modules = set ()
7678 else :
77- rechecked_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
79+ rechecked_modules = {item .strip () for item in arg .split (',' )}
7880 elif p [i ].id == 'out' or p [i ].id == 'out1' :
7981 tcout = p [i ].data
8082 if native_sep and os .path .sep == '\\ ' :
@@ -95,7 +97,9 @@ def parse_test_cases(
9597 # If the set of rechecked modules isn't specified, make it the same as the set of
9698 # modules with a stale public interface.
9799 rechecked_modules = stale_modules
98- if stale_modules is not None and not stale_modules .issubset (rechecked_modules ):
100+ if (stale_modules is not None
101+ and rechecked_modules is not None
102+ and not stale_modules .issubset (rechecked_modules )):
99103 raise ValueError (
100104 'Stale modules must be a subset of rechecked modules ({})' .format (path ))
101105
@@ -225,15 +229,15 @@ class TestItem:
225229 """
226230
227231 id = ''
228- arg = ''
232+ arg = '' # type: Optional[str]
229233
230234 # Text data, array of 8-bit strings
231235 data = None # type: List[str]
232236
233237 file = ''
234238 line = 0 # Line number in file
235239
236- def __init__ (self , id : str , arg : str , data : List [str ], file : str ,
240+ def __init__ (self , id : str , arg : Optional [ str ] , data : List [str ], file : str ,
237241 line : int ) -> None :
238242 self .id = id
239243 self .arg = arg
@@ -248,8 +252,8 @@ def parse_test_data(l: List[str], fnam: str) -> List[TestItem]:
248252 ret = [] # type: List[TestItem]
249253 data = [] # type: List[str]
250254
251- id = None # type: str
252- arg = None # type: str
255+ id = None # type: Optional[ str]
256+ arg = None # type: Optional[ str]
253257
254258 i = 0
255259 i0 = 0
0 commit comments