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

Skip to content

Commit 3e0196c

Browse files
committed
Adding unicode filename support to FSRefs broke things on MacOS9. "Fixed" by disabling unicode filenames on OS9.
1 parent 7e0bc11 commit 3e0196c

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/test/test_macfs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
warnings.filterwarnings("ignore", "macfs.*", DeprecationWarning, __name__)
66
import macfs
77
import os
8+
import sys
89
import tempfile
910
from test import test_support
1011

@@ -30,9 +31,10 @@ def test_fsref(self):
3031
self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
3132

3233
def test_fsref_unicode(self):
33-
testfn_unicode = unicode(test_support.TESTFN)
34-
fsr = macfs.FSRef(testfn_unicode)
35-
self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
34+
if sys.getfilesystemencoding():
35+
testfn_unicode = unicode(test_support.TESTFN)
36+
fsr = macfs.FSRef(testfn_unicode)
37+
self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
3638

3739
def test_coercion(self):
3840
fss = macfs.FSSpec(test_support.TESTFN)

Mac/Modules/file/_Filemodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,8 @@ PyMac_GetFSSpec(PyObject *v, FSSpec *spec)
31943194
#if TARGET_API_MAC_OSX
31953195
if ( PyMac_GetFSRef(v, &fsr) ) {
31963196
#else
3197-
if ( PyArg_Parse(v, "O&", FSRef_Convert, &fsr) ) {
3197+
if (FSRef_Check(v)) {
3198+
fsr = ((FSRefObject *)v)->ob_itself;
31983199
#endif
31993200
err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
32003201
if (err != noErr) {

Mac/Modules/file/filesupport.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ def getargsCheck(self, name):
252252
#if TARGET_API_MAC_OSX
253253
if ( PyMac_GetFSRef(v, &fsr) ) {
254254
#else
255-
if ( PyArg_Parse(v, "O&", FSRef_Convert, &fsr) ) {
255+
if (FSRef_Check(v)) {
256+
fsr = ((FSRefObject *)v)->ob_itself;
256257
#endif
257258
err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
258259
if (err != noErr) {

0 commit comments

Comments
 (0)