[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Christian Heimes

New submission from Christian Heimes:

I've come up with a quick hack to support VS 2008. VS 2008 Standard
Edition doesn't store the include and lib dirs in the registry any more.
However I came up with a nice way to get the env settings from the
vcvarsall.bat. How do you like it?

Do we need support for VS6 and VS7.1 or can I remove the code from the
module?

--
assignee: loewis
components: Distutils
files: py3k_vs2008_hack.patch
keywords: patch, py3k
messages: 57599
nosy: loewis, tiran
priority: normal
severity: normal
status: open
title: VS2008, quick hack for distutils.msvccompiler
type: rfe
versions: Python 3.0
Added file: http://bugs.python.org/file8766/py3k_vs2008_hack.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/distutils/msvccompiler.py
===
--- Lib/distutils/msvccompiler.py	(revision 59036)
+++ Lib/distutils/msvccompiler.py	(working copy)
@@ -7,15 +7,17 @@
 # Written by Perry Stoll
 # hacked by Robin Becker and Thomas Heller to do a better job of
 #   finding DevStudio (through the registry)
+# ported to VS 2008 by Christian Heimes
 
 __revision__ = "$Id$"
 
-import sys, os
-from distutils.errors import \
- DistutilsExecError, DistutilsPlatformError, \
- CompileError, LibError, LinkError
-from distutils.ccompiler import \
- CCompiler, gen_preprocess_options, gen_lib_options
+import os
+import subprocess
+import sys
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError, 
+CompileError, LibError, LinkError)
+from distutils.ccompiler import (CCompiler, gen_preprocess_options,
+gen_lib_options)
 from distutils import log
 
 _can_read_reg = False
@@ -102,44 +104,57 @@
 return s
 
 class MacroExpander:
+_vsbase = r"Software\Microsoft\VisualStudio\%0.1f"
+winsdkbase = r"Software\Microsoft\Microsoft SDKs\Windows"
+netframework = r"Software\Microsoft\.NETFramework"
+
 def __init__(self, version):
 self.macros = {}
+self.vsbase = self._vsbase % version
 self.load_macros(version)
 
 def set_macro(self, macro, path, key):
 for base in HKEYS:
 d = read_values(base, path)
-if d:
+if d and key in d:
 self.macros["$(%s)" % macro] = d[key]
-break
+return
+raise KeyError(key)
 
 def load_macros(self, version):
-vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
-self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir")
-self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir")
-net = r"Software\Microsoft\.NETFramework"
-self.set_macro("FrameworkDir", net, "installroot")
+self.set_macro("VCInstallDir", self.vsbase + r"\Setup\VC", "productdir")
+self.set_macro("VSInstallDir", self.vsbase + r"\Setup\VS", "productdir")
+self.set_macro("FrameworkDir", self.netframework, "installroot")
 try:
-if version > 7.0:
-self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
+if version >= 9.0:
+self.set_macro("FrameworkSDKDir", self.netframework, 
+   "sdkinstallrootv2.0")
+elif version > 7.0:
+self.set_macro("FrameworkSDKDir", self.netframework, 
+   "sdkinstallrootv1.1")
 else:
