Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-29176 Use tmpfile() in curses module #235

Merged
merged 1 commit into from
Mar 2, 2017

Conversation

tiran
Copy link
Member

@tiran tiran commented Feb 22, 2017

The curses module used mkstemp() + fopen() to create a temporary file in
/tmp. The /tmp directory does not exist on Android. The tmpfile()
function simplifies the task a lot. It creates a temporary file in a
correct directory, takes care of cleanup and returns FILE*.

tmpfile is supported on all platforms (C89, POSIX 2001, Android,
Windows).

https://bugs.python.org/issue29176

Signed-off-by: Christian Heimes christian@python.org

@tiran tiran requested a review from vstinner February 22, 2017 10:37
@tiran tiran changed the title Issue #29176: Use tmpfile() in curses module bpo-29176 Use tmpfile() in curses module Feb 22, 2017
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed your PR and wrote exactly the same :-)

#237

@@ -2330,9 +2314,6 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
error:
if (fp != NULL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if can now be removed

@@ -2278,8 +2267,6 @@ PyCurses_UngetMouse(PyObject *self, PyObject *args)
static PyObject *
PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
{
char fn[100];
int fd = -1;
FILE *fp = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= NULL can be removed

Same remarks for the other function.

@tiran tiran force-pushed the bpo29176_curses_tmpfile branch 2 times, most recently from 7b11476 to a16b7b5 Compare February 22, 2017 11:12
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed "Issue #29176: Use tmpfile() in curses module " in the commit message.

Please replace "Issue #29176" with "bpo-29176".

Moreover, I don't think that the bugs.python.org URL is needed in the commit message.

@@ -2314,7 +2296,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
datalen = PyBytes_GET_SIZE(data);
if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
Py_DECREF(data);
PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
PyErr_SetFromErrno(PyExc_IOError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be OSError.

@serhiy-storchaka
Copy link
Member

I think an entry in Misc/NEWS is required.

@vstinner
Copy link
Member

I think an entry in Misc/NEWS is required.

From an user point of view, there is no change, except of Android support.

Last days, I'm trying to avoid touching Misc/NEWS, because it's even more a mess because of how pull requests work :-(

@tiran tiran force-pushed the bpo29176_curses_tmpfile branch from 22fdd41 to 0e00de8 Compare February 22, 2017 12:56
The curses module used mkstemp() + fopen() to create a temporary file in
/tmp. The /tmp directory does not exist on Android. The tmpfile()
function simplifies the task a lot. It creates a temporary file in a
correct directory, takes care of cleanup and returns FILE*.

tmpfile is supported on all platforms (C89, POSIX 2001, Android,
Windows).

Signed-off-by: Christian Heimes <christian@python.org>
@vstinner vstinner merged commit 2b221b7 into python:master Mar 2, 2017
yan12125 pushed a commit to yan12125/python3-android that referenced this pull request Mar 2, 2017
akruis pushed a commit to akruis/cpython that referenced this pull request Apr 20, 2021
…#188

This commit fixes an assert statement, that could fail since python#188.
No functional change.

(cherry picked from commit 5595eec)
akruis pushed a commit to akruis/cpython that referenced this pull request May 27, 2021
…#188

This commit fixes an assert statement, that could fail since python#188.
No functional change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants