Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e58962a

Browse files
committed
Fixed the first two bugs in the new file dialogs (found by Just):
- AskFileForSave didn't work for string return values - filterProc didn't work.
1 parent b2a5772 commit e58962a

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

Lib/plat-mac/EasyDialogs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import Carbon.File
3131
import macfs
3232
import macresource
33+
import os
3334

3435
_initialized = 0
3536

@@ -660,7 +661,7 @@ def AskFileForSave(**args):
660661
# This is gross, and probably incorrect too
661662
vrefnum, dirid, name = rr.selection[0].as_tuple()
662663
pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
663-
pardir_fsr = Carbon.File.FSRef(fss)
664+
pardir_fsr = Carbon.File.FSRef(pardir_fss)
664665
pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8
665666
name_utf8 = unicode(name, 'macroman').encode('utf8')
666667
fullpath = os.path.join(pardir_path, name_utf8)

Mac/Modules/Nav.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ my_eventProc(NavEventCallbackMessage callBackSelector,
5656

5757
if (!dict) return;
5858
if ( (pyfunc = PyDict_GetItemString(dict, "eventProc")) == NULL ) {
59-
PyErr_Clear();
59+
PyErr_Print();
6060
return;
6161
}
6262
if ( pyfunc == Py_None ) {
@@ -74,8 +74,8 @@ my_eventProc(NavEventCallbackMessage callBackSelector,
7474
if ( rv )
7575
Py_DECREF(rv);
7676
else {
77-
fprintf(stderr, "Nav: exception in eventProc callback\n");
78-
PyErr_Clear();
77+
PySys_WriteStderr("Nav: exception in eventProc callback\n");
78+
PyErr_Print();
7979
}
8080
}
8181

@@ -90,16 +90,16 @@ my_previewProc(NavCBRecPtr callBackParms,
9090

9191
if (!dict) return false;
9292
if ( (pyfunc = PyDict_GetItemString(dict, "previewProc")) == NULL ) {
93-
PyErr_Clear();
93+
PyErr_Print();
9494
return false;
9595
}
9696
rv = PyObject_CallFunction(pyfunc, "s#", (void *)callBackParms, sizeof(NavCBRec));
9797
if ( rv ) {
9898
c_rv = PyObject_IsTrue(rv);
9999
Py_DECREF(rv);
100100
} else {
101-
fprintf(stderr, "Nav: exception in previewProc callback\n");
102-
PyErr_Clear();
101+
PySys_WriteStderr("Nav: exception in previewProc callback\n");
102+
PyErr_Print();
103103
}
104104
return c_rv;
105105
}
@@ -113,20 +113,21 @@ my_filterProc(AEDesc *theItem, void *info,
113113
PyObject *pyfunc;
114114
PyObject *rv;
115115
Boolean c_rv = false;
116+
PyObject theItemCopy;
116117

117118
if (!dict) return false;
118119
if ( (pyfunc = PyDict_GetItemString(dict, "filterProc")) == NULL ) {
119-
PyErr_Clear();
120+
PyErr_Print();
120121
return false;
121122
}
122123
rv = PyObject_CallFunction(pyfunc, "O&s#h",
123-
AEDesc_New, theItem, info, sizeof(NavFileOrFolderInfo), (short)filterMode);
124+
AEDesc_NewBorrowed, theItem, info, sizeof(NavFileOrFolderInfo), (short)filterMode);
124125
if ( rv ) {
125126
c_rv = PyObject_IsTrue(rv);
126127
Py_DECREF(rv);
127128
} else {
128-
fprintf(stderr, "Nav: exception in filterProc callback\n");
129-
PyErr_Clear();
129+
PySys_WriteStderr("Nav: exception in filterProc callback\n");
130+
PyErr_Print();
130131
}
131132
return c_rv;
132133
}

0 commit comments

Comments
 (0)