-self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
+self.set_macro("FrameworkSDKDir", self.netframework,
+   "sdkinstallroot")
 except KeyError as exc: #
 raise DistutilsPlatformError(
-"""Python was built with Visual Studio 2003;
+"""Python was built with Visual Studio 2008;
 extensions must be built with a compiler than can generate compatible binaries.
-Visual Studio 2003 was not found on this system. If you have Cygwin installed,
+Visual Studio 2008 was not found on this system. If you have Cygwin installed,
 you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
 
-p = r"Software\Microsoft\NET Framework Setup\Product"
-for base in HKEYS:
-try:
-h = RegOpenKeyEx(base, p)
-except RegError:
-continue
-key = RegEnumKey(h, 0)
-d = read_values(base, r"%s\%s" % (p, key))
-self.macros["$(FrameworkVersion)"] = d["version"]
+if version >= 0.9:
+self.set_macro("FrameworkVersion", self.vsbase, "clr version")
+self.set_macro("WindowsSdkDir", self.winsdkbase, "currentinstallfolder")
+else:
+p = r"Software\Microsoft\NET Framework Setup\Product"
+for base in HKEYS:
+try:
+h = RegOpenKeyEx(base, p)
+   

[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Martin v. Löwis

Martin v. Löwis added the comment:

There is always the debate whether distutils might be repackaged and
backported to older Python releases, therefore people hesitate to remove
support for older versions.

As for finding it in the registry: are you sure it has no registry
settings anymore? I find that hard to believe.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Martin v. Löwis

Martin v. Löwis added the comment:

As another note: you shouldn't remove support code for Itanium. Even
though no Itanium binaries will be produced at the releases, I see no
reason to rip the code out - people with Itanium machines should still
be able to build Python, with some effort.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Christian Heimes

Christian Heimes added the comment:

Neither VS8 Professional nor VS9 Beta 2 Standard are storing the lib and
include directories in the registry. I've searched in HKCU and HKLM. The
best I could find was the path to a XML file in My Documents that
contains the information.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Ok. Running vsvars is fine, then.

The change to get_build_architecture is broken in another way: as it
parses the architecture out of sys.version, you still get Intel, not x86
(unless you also change PC/pyconfig.h - which may break code that relies
on the specific format of sys.version)

Otherwise, the patch looks fine.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1454] Generators break trace functionality

2007-11-17 Thread Guido van Rossum

Guido van Rossum added the comment:

I think this was fixed in svn this week!  See issue 1265.  Let me know
if your issue is different.

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1739468] Add a -z interpreter flag to execute a zip file

2007-11-17 Thread Nick Coghlan

Nick Coghlan added the comment:

Attached an updated version of PJE's patch with the suggested cleanups
and a new unit test file (test_cmd_line_script.py). Finding the
roundtuits to finish the latter is actually what has taken me so long.

The basic tests and the directory tests are currently working, but for
some reason the zipfile tests are attempting to load __main__ using
pkgutil.ImpLoader instead of the zipimport module.

I'm posting the patch anyway to see if anyone else can spot where it's
going wrong before I find some more time to try and figure it out for
myself.

Added file: http://bugs.python.org/file8767/runmain_with_tests.diff

_
Tracker <[EMAIL PROTECTED]>

_Index: Python/import.c
===
--- Python/import.c (revision 59036)
+++ Python/import.c (working copy)
@@ -104,7 +104,6 @@
 };
 #endif
 
-static PyTypeObject NullImporterType;  /* Forward reference */
 
 /* Initialize things */
 
@@ -167,7 +166,7 @@
 
/* adding sys.path_hooks and sys.path_importer_cache, setting up
   zipimport */
-   if (PyType_Ready(&NullImporterType) < 0)
+   if (PyType_Ready(&PyNullImporter_Type) < 0)
goto error;
 
