Setuptools: Spaces in file names are looking for troubles

Created on 21 Mar 2019  Â·  5Comments  Â·  Source: pypa/setuptools

What is the purpose of naming a file script (dev).tmpl? Oh, I see, to prove that Setuptools can support funny file names. Great.

I read bug #134, and especially jaraco's comment on Jan 3, 2016. There is a third principle, besides least astonishment and robustness, and it is the readability. As an invisible character, a space cannot be distinguished from other invisible characters, such as tab and a plethora of UTF-8 space variations. How easily can you tell script (dev).tmpl from script (dev).tmpl? (Hint: one of them has multiple spaces, but you need to inspect HTML code to tell). An accidental misspell can hardly catch your eyeballs.

Certainly, script-dev.tmpl would have looked too simple, eh? So here's a fourth principle, KISS.

The URI syntax (rfc3986) provides for a set of unreserved characters (ALPHA / DIGIT / "-" / "." / "_" / "~"), whereby the rest, including spaces, has to be percent-encoded. What doddering fools!

Email syntax allows for spaces in the local-part of an email address, provided that spaces are quoted. However, SMTP wording is "a host that expects to receive mail SHOULD avoid [them]".

Some SQL implementation provide for spaces in variable names. I'd guess you're looking forward for the next version of Python to support a similar feature too, possibly varying quotation styles from a version to the next. Real progress, eh?

I hope I didn't annoy you by re-opening a bug that you consider a feature. I guess I won't be the last one, until you fix it.

Best
Ale

question

All 5 comments

Sorry, but spaces are valid in filenames and systems and tools should support them.

By the way, I agree with you about "looking for trouble". I think that's a mostly fair characterization. And given that using spaces has shown little trouble over the years, it's now a strength.

Have you considered renaming the file to

script\x00 (🥴`'); DROP TABLE packages;--.tmpl‮

? I think, that will significantly increase the "strength" of this file.

I still have to deal with the Solaris Package Manager that lacks support for filenames containing whitespaces, see also #134. The workaround is to replace whitespaces in all filenames with underscores and move them back to their original filename in a so called postinstall script during install time. It's doable but it's ugly.

While I totally aggree that "systems and tools should support them", there is still systems/tools out there that don't. Solaris should be fully supported by python3 imho, including their (in deed questionable) package mgmt.

Have you considered renaming the file to...

Point taken. I do think 'spaces to separate words' is a long held convention that's been eschewed by the programmer community mainly because of practical concerns about reliably lexing names. In the space of filenames, however, support for spaces should be supported.

I have gone out of my way in other places to use emoji in commit messages and non-ascii in format strings to push the envelope and actually leverage Unicode in places where you may not have expected it.

I do recognize this approach causes some consternation in systems that make undue assumptions about character spaces, but these are assumptions we want to push against rather than capitulate to the lowest common denominator.

Thank you M0WA and others for the modest effort you must apply to help retain this behavior.

Was this page helpful?
0 / 5 - 0 ratings