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
| 413 | 413 | file_name_out = file_out | |
| 414 | 414 | file_out = file_out_to_close = self.open_output_file(file_out) | |
| 415 | 415 | ||
| 416 | + | start_dir = os.getcwd() | |
| 417 | + | ||
| 416 | 418 | try: | |
| 417 | 419 | file_in = NumberedFileReader(file_in) | |
| 418 | 420 | ||
| ⋯ | |||
| 592 | 594 | file_in_to_close.close() | |
| 593 | 595 | if file_out_to_close: | |
| 594 | 596 | file_out_to_close.close() | |
| 597 | + | os.chdir(start_dir) | |
| 595 | 598 | ||
| 596 | 599 | # A regex for non-empty lines, used by suffixLines. | |
| 597 | 600 | re_non_empty_lines = re.compile(r"^\s*\S+.*$", re.MULTILINE) | |
The check that tells the two apart
fail→pass·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
- 2025-09-21feat: --check-fail-msg