if (Py_VerboseFlag)
@@ -1088,7 +1087,7 @@
}
if (importer == NULL) {
importer = PyObject_CallFunctionObjArgs(
-   (PyObject *)&NullImporterType, p, NULL
+   (PyObject *)&PyNullImporter_Type, p, NULL
);
if (importer == NULL) {
if (PyErr_ExceptionMatches(PyExc_ImportError)) {
@@ -1106,6 +1105,20 @@
return importer;
 }
 
+PyAPI_FUNC(PyObject *)
+PyImport_GetImporter(PyObject *path) {
+PyObject *importer=NULL, *path_importer_cache=NULL, *path_hooks=NULL;
+
+   if ((path_importer_cache = PySys_GetObject("path_importer_cache"))) {
+   if ((path_hooks = PySys_GetObject("path_hooks"))) {
+   importer = get_path_importer(path_importer_cache,
+path_hooks, path);
+   }
+   }
+   Py_XINCREF(importer); /* get_path_importer returns a borrowed reference 
*/
+   return importer;
+}
+
 /* Search the path (default sys.path) for a module.  Return the
corresponding filedescr struct, and (via return arguments) the
pathname and an open file.  Return NULL if the module is not found. */
@@ -3049,7 +3062,7 @@
 };
 
 
-static PyTypeObject NullImporterType = {
+PyTypeObject PyNullImporter_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"imp.NullImporter",/*tp_name*/
sizeof(NullImporter),  /*tp_basicsize*/
@@ -3096,7 +3109,7 @@
 {
PyObject *m, *d;
 
-   if (PyType_Ready(&NullImporterType) < 0)
+   if (PyType_Ready(&PyNullImporter_Type) < 0)
goto failure;
 
m = Py_InitModule4("imp", imp_methods, doc_imp,
@@ -3118,8 +3131,8 @@
if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure;
if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure;
 
-   Py_INCREF(&NullImporterType);
-   PyModule_AddObject(m, "NullImporter", (PyObject *)&NullImporterType);
+   Py_INCREF(&PyNullImporter_Type);
+   PyModule_AddObject(m, "NullImporter", (PyObject *)&PyNullImporter_Type);
   failure:
;
 }
Index: Include/import.h
===
--- Include/import.h(revision 59036)
+++ Include/import.h(working copy)
@@ -24,6 +24,7 @@
 #define PyImport_ImportModuleEx(n, g, l, f) \
PyImport_ImportModuleLevel(n, g, l, f, -1)
 
+PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
 PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
 PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
 PyAPI_FUNC(void) PyImport_Cleanup(void);
@@ -42,6 +43,7 @@
 void (*initfunc)(void);
 };
 
+PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
 PyAPI_DATA(struct _inittab *) PyImport_Inittab;
 
 PyAPI_FUNC(int) PyImport_AppendInittab(char *name, void (*initfunc)(void));
Index: Lib/test/test_cmd_line.py
===
--- Lib/test/test_cmd_line.py   (revision 59036)
+++ Lib/test/test_cmd_line.py   (working copy)
@@ -1,3 +1,6 @@
+# Tests invocation of the interpreter with various command line arguments
+# All tests are executed with environment variables ignored
+# See test_cmd_line_script.py for testing of script execution
 
 import test.test_support, unittest
 import sys
Index: Lib/test/test_cmd_line_script.py
===
--- Lib/test/test_cmd_line_script.py(revision 0)
+++ Lib/test/test_cmd_line_script.py(revision 0)
@@ -0,0 +1,145 @@
+# Tests command line execution of scripts
+from __future__ i

[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Christian Heimes

Christian Heimes added the comment:

Ok, I'll take it from here. I'm going to wait until it's decided to use
VS 2008 as the new default compiler.

--
assignee: loewis -> tiran

__
Tracker <[EMAIL PROTECTED]>

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



[issue1454] Generators break trace functionality

2007-11-17 Thread Aldo Cortesi

Aldo Cortesi added the comment:

Drat, you're right. This was fixed a few days ago by Amaury in
http://svn.python.org/view?rev=58963&view=rev 

Another example of confluence - this bug has existed for a very long time.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1454] Generators break trace functionality

2007-11-17 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks anyway!

--
resolution:  -> duplicate
status: open -> closed
superseder:  -> pdb bug with "with" statement

__
Tracker <[EMAIL PROTECTED]>

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



[issue1251] ssl module doesn't support non-blocking handshakes

2007-11-17 Thread Bill Janssen

Bill Janssen added the comment:

This is now checked into the 3K branch.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-17 Thread Christian Heimes

Christian Heimes added the comment:

UPDATES:

* Cleanup and rewrite of the registry related code
* Moved search code to find_vcvarsall().
* Added fallback using the VS90COMNTOOL env var for Express edition

Added file: http://bugs.python.org/file8768/py3k_vs2008_2.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/distutils/msvccompiler.py
===
--- Lib/distutils/msvccompiler.py	(revision 59036)
+++ Lib/distutils/msvccompiler.py	(working copy)
@@ -1,145 +1,152 @@
-"""distutils.msvccompiler
+"""distutils.msvc9compiler
 
 Contains MSVCCompiler, an implementation of the abstract CCompiler class
-for the Microsoft Visual Studio.
+for the Microsoft Visual Studio 2008.
 """
 
 # Written by Perry Stoll
 # hacked by Robin Becker and Thomas Heller to do a better job of
 #   finding DevStudio (through the registry)
+# ported to VS 2008 by Christian Heimes
 
 __revision__ = "$Id$"
 
-import sys, os
-from distutils.errors import \
- DistutilsExecError, DistutilsPlatformError, \
- CompileError, LibError, LinkError
-from distutils.ccompiler import \
- CCompiler, gen_preprocess_options, gen_lib_options
+import os
+import subprocess
+import sys
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError, 
+CompileError, LibError, LinkError)
+from distutils.ccompiler import (CCompiler, gen_preprocess_options,
+gen_lib_options)
 from distutils import log
 
-_can_read_reg = False
-try:
-import _winreg
+import _winreg
 
-_can_read_reg = True
-hkey_mod = _winreg
+RegOpenKeyEx = _winreg.OpenKeyEx
+RegEnumKey = _winreg.EnumKey
+RegEnumValue = _winreg.EnumValue
+RegError = _winreg.error
 
-RegOpenKeyEx = _winreg.OpenKeyEx
-RegEnumKey = _winreg.EnumKey
-RegEnumValue = _winreg.EnumValue
-RegError = _winreg.error
+HKEYS = (_winreg.HKEY_USERS,
+ _winreg.HKEY_CURRENT_USER,
+ _winreg.HKEY_LOCAL_MACHINE,
+ _winreg.HKEY_CLASSES_ROOT)
 
-except ImportError:
-try:
-import win32api
-import win32con
-_can_read_reg = True
-hkey_mod = win32con
+VS_BASE = r"Software\Microsoft\VisualStudio\%0.1f"
+WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
+NET_BASE = r"Software\Microsoft\.NETFramework"
+ARCHS = {'DEFAULT' : 'x86',
+'intel' : 'x86', 'x86' : 'x86',
+'amd64' : 'x64', 'x64' : 'x64',
+'itanium' : 'ia64', 'ia64' : 'ia64',
+}
 
-RegOpenKeyEx = win32api.RegOpenKeyEx
-RegEnumKey = win32api.RegEnumKey
-RegEnumValue = win32api.RegEnumValue
-RegError = win32api.error
-except ImportError:
-log.info("Warning: Can't read registry to find the "
- "necessary compiler setting\n"
- "Make sure that Python modules _winreg, "
- "win32api or win32con are installed.")
-pass
+class Reg:
+"""Helper class to read values from the registry
+"""
 
-if _can_read_reg:
-HKEYS = (hkey_mod.HKEY_USERS,
- hkey_mod.HKEY_CURRENT_USER,
- hkey_mod.HKEY_LOCAL_MACHINE,
- hkey_mod.HKEY_CLASSES_ROOT)
-
-def read_keys(base, key):
-"""Return list of registry keys."""
-try:
-handle = RegOpenKeyEx(base, key)
-except RegError:
-return None
-L = []
-i = 0
-while True:
+@classmethod
+def get_value(cls, path, key):
+for base in HKEYS:
+d = cls.read_values(base, path)
+if d and key in d:
+return d[key]
+raise KeyError(key)
+
+@classmethod
+def read_keys(cls, base, key):
+"""Return list of registry keys."""
 try:
-k = RegEnumKey(handle, i)
+handle = RegOpenKeyEx(base, key)
 except RegError:
-break
-L.append(k)
-i += 1
-return L
+return None
+L = []
+i = 0
+while True:
+try:
+k = RegEnumKey(handle, i)
+except RegError:
+break
+L.append(k)
+i += 1
+return L
 
-def read_values(base, key):
-"""Return dict of registry keys and values.
-
-All names are converted to lowercase.
-"""
-try:
-handle = RegOpenKeyEx(base, key)
-except RegError:
-return None
-d = {}
-i = 0
-while True:
+@classmethod
+def read_values(cls, base, key):
+"""Return dict of registry keys and values.
+
+All names are converted to lowercase.
+"""
 try:
-name, value, type = RegEnumValue(handle, i)
+handle = RegOpenKeyEx(base, key)
 except RegError:
-break
-name = name.lower()
-d[convert_mbcs(name)] = convert_mbcs(value)
-i += 1
-return d
+return None
+d = {}
+i = 0
+while

[issue1456] unexpected iterator behavior with removal

2007-11-17 Thread Joseph Armbruster

New submission from Joseph Armbruster:

Trunk Revision: 58651

Example of potential issue:

>>> a = [1,2,3,4,5]
>>>
>>> for x in a:
...   a.remove(x)
...
>>>
>>> a
[2, 4]


If this is the expected behavior of iteration in this case, my
apologies.  If this is not, I believe the issue lies in that
listiter_next does not act correctly after a listremove has occurred.

My knowledge of Python development is practically 0, so please take the
patch with a grain of salt.

--
components: Interpreter Core
files: listobjectpatch.patch
messages: 57611
nosy: JosephArmbruster
severity: normal
status: open
title: unexpected iterator behavior with removal
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file8769/listobjectpatch.patch

__
Tracker <[EMAIL PROTECTED]>

__

listobjectpatch.patch
Description: Binary data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1456] unexpected iterator behavior with removal

2007-11-17 Thread Christian Heimes

Christian Heimes added the comment:

Closed as discussed on IRC.

--
nosy: +tiran
resolution:  -> invalid
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