Skip to content

Commit 9702c57

Browse files
committed
Backport PR #1341 on 0.6.x (Make format_path behave the same for absolute paths with and
without escape=True)
1 parent 07aff67 commit 9702c57

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nbgrader/coursedir.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,12 @@ def format_path(self, nbgrader_step, student_id, assignment_id, escape=False):
306306
)
307307

308308
if escape:
309-
base = re.escape(self.root)
310309
structure = [x.format(**kwargs) for x in full_split(self.directory_structure)]
311-
path = re.escape(os.path.sep).join([base] + structure)
310+
if len(structure) == 0 or not structure[0].startswith(os.sep):
311+
base = [re.escape(self.root)]
312+
else:
313+
base = []
314+
path = re.escape(os.path.sep).join(base + structure)
312315
else:
313316
path = os.path.join(self.root, self.directory_structure).format(**kwargs)
314317

0 commit comments

Comments
 (0)