Whole file

nedbat/cog

The author described this change as fix: cog restores the current directory. It counts as a record because the check below fails on the code as it stood at 10de5fb71 and passes on 6dbbc3ee1, with nothing else changed between the two runs.

Projectnedbat/cog
Fix saved2025-06-02
Sharing licenceMIT · LICENSE.txt
Change size+3 0

What the code was meant to do, written into the code itself as a save note

fix: cog restores the current directory

The change

413413 file_name_out = file_out
414414 file_out = file_out_to_close = self.open_output_file(file_out)
415415
416+ start_dir = os.getcwd()
417+
416418 try:
417419 file_in = NumberedFileReader(file_in)
418420
592594 file_in_to_close.close()
593595 if file_out_to_close:
594596 file_out_to_close.close()
597+ os.chdir(start_dir)
595598
596599 # A regex for non-empty lines, used by suffixLines.
597600 re_non_empty_lines = re.compile(r"^\s*\S+.*$", re.MULTILINE)

The check that tells the two apart

failpass·cogapp/test_cogapp.py::TestFileHandling::test_change_dir

Check file cogapp/test_cogapp.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it10de5fb7147f5666cae4909dd7f89537380ca78b
Broken version dated2025-06-02
Modulecogapp.cogapp
Units changedCog
Fingerprinta0097efbb99b63bd
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in nedbat/cog