Re: PEP 420: Implicit Namespace Packages

Barry Warsaw <[email protected]>
Newsgroups gmane.comp.python.import
Organization Damn Crazy Followers of the Horn
Message-ID <[email protected]>
On May 03, 2012, at 10:48 AM, Brett Cannon wrote:

>So, to the people not wanting to set __file__, that  (probably) won't fly
>because it has been documented for years that built-in modules are the only
>things that don't define __file__.

Okay, but *why* is this the rule, other than that PEP 302 says it?  IOW, PEP
302 doesn't give much of a rationale for the rule, and I suspect it just
reflected the reality back in 2002.

>Or we at least need to explain to people how to tell the difference in a
>backwards-compatible fashion.

Definitely, and I think that would be fine to include in PEP 420.

>So I would have said that had experience with the stdlib not big me on
>this. In my situation, the trace module was checking file, and if __file__
>didn't contain "<frozen>" or "<doctest" it would try to read it as a path,
>and then error out if it couldn't open the file. Now I updated it to
>startswith('<') and endswith('>'), but I wonder how many people made a
>similar whitelist approach. And while having __file__ to None or
>non-existent will take about the same amount of time to fix, it is less
>prone to silly whitelisting like what the trace module had.

See what I mean about arbitrary and underdocumented? :)

Cheers,
-Barry

_______________________________________________
Import-SIG mailing list
[email protected]
http://mail.python.org/mailman/listinfo/import-sig
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJPoq8uAAoJEBJutWOnSwa/UGoP/jM8xgrvv54RHULYHBdL6aZR
NYvxUhyxFtwfBlVu0nw5OECAXmBfMiNGqmPQauHbHRnM2LxqlttfVpfOzcMxpzVm
tSmaiwPz0xA17l9ntlV3nQgsE2zDUK9vc5IL4ieDzgS09PKM6tOshU3VlkPA4ILz
zXk/dIXu7nXsAUehUC+GwN7l8qgQaURDJsZl9cDAIUWPfD5qeWSpl3A7A8GmL2d1
Oe9Z/4AZ1VOJFeBWLs2CxgpGswlHRNn80dD0/Re4xM7GqJnVzYicYY6RjHnAdRHY
re4RqPow3xC8PAS7gYVoY7YxWYUriqwL7APpJvbaf5uk5A6ylwUSEZSQpSGF1tA7
g2SKUNMQTmd1XoDXlk14bcOx/HHedLSZe8AXuRT7tOYSKiej1keiJWeEKALByWC9
TykRAybjzAyklstTf3+mlOgN6CUVXJM2bq+0iJ4EZFicqmOD5j1hAok41zuqjIMx
7wD2CAgg3XBpXPcsv3xqNgLHMBHaRYgn69RdUhdjkrHHbxlzB2Tg5BljgPW0EhZl
xARF+0JT1zAg9UyF0/5bSIZaXqN8DYeVlpH4lEi7dacfkNVVu6+fP+C+/4YzQ0EL
G2KTpxxFwmPk9c5tzQ5GUaej4DWTe/uU8W0uSNsvO7HARxvlfBsjrOUWDKhKEkl+
RDB1qlsWGW5uFMAFKqC0
=Z5Os
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.