@@ -363,13 +363,16 @@ def get_arg_parser() -> optparse.OptionParser:
363363
364364
365365def constant_replace (
366- fn : str , updated_constants : str , comment_start : str = "/*" , comment_end : str = "*/"
366+ filename : str ,
367+ updated_constants : str ,
368+ comment_start : str = "/*" ,
369+ comment_end : str = "*/" ,
367370) -> None :
368371 """Inserts in between --start constant-- and --end constant-- in a file"""
369372 start_tag = comment_start + "--start constants--" + comment_end
370373 end_tag = comment_start + "--end constants--" + comment_end
371- with open (fn , encoding = "ascii" ) as infile , open (
372- fn + ".new" , "w" , encoding = "ascii"
374+ with open (filename , encoding = "ascii" ) as infile , open (
375+ filename + ".new" , "w" , encoding = "ascii"
373376 ) as outfile :
374377 found_constants = False
375378 waiting_for_end = False
@@ -387,12 +390,14 @@ def constant_replace(
387390 else :
388391 outfile .write (line )
389392 if not found_constants :
390- error (f"Constant section delimiters not found: { fn } " )
391- os .rename (fn + ".new" , fn )
393+ error (f"Constant section delimiters not found: { filename } " )
394+ os .rename (filename + ".new" , filename )
392395
393396
394- def tweak_patchlevel (tag : Tag , done : bool = False ) -> None :
395- print ("Updating Include/patchlevel.h..." , end = " " )
397+ def tweak_patchlevel (
398+ tag : Tag , filename : str = "Include/patchlevel.h" , done : bool = False
399+ ) -> None :
400+ print (f"Updating { filename } ..." , end = " " )
396401 template = '''
397402#define PY_MAJOR_VERSION\t {tag.major}
398403#define PY_MINOR_VERSION\t {tag.minor}
@@ -414,7 +419,7 @@ def tweak_patchlevel(tag: Tag, done: bool = False) -> None:
414419 )
415420 if tag .as_tuple () >= (3 , 7 , 0 , "a" , 3 ):
416421 new_constants = new_constants .expandtabs ()
417- constant_replace ("Include/patchlevel.h" , new_constants )
422+ constant_replace (filename , new_constants )
418423 print ("done" )
419424
420425
@@ -440,22 +445,22 @@ def bump(tag: Tag) -> None:
440445 ".github/ISSUE_TEMPLATE/crash.yml" ,
441446 ]
442447 print ("\n Manual editing time..." )
443- for fn in other_files :
444- if os .path .exists (fn ):
445- print (f"Edit { fn } " )
446- manual_edit (fn )
448+ for filename in other_files :
449+ if os .path .exists (filename ):
450+ print (f"Edit { filename } " )
451+ manual_edit (filename )
447452 else :
448- print (f"Skipping { fn } " )
453+ print (f"Skipping { filename } " )
449454
450455 print ("Bumped revision" )
451456 if extra_work :
452457 print ("configure.ac has changed; re-run autotools!" )
453458 print ("Please commit and use --tag" )
454459
455460
456- def manual_edit (fn : str ) -> None :
461+ def manual_edit (filename : str ) -> None :
457462 editor = os .environ ["EDITOR" ].split ()
458- run_cmd ([* editor , fn ])
463+ run_cmd ([* editor , filename ])
459464
460465
461466@contextmanager
0 commit comments