File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,14 +228,13 @@ def _zipinfo(self, filename):
228228
229229 def _quote_filename (self , filename : str ) -> str :
230230 """Return a possibly quoted filename for RECORD file."""
231- # Use csv writer to auto-quote the filename (may contain ",")
231+ filename = filename .lstrip ("/" )
232+ # Some RECORDs like torch have *all* filenames quoted and we must minimize diff.
233+ # Otherwise, we quote only when necessary (e.g. for filenames with commas).
234+ quoting = csv .QUOTE_ALL if self .quote_all_filenames else csv .QUOTE_MINIMAL
232235 with io .StringIO () as buf :
233- csv .writer (buf ).writerow ([filename .lstrip ("/" )])
234- filename = buf .getvalue ().strip ()
235- # Some RECORDs like torch have *all* filenames quoted and we must minimize diff
236- if self .quote_all_filenames and not filename .startswith ('"' ):
237- filename = f'"{ filename } "'
238- return filename
236+ csv .writer (buf , quoting = quoting ).writerow ([filename ])
237+ return buf .getvalue ().strip ()
239238
240239 def add_recordfile (self ) -> str :
241240 """Write RECORD file to the distribution."""
You can’t perform that action at this time.
0 commit comments