Whole file

jupyter/jupyter-packaging

The author described this change as Fix is_stale for file paths. It counts as a record because the check below fails on the code as it stood at ffea6a0db and passes on 4ccb7b7ac, with nothing else changed between the two runs.

Fix saved2017-04-20
Sharing licenceBSD-3-Clause · LICENSE
Change size+10 1

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

Fix is_stale for file paths

The change

128128 """
129129 if not os.path.exists(target):
130130 return True
131- target_mtime = recursive_mtime(target)
131+ target_mtime = recursive_mtime(target) or 0
132132 return compare_recursive_mtime(source, cutoff=target_mtime)
133133
134134
179179 E.g. if newest=True, and a file in path is newer than the cutoff, it will
180180 return True.
181181 """
182+ if os.path.isfile(path):
183+ mt = mtime(path)
184+ if newest:
185+ if mt > cutoff:
186+ return True
187+ elif mt < cutoff:
188+ return True
182189 for dirname, _, filenames in os.walk(path, topdown=False):
183190 for filename in filenames:
184191 mt = mtime(pjoin(dirname, filename))
192199
193200 def recursive_mtime(path, newest=True):
194201 """Gets the newest/oldest mtime for all files in a directory."""
202+ if os.path.isfile(path):
203+ return mtime(path)
195204 current_extreme = None
196205 for dirname, _, filenames in os.walk(path, topdown=False):
197206 for filename in filenames:

The check that tells the two apart

failpass·tests/test_is_stale.py::test_file_vs_dir

Check file tests/test_is_stale.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 itffea6a0dbfd6d8e77fbcb5c436a0323d92d0e8ed
Broken version dated2017-04-19
Modulejupyter_packaging.setupbase
Units changedcompare_recursive_mtime, is_stale, recursive_mtime
Fingerprint22381053e0fae523
Checked2026-08-18 by goldset/0.1

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