mirror of https://github.com/python/cpython
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. ........
This commit is contained in:
parent
6b23e5a315
commit
2c66b7cd9f
|
@ -1,9 +1,6 @@
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
|
||||||
import random
|
|
||||||
import dbm
|
import dbm
|
||||||
from dbm import error
|
|
||||||
|
|
||||||
class DbmTestCase(unittest.TestCase):
|
class DbmTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -18,11 +15,16 @@ class DbmTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_keys(self):
|
def test_keys(self):
|
||||||
self.d = dbm.open(self.filename, 'c')
|
self.d = dbm.open(self.filename, 'c')
|
||||||
self.assert_(self.d.keys() == [])
|
self.assertEqual(self.d.keys(), [])
|
||||||
self.d['a'] = 'b'
|
a = [('a', 'b'), ('12345678910', '019237410982340912840198242')]
|
||||||
self.d['12345678910'] = '019237410982340912840198242'
|
for k, v in a:
|
||||||
self.d.keys()
|
self.d[k] = v
|
||||||
self.assert_(self.d.has_key('a'))
|
self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
|
||||||
|
for k, v in a:
|
||||||
|
self.assert_(k in self.d)
|
||||||
|
self.assertEqual(self.d[k], v)
|
||||||
|
self.assert_('xxx' not in self.d)
|
||||||
|
self.assertRaises(KeyError, lambda: self.d['xxx'])
|
||||||
self.d.close()
|
self.d.close()
|
||||||
|
|
||||||
def test_modes(self):
|
def test_modes(self):
|
||||||
|
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import platform
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
|
||||||
|
@ -9,6 +10,21 @@ class PlatformTest(unittest.TestCase):
|
||||||
def test_architecture(self):
|
def test_architecture(self):
|
||||||
res = platform.architecture()
|
res = platform.architecture()
|
||||||
|
|
||||||
|
if hasattr(os, "symlink"):
|
||||||
|
def test_architecture_via_symlink(self): # issue3762
|
||||||
|
def get(python):
|
||||||
|
cmd = [python, '-c',
|
||||||
|
'import platform; print platform.architecture()']
|
||||||
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
|
return p.communicate()
|
||||||
|
real = os.path.realpath(sys.executable)
|
||||||
|
link = os.path.abspath(test_support.TESTFN)
|
||||||
|
os.symlink(real, link)
|
||||||
|
try:
|
||||||
|
self.assertEqual(get(real), get(link))
|
||||||
|
finally:
|
||||||
|
os.remove(link)
|
||||||
|
|
||||||
def test_machine(self):
|
def test_machine(self):
|
||||||
res = platform.machine()
|
res = platform.machine()
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@ What's New in Python 2.6.1 alpha 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|
||||||
- Issue #4069: When set.remove(element) is used with a set element, the element
|
- Issue #4069: When set.remove(element) is used with a set element, the element
|
||||||
is temporarily replaced with an equivalent frozenset. But the eventual
|
is temporarily replaced with an equivalent frozenset. But the eventual
|
||||||
KeyError would always report the empty frozenset([]) as the missing key. Now
|
KeyError would always report the empty frozenset([]) as the missing key. Now
|
||||||
|
|
|
@ -726,11 +726,16 @@ win32_wchdir(LPCWSTR path)
|
||||||
if (!result)
|
if (!result)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (result > MAX_PATH+1) {
|
if (result > MAX_PATH+1) {
|
||||||
new_path = malloc(result);
|
new_path = malloc(result * sizeof(wchar_t));
|
||||||
if (!new_path) {
|
if (!new_path) {
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
result = GetCurrentDirectoryW(result, new_path);
|
||||||
|
if (!result) {
|
||||||
|
free(new_path);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
|
if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
|
||||||
wcsncmp(new_path, L"//", 2) == 0)
|
wcsncmp(new_path, L"//", 2) == 0)
|
||||||
|
|
Loading…
Reference in New Issue