@@ -3323,6 +3323,9 @@ cat_and_normalize_import(/*utf-8*/ char const *__restrict pathname, size_t pathn
33233323 /* Trim "pathname_size" to get rid of everything after the last slash. */
33243324 while (pathname_size >= 1 && !DeeSystem_IsSep (pathname [pathname_size - 1 ]))
33253325 -- pathname_size ;
3326+ /* Special case: if the context path somehow becomes empty here, then it mustn't count as the FS root! */
3327+ if unlikely (!pathname_size )
3328+ goto make_absolute_path ;
33263329 while (pathname_size >= 1 && DeeSystem_IsSep (pathname [pathname_size - 1 ]))
33273330 -- pathname_size ;
33283331 }
@@ -3334,6 +3337,7 @@ cat_and_normalize_import(/*utf-8*/ char const *__restrict pathname, size_t pathn
33343337 if (DeeSystem_IsNormalAndAbsolute (pathname , pathname_size ) || !pathname_size ) {
33353338 pathname_ob = NULL ;
33363339 } else {
3340+ make_absolute_path :
33373341 if (pathname_ob && (flags & DeeModule_IMPORT_F_CTXDIR )) {
33383342 pathname_ob = (DeeStringObject * )DeeSystem_MakeNormalAndAbsolute (Dee_AsObject (pathname_ob ));
33393343 } else {
@@ -3454,7 +3458,7 @@ cat_and_normalize_import(/*utf-8*/ char const *__restrict pathname, size_t pathn
34543458 /* Write new drive-string */
34553459 if unlikely (segment_len != 1 ) {
34563460 DeeError_Throwf (& DeeError_ValueError ,
3457- "Length of drive name %$q is not 1 character in \".%#$q\" relative to" ,
3461+ "Length of drive name %$q is not 1 character in \".%#$q\" relative to %$q " ,
34583462 segment_len , import_str ,
34593463 (size_t )(import_str_end - import_str_orig ),
34603464 import_str_orig , pathname_size , pathname );
@@ -3736,9 +3740,11 @@ do_DeeModule_OpenEx(/*utf-8*/ char const *__restrict import_str, size_t import_s
37363740 /* Trim "context_absname_size" to get rid of everything after the last slash. */
37373741 while (context_absname_size >= 1 && !DeeSystem_IsSep (context_absname [context_absname_size - 1 ]))
37383742 -- context_absname_size ;
3743+ /* Special case: if the context path somehow becomes empty here, then it mustn't count as the FS root! */
3744+ if likely (context_absname_size )
3745+ flags |= DeeModule_IMPORT_F_CTXDIR ;
37393746 while (context_absname_size >= 1 && DeeSystem_IsSep (context_absname [context_absname_size - 1 ]))
37403747 -- context_absname_size ;
3741- flags |= DeeModule_IMPORT_F_CTXDIR ;
37423748 }
37433749 ++ import_str ; /* Skip leading "." */
37443750 -- import_str_size ;
0 commit comments