@@ -229,46 +229,48 @@ def __validate_universal_filename(self, unicode_filename: str) -> None:
229229 if match :
230230 raise InvalidCharError (
231231 INVALID_CHAR_ERR_MSG_TMPL .format (
232- invalid = findall_to_str (match ), value = repr ( unicode_filename )
232+ invalid = findall_to_str (match ),
233233 ),
234234 platform = Platform .UNIVERSAL ,
235+ value = unicode_filename ,
235236 )
236237
237238 def __validate_win_filename (self , unicode_filename : str ) -> None :
238239 match = _RE_INVALID_WIN_FILENAME .findall (unicode_filename )
239240 if match :
240241 raise InvalidCharError (
241242 INVALID_CHAR_ERR_MSG_TMPL .format (
242- invalid = findall_to_str (match ), value = repr ( unicode_filename )
243+ invalid = findall_to_str (match ),
243244 ),
244245 platform = Platform .WINDOWS ,
246+ value = unicode_filename ,
245247 )
246248
247249 if unicode_filename in ("." , ".." ):
248250 return
249251
250252 KB2829981_err_tmpl = "{}. Refer: https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/file-folder-name-whitespace-characters" # noqa: E501
253+ err_kwargs = {
254+ ErrorAttrKey .PLATFORM : Platform .WINDOWS ,
255+ ErrorAttrKey .VALUE : unicode_filename ,
256+ }
251257
252258 if unicode_filename [- 1 ] in (" " , "." ):
253259 raise InvalidCharError (
254- INVALID_CHAR_ERR_MSG_TMPL .format (
255- invalid = re .escape (unicode_filename [- 1 ]), value = repr (unicode_filename )
256- ),
257- platform = Platform .WINDOWS ,
260+ INVALID_CHAR_ERR_MSG_TMPL .format (invalid = re .escape (unicode_filename [- 1 ])),
258261 description = KB2829981_err_tmpl .format (
259262 "Do not end a file or directory name with a space or a period"
260263 ),
264+ ** err_kwargs ,
261265 )
262266
263267 if unicode_filename [0 ] in (" " ):
264268 raise InvalidCharError (
265- INVALID_CHAR_ERR_MSG_TMPL .format (
266- invalid = re .escape (unicode_filename [0 ]), value = repr (unicode_filename )
267- ),
268- platform = Platform .WINDOWS ,
269+ INVALID_CHAR_ERR_MSG_TMPL .format (invalid = re .escape (unicode_filename [0 ])),
269270 description = KB2829981_err_tmpl .format (
270271 "Do not start a file or directory name with a space"
271272 ),
273+ ** err_kwargs ,
272274 )
273275
274276
0 commit comments