[issue2051] PYO file permission problem

Eric Snow report at bugs.python.org
Fri Aug 24 19:03:17 CEST 2012


Eric Snow added the comment:

My patch was very similar.  _cache_bytecode() is a good addition.  Good point about the cache, too.

I'm not convinced that source_path is the right thing to add to the API (even just for SourceFileLoader).  I would have thought mode would have been more appropriate:

  def set_data(self, path, data, *, mode=0o666):

Then the "mode = _os.stat(source_path).st_mode" bit would get moved to _cache_bytecode().

My reasoning is that set_data() is useful to write any data relative to the Loader.  The concrete use case in the stdlib is for writing the .pyc files.  Otherwise I'm not certain why the idea of "source_path" should be associated with set_data().  On the other hand, the idea of "mode" likewise may not be univeral enough to enshrine in the API, but I'd think it's more so than source_path.

I was going to ask about backward compatability, but then I realized that SourceFileLoader is new in 3.3 (SourceLoader is new in 3.2).  I'm also wondering why set_data() is not a part of the FileLoader API, but that's a question for another time (and version).  :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2051>
_______________________________________


More information about the Python-bugs-list mailing list