Skip to content

Commit 2c66b7c

Browse files
author
Hirokazu Yamamoto
committed
Merged revisions 66809-66810,66835,66862-66863 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66809 | hirokazu.yamamoto | 2008-10-06 10:57:03 +0900 | 1 line Added the test for issue3762. ........ r66810 | hirokazu.yamamoto | 2008-10-06 11:41:59 +0900 | 1 line More strict test. Consider the case sys.executable itself is symlink. ........ r66835 | hirokazu.yamamoto | 2008-10-08 03:10:47 +0900 | 1 line more intensive test on dbm. ........ r66862 | hirokazu.yamamoto | 2008-10-09 19:00:30 +0900 | 3 lines On windows, os.chdir given unicode was not working if GetCurrentDirectoryW returned a path longer than MAX_PATH. (But It's doubtful this code path is really executed because I cannot move to such directory on win2k) ........ r66863 | hirokazu.yamamoto | 2008-10-09 19:11:21 +0900 | 1 line r66862 contained memory leak. ........
1 parent 6b23e5a commit 2c66b7c

4 files changed

Lines changed: 36 additions & 9 deletions

File tree

Lib/test/test_dbm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from test import test_support
22
import unittest
3-
import os
4-
import random
53
import dbm
6-
from dbm import error
74

85
class DbmTestCase(unittest.TestCase):
96

@@ -18,11 +15,16 @@ def tearDown(self):
1815

1916
def test_keys(self):
2017
self.d = dbm.open(self.filename, 'c')
21-
self.assert_(self.d.keys() == [])
22-
self.d['a'] = 'b'
23-
self.d['12345678910'] = '019237410982340912840198242'
24-
self.d.keys()
25-
self.assert_(self.d.has_key('a'))
18+
self.assertEqual(self.d.keys(), [])
19+
a = [('a', 'b'), ('12345678910', '019237410982340912840198242')]
20+
for k, v in a:
21+
self.d[k] = v
22+
self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
23+
for k, v in a:
24+
self.assert_(k in self.d)
25+
self.assertEqual(self.d[k], v)
26+
self.assert_('xxx' not in self.d)
27+
self.assertRaises(KeyError, lambda: self.d['xxx'])
2628
self.d.close()
2729

2830
def test_modes(self):

Lib/test/test_platform.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
import os
33
import unittest
44
import platform
5+
import subprocess
56

67
from test import test_support
78

89
class PlatformTest(unittest.TestCase):
910
def test_architecture(self):
1011
res = platform.architecture()
1112

13+
if hasattr(os, "symlink"):
14+
def test_architecture_via_symlink(self): # issue3762
15+
def get(python):
16+
cmd = [python, '-c',
17+
'import platform; print platform.architecture()']
18+
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
19+
return p.communicate()
20+
real = os.path.realpath(sys.executable)
21+
link = os.path.abspath(test_support.TESTFN)
22+
os.symlink(real, link)
23+
try:
24+
self.assertEqual(get(real), get(link))
25+
finally:
26+
os.remove(link)
27+
1228
def test_machine(self):
1329
res = platform.machine()
1430

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ What's New in Python 2.6.1 alpha 1
1212
Core and Builtins
1313
-----------------
1414

15+
- On windows, os.chdir given unicode was not working if GetCurrentDirectoryW
16+
returned a path longer than MAX_PATH. (But It's doubtful this code path is
17+
really executed because I cannot move to such directory on win2k)
18+
1519
- Issue #4069: When set.remove(element) is used with a set element, the element
1620
is temporarily replaced with an equivalent frozenset. But the eventual
1721
KeyError would always report the empty frozenset([]) as the missing key. Now

Modules/posixmodule.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,16 @@ win32_wchdir(LPCWSTR path)
726726
if (!result)
727727
return FALSE;
728728
if (result > MAX_PATH+1) {
729-
new_path = malloc(result);
729+
new_path = malloc(result * sizeof(wchar_t));
730730
if (!new_path) {
731731
SetLastError(ERROR_OUTOFMEMORY);
732732
return FALSE;
733733
}
734+
result = GetCurrentDirectoryW(result, new_path);
735+
if (!result) {
736+
free(new_path);
737+
return FALSE;
738+
}
734739
}
735740
if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
736741
wcsncmp(new_path, L"//", 2) == 0)

0 commit comments

Comments
 (0)