[issue1331] More fixes for Windows

2007-10-25 Thread Guido van Rossum

Guido van Rossum added the comment:

Tested on OSX as well.  Thanks!!
Committed revision 58662.

--
assignee:  -> gvanrossum
keywords: +patch, py3k
resolution:  -> accepted
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1331] More fixes for Windows

2007-10-25 Thread Christian Heimes

New submission from Christian Heimes:

The patch fixes some of the problems on Windows. It doesn't introduce
addition problems on Linux.

--
components: Library (Lib)
files: py3k_misc_win.patch
messages: 56770
nosy: gvanrossum, nnorwitz, tiran
severity: normal
status: open
title: More fixes for Windows
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file8614/py3k_misc_win.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/netrc.py
===
--- Lib/netrc.py	(revision 58660)
+++ Lib/netrc.py	(working copy)
@@ -26,9 +26,12 @@
 file = os.path.join(os.environ['HOME'], ".netrc")
 except KeyError:
 raise IOError("Could not find .netrc: $HOME is not set")
-fp = open(file)
 self.hosts = {}
 self.macros = {}
+with open(file) as fp:
+self._parse(file, fp)
+
+def _parse(self, file, fp):
 lexer = shlex.shlex(fp)
 lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>[EMAIL PROTECTED]|}~"""
 while 1:
Index: Lib/subprocess.py
===
--- Lib/subprocess.py	(revision 58660)
+++ Lib/subprocess.py	(working copy)
@@ -809,6 +809,8 @@
 
 if self.stdin:
 if input is not None:
+if isinstance(input, str):
+input = input.encode()
 self.stdin.write(input)
 self.stdin.close()
 
Index: Lib/test/regrtest.py
===
--- Lib/test/regrtest.py	(revision 58660)
+++ Lib/test/regrtest.py	(working copy)
@@ -885,6 +885,7 @@
 test_pwd
 test_resource
 test_signal
+test_syslog
 test_threadsignals
 test_wait3
 test_wait4
Index: Lib/test/test_mailbox.py
===
--- Lib/test/test_mailbox.py	(revision 58660)
+++ Lib/test/test_mailbox.py	(working copy)
@@ -58,6 +58,7 @@
 self._box = self._factory(self._path)
 
 def tearDown(self):
+self._box.close()
 self._delete_recursively(self._path)
 
 def test_add(self):
@@ -390,12 +391,14 @@
 self._box.add(contents[0])
 self._box.add(contents[1])
 self._box.add(contents[2])
+oldbox = self._box
 method()
 self._box = self._factory(self._path)
 keys = self._box.keys()
 self.assertEqual(len(keys), 3)
 for key in keys:
 self.assert_(self._box.get_string(key) in contents)
+oldbox.close()
 
 def test_dump_message(self):
 # Write message representations to disk
@@ -403,7 +406,7 @@
   _sample_message, io.StringIO(_sample_message)):
 output = io.StringIO()
 self._box._dump_message(input, output)
-self.assert_(output.getvalue() ==
+self.assertEqual(output.getvalue(),
  _sample_message.replace('\n', os.linesep))
 output = io.StringIO()
 self.assertRaises(TypeError,
@@ -694,6 +697,7 @@
 class _TestMboxMMDF(TestMailbox):
 
 def tearDown(self):
+self._box.close()
 self._delete_recursively(self._path)
 for lock_remnant in glob.glob(self._path + '.*'):
 test_support.unlink(lock_remnant)
@@ -916,6 +920,7 @@
 _factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
 
 def tearDown(self):
+self._box.close()
 self._delete_recursively(self._path)
 for lock_remnant in glob.glob(self._path + '.*'):
 test_support.unlink(lock_remnant)
Index: Lib/test/test_netrc.py
===
--- Lib/test/test_netrc.py	(revision 58660)
+++ Lib/test/test_netrc.py	(working copy)
@@ -21,25 +21,24 @@
 
 class NetrcTestCase(unittest.TestCase):
 
-def setUp (self):
+def setUp(self):
 mode = 'w'
 if sys.platform not in ['cygwin']:
 mode += 't'
 fp = open(temp_filename, mode)
 fp.write(TEST_NETRC)
 fp.close()
-self.netrc = netrc.netrc(temp_filename)
 
-def tearDown (self):
-del self.netrc
+def tearDown(self):
 os.unlink(temp_filename)
 
 def test_case_1(self):
-self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'],
+nrc = netrc.netrc(temp_filename)
+self.assert_(nrc.macros == {'macro1':['line1\n', 'line2\n'],
'macro2':['line3\n', 'line4\n']}
)
-self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
-self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2'))
+self.assert_(nrc.hosts