New submission from Christian Heimes:

I suggest that posixpath.c:_fd_converter() should  PyObject_AsFileDescriptor() 
to convert a Python object to a fd integer. With PyObject_AsFileDescriptor() 
functions such as os.chmod() can be called with an opened file as first 
argument:

Now:

  with open("somefile") as f:
     os.chmod(f.fileno(), 0o644)

With PyObject_AsFileDescriptor():

    with open("somefile") as f:
     os.chmod(f, 0o644)

_fd_converter() also has more elaborate overflow checks. These checks should be 
added to PyObject_AsFileDescriptor(), too.

----------
messages: 191563
nosy: christian.heimes
priority: normal
severity: normal
stage: needs patch
status: open
title: posixpath.c:_fd_converter() should use PyObject_AsFileDescriptor()
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18276>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to