summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/__init__.py5
-rwxr-xr-xLib/platform.py73
-rw-r--r--Lib/test/crashers/loosing_mro_ref.py7
-rw-r--r--Lib/test/test_grammar.py1
-rw-r--r--Lib/test/test_heapq.py3
-rw-r--r--Lib/test/test_struct.py6
-rw-r--r--Lib/test/test_sys.py3
7 files changed, 58 insertions, 40 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 742eac2..9727d4f 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -731,7 +731,7 @@ class StreamHandler(Handler):
"""
Flushes the stream.
"""
- if self.stream:
+ if self.stream and hasattr(self.stream, "flush"):
self.stream.flush()
def emit(self, record):
@@ -787,7 +787,8 @@ class FileHandler(StreamHandler):
"""
if self.stream:
self.flush()
- self.stream.close()
+ if hasattr(self.stream, "close"):
+ self.stream.close()
StreamHandler.close(self)
self.stream = None
diff --git a/Lib/platform.py b/Lib/platform.py
index 8447d41..33033ff 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1066,23 +1066,30 @@ def uname():
"""
global _uname_cache
+ no_os_uname = 0
if _uname_cache is not None:
return _uname_cache
+ processor = ''
+
# Get some infos from the builtin os.uname API...
try:
system,node,release,version,machine = os.uname()
-
except AttributeError:
- # Hmm, no uname... we'll have to poke around the system then.
- system = sys.platform
- release = ''
- version = ''
- node = _node()
- machine = ''
- processor = ''
- use_syscmd_ver = 1
+ no_os_uname = 1
+
+ if no_os_uname or not filter(None, (system, node, release, version, machine)):
+ # Hmm, no there is either no uname or uname has returned
+ #'unknowns'... we'll have to poke around the system then.
+ if no_os_uname:
+ system = sys.platform
+ release = ''
+ version = ''
+ node = _node()
+ machine = ''
+
+ use_syscmd_ver = 01
# Try win32_ver() on win32 platforms
if system == 'win32':
@@ -1093,8 +1100,10 @@ def uname():
# available on Win XP and later; see
# http://support.microsoft.com/kb/888731 and
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
- machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
- processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
+ if not machine:
+ machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
+ if not processor:
+ processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
# Try the 'ver' system command available on some
# platforms
@@ -1136,30 +1145,28 @@ def uname():
release,(version,stage,nonrel),machine = mac_ver()
system = 'MacOS'
- else:
- # System specific extensions
- if system == 'OpenVMS':
- # OpenVMS seems to have release and version mixed up
- if not release or release == '0':
- release = version
- version = ''
- # Get processor information
- try:
- import vms_lib
- except ImportError:
- pass
- else:
- csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
- if (cpu_number >= 128):
- processor = 'Alpha'
- else:
- processor = 'VAX'
+ # System specific extensions
+ if system == 'OpenVMS':
+ # OpenVMS seems to have release and version mixed up
+ if not release or release == '0':
+ release = version
+ version = ''
+ # Get processor information
+ try:
+ import vms_lib
+ except ImportError:
+ pass
else:
- # Get processor information from the uname system command
- processor = _syscmd_uname('-p','')
+ csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
+ if (cpu_number >= 128):
+ processor = 'Alpha'
+ else:
+ processor = 'VAX'
+ if not processor:
+ # Get processor information from the uname system command
+ processor = _syscmd_uname('-p','')
- # 'unknown' is not really any useful as information; we'll convert
- # it to '' which is more portable
+ #If any unknowns still exist, replace them with ''s, which are more portable
if system == 'unknown':
system = ''
if node == 'unknown':
diff --git a/Lib/test/crashers/loosing_mro_ref.py b/Lib/test/crashers/loosing_mro_ref.py
index 5ecde63..a8c6e63 100644
--- a/Lib/test/crashers/loosing_mro_ref.py
+++ b/Lib/test/crashers/loosing_mro_ref.py
@@ -27,10 +27,9 @@ class Base(object):
class Base2(object):
mykey = 'from Base2'
-class X(Base):
- # you can't add a non-string key to X.__dict__, but it can be
- # there from the beginning :-)
- locals()[MyKey()] = 5
+# you can't add a non-string key to X.__dict__, but it can be
+# there from the beginning :-)
+X = type('X', (Base,), {MyKey(): 5})
print(X.mykey)
# I get a segfault, or a slightly wrong assertion error in a debug build.
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 1a34ff8..acfe1f1 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -335,6 +335,7 @@ class GrammarTests(unittest.TestCase):
self.assertEquals(l5(1, 2), 5)
self.assertEquals(l5(1, 2, 3), 6)
check_syntax_error(self, "lambda x: x = 2")
+ check_syntax_error(self, "lambda (None,): None")
l6 = lambda x, y, *, k=20: x+y+k
self.assertEquals(l6(1,2), 1+2+20)
self.assertEquals(l6(1,2,k=10), 1+2+10)
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index 1c7c97f..fba4fd7 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -211,10 +211,11 @@ class TestHeapC(TestHeap):
class LE:
def __init__(self, x):
self.x = x
- def __lt__(self, other):
+ def __le__(self, other):
return self.x >= other.x
data = [random.random() for i in range(100)]
target = sorted(data, reverse=True)
+ print("HASATTR", hasattr(LE(0), "__lt__"), LE(0).__lt__)
self.assertEqual(hsort(data, LT), target)
self.assertEqual(hsort(data, LE), target)
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 917f626..616e665 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -8,6 +8,7 @@ from test.support import TestFailed, verbose, run_unittest, catch_warning
import sys
ISBIGENDIAN = sys.byteorder == "big"
+IS32BIT = sys.maxsize == 0x7fffffff
del sys
try:
@@ -580,6 +581,11 @@ class StructTest(unittest.TestCase):
for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
self.assertTrue(struct.unpack('>?', c)[0])
+ if IS32BIT:
+ def test_crasher(self):
+ self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
+
+
def test_main():
run_unittest(StructTest)
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 4049802..08fc909 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -520,6 +520,9 @@ class SizeofTest(unittest.TestCase):
self.check_sizeof(32768, h + self.align(2) + 2)
self.check_sizeof(32768*32768-1, h + self.align(2) + 2)
self.check_sizeof(32768*32768, h + self.align(2) + 4)
+ # tuple
+ self.check_sizeof((), h)
+ self.check_sizeof((1,2,3), h + 3*p)
def test_main():