[issue1575] typo in README

2007-12-09 Thread Georg Brandl

Georg Brandl added the comment:

Don't worry, this is what bots are here for :)
Fixed in r59436.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1575
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1571] Better description of 'L' repr removal in What's New

2007-12-09 Thread Georg Brandl

Georg Brandl added the comment:

Thanks, fixed in r59438.

--
resolution:  - fixed
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1571
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564547] Py_signal_pipe

2007-12-09 Thread Gustavo J. A. M. Carneiro

Gustavo J. A. M. Carneiro added the comment:

Minimal patch that just adds the pipe but does not attempt to fix
anything else.

Added file: http://bugs.python.org/file8898/python-signals-minimal.diff

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564547
_Index: Python/sigcheck.c
===
--- Python/sigcheck.c	(revision 59439)
+++ Python/sigcheck.c	(working copy)
@@ -17,3 +17,6 @@
 	PyErr_SetNone(PyExc_KeyboardInterrupt);
 	return -1;
 }
+
+int Py_signal_pipe = -1;
+
Index: Include/pyerrors.h
===
--- Include/pyerrors.h	(revision 59439)
+++ Include/pyerrors.h	(working copy)
@@ -238,6 +238,11 @@
 PyAPI_FUNC(int) PyErr_CheckSignals(void);
 PyAPI_FUNC(void) PyErr_SetInterrupt(void);
 
+/* Read end of a pipe used to notify the main thread / main loop that
+   there are pending signals; Equal to -1 if the platform doesn't
+   support signals. */
+PyAPI_DATA(int) Py_signal_pipe;
+
 /* Support for adding program text to SyntaxErrors */
 PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
 PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
Index: Modules/signalmodule.c
===
--- Modules/signalmodule.c	(revision 59439)
+++ Modules/signalmodule.c	(working copy)
@@ -11,6 +11,8 @@
 #endif
 
 #include signal.h
+#include unistd.h
+#include fcntl.h
 
 #ifndef SIG_ERR
 #define SIG_ERR ((PyOS_sighandler_t)(-1))
@@ -88,7 +90,10 @@
 
 static PyOS_sighandler_t old_siginthandler = SIG_DFL;
 
+int Py_signal_pipe = -1;/* read end */
+static int Py_signal_pipe_w;/* write end */
 
+
 static PyObject *
 signal_default_int_handler(PyObject *self, PyObject *args)
 {
@@ -112,6 +117,7 @@
 static void
 signal_handler(int sig_num)
 {
+	char dummy_char;
 #ifdef WITH_THREAD
 #ifdef WITH_PTH
 	if (PyThread_get_thread_ident() != main_thread) {
@@ -125,6 +131,7 @@
 		is_tripped++;
 		Handlers[sig_num].tripped = 1;
 		Py_AddPendingCall(checksignals_witharg, NULL);
+		write(Py_signal_pipe_w, dummy_char, sizeof(dummy_char));
 #ifdef WITH_THREAD
 	}
 #endif
@@ -309,6 +316,7 @@
 {
 	PyObject *m, *d, *x;
 	int i;
+	int filedes[2], fd_flags;
 
 #ifdef WITH_THREAD
 	main_thread = PyThread_get_thread_ident();
@@ -336,6 +344,30 @@
 goto finally;
 Py_DECREF(x);
 
+
+#define set_nonblock(fd)\
+	if ((fd_flags = fcntl(fd, F_GETFL, 0)) == -1) { \
+PyErr_SetFromErrno(PyExc_RuntimeError); \
+return; \
+}   \
+	fd_flags |= O_NONBLOCK; \
+if (fcntl(fd, F_SETFL, fd_flags) == -1) {   \
+PyErr_SetFromErrno(PyExc_RuntimeError); \
+return; \
+}
+
+if (Py_signal_pipe == -1) {
+if (pipe(filedes)) {
+PyErr_SetFromErrno(PyExc_RuntimeError);
+return;
+}
+set_nonblock(filedes[0]);
+set_nonblock(filedes[1]);
+Py_signal_pipe = filedes[0];
+Py_signal_pipe_w = filedes[1];
+}
+#undef set_nonblock
+
 	x = IntHandler = PyDict_GetItemString(d, default_int_handler);
 if (!x)
 goto finally;
@@ -592,6 +624,7 @@
 int
 PyErr_CheckSignals(void)
 {
+	char dummy_c;
 	int i;
 	PyObject *f;
 
@@ -621,6 +654,11 @@
 			Py_DECREF(result);
 		}
 	}
+  /* Flush all bytes from the pipe, so that it stops notifying
+   * main threads / main loops that signals are pending. */
+	while (read(Py_signal_pipe, dummy_c, sizeof(dummy_c)) == sizeof(dummy_c))
+		; /* pass */
+
 	is_tripped = 0;
 	return 0;
 }
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file8896/py3k_optimize_set_unicode.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1573] Improper use of the keyword-only syntax makes the parser crash

2007-12-09 Thread Christian Heimes

Christian Heimes added the comment:

I'm fine with your patch. Can you commit it please?

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1573
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The patch doesn't parallel what was done for dicts.  The code in 
dictobject.c does not use a macro.  It special cases for PyUnicode but 
not PyString.  Please submit a patch that mirrors what was done for 
dicts.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564547] Py_signal_pipe

2007-12-09 Thread Adam Olsen

Adam Olsen added the comment:

The minimal patch doesn't initialize dummy_char or dummy_c.  It's
harmless here, but please fix it. ;)

sizeof(dummy_char) will always be 1 (C defines sizeof as multiples of
char.)  The convention seems to be hardcoding 1 instead.

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564547
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564547] Py_signal_pipe

2007-12-09 Thread Gustavo J. A. M. Carneiro

Gustavo J. A. M. Carneiro added the comment:

 The minimal patch doesn't initialize dummy_char or dummy_c.  It's
harmless here, but please fix it. ;)

The variable is called 'dummy' for a reason.  The value written or read
is irrevelant...

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564547
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1576] First draft of a post import hook

2007-12-09 Thread Christian Heimes

New submission from Christian Heimes:

I've written a rough draft for a post import hook as discussed on the
python 3000 mailing list. The implementation is far from perfect. It
requires more unit tests, a code review and reference count checks.

--
assignee: tiran
components: Interpreter Core
files: py3k_post_import_hook.patch
keywords: py3k
messages: 58323
nosy: ncoghlan, pje, tiran
priority: normal
severity: normal
status: open
title: First draft of a post import hook
type: rfe
versions: Python 3.0
Added file: http://bugs.python.org/file8900/py3k_post_import_hook.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1576
__Index: Python/import.c
===
--- Python/import.c	(Revision 59441)
+++ Python/import.c	(Arbeitskopie)
@@ -161,7 +161,7 @@
 void
 _PyImportHooks_Init(void)
 {
-	PyObject *v, *path_hooks = NULL, *zimpimport;
+	PyObject *v, *path_hooks = NULL, *zimpimport, *pihr;
 	int err = 0;
 
 	/* adding sys.path_hooks and sys.path_importer_cache, setting up
@@ -198,6 +198,14 @@
 			  );
 	}
 
+	pihr = PyDict_New();
+	if (pihr == NULL ||
+PySys_SetObject(post_import_hooks, pihr) != 0) {
+		PyErr_Print();
+		Py_FatalError(initialization of post import hook registry 
+			  failed);
+	}
+
 	zimpimport = PyImport_ImportModule(zipimport);
 	if (zimpimport == NULL) {
 		PyErr_Clear(); /* No zip import module -- okay */
@@ -623,6 +631,186 @@
 			  sys.modules failed);
 }
 
+/* post import hook API */
+PyObject *
+PyImport_GetPostImportHooks(void)
+{
+	PyObject *pihr;
+
+	pihr = PySys_GetObject(post_import_hooks);
+	/* This should only happen during initialization */
+	if (pihr == NULL)
+		return NULL;
+
+	if (!PyDict_Check(pihr)) {
+		PyErr_SetString(PyExc_TypeError,
+post import registry is not a dict);
+	}
+
+	Py_INCREF(pihr);
+	return pihr;
+}
+
+PyObject *
+PyImport_NotifyPostImport(PyObject *module)
+{
+	static PyObject *name = NULL;
+	PyObject *mod_name = NULL, *registry = NULL, *o;
+	PyObject *hooks = NULL, *hook, *it = NULL;
+	int status = -1;
+
+	if (module == NULL)
+		return NULL;
+	if (!PyModule_Check(module)) {
+		PyErr_BadInternalCall();
+		return NULL;
+	}
+
+	if (!PyModule_IsLoaded(module)) {
+		/* nothing to do here */
+		return module;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		/* This should only happen during initialization */
+		return module;
+	}
+
+	if (name == NULL) {
+		name = PyUnicode_InternFromString(__name__);
+		if (name == NULL)
+			return NULL;
+	}
+
+	mod_name = PyObject_GetAttr(module, name);
+	if (mod_name == NULL) {
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyErr_Format(PyExc_TypeError,
+			 Module name %.200s of %.200s is not string,
+			 PyObject_Repr(mod_name),
+			 PyObject_Repr(module));
+		goto error;
+	}
+
+	hooks = PyObject_GetItem(registry, mod_name);
+	if (hooks == NULL || hooks == Py_None) {
+		/* Either no hooks are defined or they are already fired */
+		if (hooks == NULL) {
+			PyErr_Clear();
+		}
+		Py_DECREF(mod_name);
+		Py_DECREF(registry);
+		return module;
+	}
+	if (!PyList_Check(hooks)) {
+		PyErr_Format(PyExc_TypeError,
+			 expected None or list of hooks, got %.200s,
+			 PyObject_Repr(hooks));
+		goto error;
+	}
+
+	it = PyObject_GetIter(hooks);
+	if (it == NULL) {
+		goto error;
+	}
+	while ((hook = PyIter_Next(it)) != NULL) {
+		o = PyObject_CallFunctionObjArgs(hook, module, NULL);
+		if (o == NULL) {
+			goto error;
+		}
+		Py_DECREF(o);
+	}
+
+	status = 0;
+error:
+	Py_XDECREF(mod_name);
+	Py_XDECREF(hooks);
+	Py_XDECREF(it);
+	Py_XDECREF(registry);
+	if (status == -1)
+		return NULL;
+	else
+		return module;
+}
+
+PyObject *
+PyImport_RegisterPostImportHook(PyObject *callable, PyObject *mod_name)
+{
+	PyObject *registry, *hooks;
+
+	if (!PyCallable_Check(callable)) {
+		PyErr_SetString(PyExc_TypeError, expected callable);
+		return NULL;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyErr_SetString(PyExc_TypeError, expected string);
+		return NULL;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL)
+		return NULL;
+
+	hooks = PyObject_GetItem(registry, mod_name);
+	/* module already loaded, fire hook immediately */
+	if (hooks == Py_None) {
+		PyObject *o, *module, *modules;
+
+		Py_DECREF(registry);
+
+		modules = PySys_GetObject(modules);
+		if (modules == NULL)
+			return NULL;
+		module = PyObject_GetItem(modules, mod_name);
+		if (module == NULL)
+			return NULL;
+		
+		o = PyObject_CallFunctionObjArgs(callable, module, NULL);
+		if (o == NULL)
+			return NULL;
+		else {
+			Py_DECREF(o);
+			Py_RETURN_NONE;
+		}
+	}
+	/* no hook registered so far */
+	if (hooks == NULL) {
+		PyErr_Clear();
+		hooks = PyList_New(1);
+		if (hooks == NULL) {
+			goto error;
+		}
+		Py_INCREF(callable);
+		PyList_SET_ITEM(hooks, 0, callable);
+		if (PyObject_SetItem(registry, mod_name, hooks)  

[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Skip Montanaro added the comment:

Okay, here's my latest patch (datetime-f.diff).  2.6 only at this point.

Added file: http://bugs.python.org/file8901/datetime-f.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__Index: Doc/library/datetime.rst
===
--- Doc/library/datetime.rst(revision 59441)
+++ Doc/library/datetime.rst(working copy)
@@ -1491,10 +1491,32 @@
 be used, as time objects have no such values.  If they're used anyway, ``1900``
 is substituted for the year, and ``0`` for the month and day.
 
-For :class:`date` objects, the format codes for hours, minutes, and seconds
-should not be used, as :class:`date` objects have no such values.  If they're
-used anyway, ``0`` is substituted for them.
+For :class:`date` objects, the format codes for hours, minutes, seconds, and
+fractions of sections should not be used, as :class:`date` objects have no
+such values.  If they're used anyway, ``0`` is substituted for them.
 
+:class:`time` and :class:`datetime` objects support a ``%f`` format code
+which expands to the number of microseconds in the object, zero-padded on
+the left to six places.
+
+.. versionadded:: 2.6
+
+For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
+strings.
+
+For an aware object:
+
+``%z``
+   :meth:`utcoffset` is transformed into a 5-character string of the form 
+HHMM or
+   -HHMM, where HH is a 2-digit string giving the number of UTC offset hours, 
and
+   MM is a 2-digit string giving the number of UTC offset minutes.  For 
example, if
+   :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is
+   replaced with the string ``'-0330'``.
+
+``%Z``
+   If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty string.
+   Otherwise ``%Z`` is replaced by the returned value, which must be a string.
+
 The full set of format codes supported varies across platforms, because Python
 calls the platform C library's :func:`strftime` function, and platform
 variations are common.  
Index: Lib/_strptime.py
===
--- Lib/_strptime.py(revision 59441)
+++ Lib/_strptime.py(working copy)
@@ -22,7 +22,7 @@
 except:
 from dummy_thread import allocate_lock as _thread_allocate_lock
 
-__all__ = ['strptime']
+__all__ = []
 
 def _getlang():
 # Figure out what the current language is set to.
@@ -190,6 +190,7 @@
 base.__init__({
 # The  \d part of the regex is to make %c from ANSI C work
 'd': r(?Pd3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9]),
+'f': r(?Pf[0-9]{1,6}),
 'H': r(?PH2[0-3]|[0-1]\d|\d),
 'I': r(?PI1[0-2]|0[1-9]|[1-9]),
 'j': 
r(?Pj36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9]),
@@ -291,7 +292,7 @@
 return 1 + days_to_week + day_of_week
 
 
-def strptime(data_string, format=%a %b %d %H:%M:%S %Y):
+def _strptime(data_string, format=%a %b %d %H:%M:%S %Y):
 Return a time struct based on the input string and the format string.
 global _TimeRE_cache, _regex_cache
 with _cache_lock:
@@ -327,7 +328,7 @@
   data_string[found.end():])
 year = 1900
 month = day = 1
-hour = minute = second = 0
+hour = minute = second = fraction = 0
 tz = -1
 # Default to -1 to signify that values not known; not critical to have,
 # though
@@ -384,6 +385,11 @@
 minute = int(found_dict['M'])
 elif group_key == 'S':
 second = int(found_dict['S'])
+elif group_key == 'f':
+s = found_dict['f']
+# Pad to always return microseconds.
+s += 0 * (6 - len(s))
+fraction = int(s)
 elif group_key == 'A':
 weekday = locale_time.f_weekday.index(found_dict['A'].lower())
 elif group_key == 'a':
@@ -440,6 +446,9 @@
 day = datetime_result.day
 if weekday == -1:
 weekday = datetime_date(year, month, day).weekday()
-return time.struct_time((year, month, day,
- hour, minute, second,
- weekday, julian, tz))
+return (time.struct_time((year, month, day,
+  hour, minute, second,
+  weekday, julian, tz)), fraction)
+
+def _strptime_time(data_string, format=%a %b %d %H:%M:%S %Y):
+return _strptime(data_string, format)[0]
Index: Lib/test/test_strptime.py
===
--- Lib/test/test_strptime.py   (revision 59441)
+++ Lib/test/test_strptime.py   (working copy)
@@ -208,11 +208,11 @@
 
 def test_ValueError(self):
 # Make sure ValueError is raised when match fails or format is bad
-self.assertRaises(ValueError, _strptime.strptime, data_string=%d,
+self.assertRaises(ValueError, 

[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Changes by Skip Montanaro:


Removed file: http://bugs.python.org/file8438/dt-26.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Skip Montanaro added the comment:

Actually, I think I will avoid the 3.0 patch altogether and let these
changes propagate from trunk to py3k by whoever works that magic.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1677872] Efficient reverse line iterator

2007-12-09 Thread Mark Russell

Mark Russell added the comment:

Here's an updated version of the patch.  Changes:

- Updated to work against current py3k branch (r59441)
- Added support for universal newlines
- Added unit tests
- Added docs

The patch includes documentation for reversed() and __reversed__() (in the 
library and reference manuals respectively) which are independent of the 
reverse lines iterator - I can split those out to separate patch if needed.

I also updated the expected output from test_profile and test_cProfile, 
although I think a better fix would be to filter out the stdlib-related stuff 
from the expected output, as currently these tests break whenever io.py is 
changed.

Added file: http://bugs.python.org/file8902/reverse-file-iterator-20071209.diff

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1677872
_Index: Doc/reference/datamodel.rst
===
--- Doc/reference/datamodel.rst (revision 59439)
+++ Doc/reference/datamodel.rst (working copy)
@@ -1662,12 +1662,27 @@
Iterator objects also need to implement this method; they are required to 
return
themselves.  For more information on iterator objects, see :ref:`typeiter`.
 
+.. method:: object.__reversed__(self)
+
+   Called (if present) by the :func:`reversed()` builtin to implement
+   reverse iteration.  It should return a new iterator object that iterates
+   over all the objects in the container in reverse order.
+
+   If the :meth:`__reversed__()` method is not provided, the
+   :func:`reversed()` builtin will fall back to using the sequence protocol
+   (:meth:`__len__()` and :meth:`__getitem__()`). Objects should normally
+   only provide :meth:`__reversed__()` if they do not support the sequence
+   protocol and an efficient implementation of reverse iteration is possible.
+   
 The membership test operators (:keyword:`in` and :keyword:`not in`) are 
normally
 implemented as an iteration through a sequence.  However, container objects can
 supply the following special method with a more efficient implementation, which
 also does not require the object be a sequence.
 
 
+
+
+
 .. method:: object.__contains__(self, item)
 
Called to implement membership test operators.  Should return true if 
*item* is
Index: Doc/library/stdtypes.rst
===
--- Doc/library/stdtypes.rst(revision 59439)
+++ Doc/library/stdtypes.rst(working copy)
@@ -1937,7 +1937,16 @@
right.  However, using :meth:`seek` to reposition the file to an absolute
position will flush the read-ahead buffer.
 
+.. method:: file.__reversed__()
 
+   Return a new iterator that returns lines in reverse order (but without
+   reading the entire file into memory first).  Normally called via the
+   :func:`reversed()` builtin, as in ``for line in reversed(f): print(line)``.
+   Useful for scanning backwards through large files without reading the
+   entire file first.  Note that this changes the current position of the
+   underlying file object, so you should not interleave use of reverse and
+   forward iteration over the same file object.
+
 .. method:: file.read([size])
 
Read at most *size* bytes from the file (less if the read hits EOF before
Index: Doc/library/functions.rst
===
--- Doc/library/functions.rst   (revision 59439)
+++ Doc/library/functions.rst   (working copy)
@@ -869,8 +869,9 @@
 
 .. function:: reversed(seq)
 
-   Return a reverse :term:`iterator`.  *seq* must be an object which supports
-   the sequence protocol (the :meth:`__len__` method and the 
:meth:`__getitem__`
+   Return a reverse :term:`iterator`.  *seq* must be an object which has
+   a :meth:`__reversed__` method [#]_ or supports the sequence protocol
+   (the :meth:`__len__` method and the :meth:`__getitem__`
method with integer arguments starting at ``0``).
 
 
@@ -1099,6 +1100,8 @@
any I/O has been performed, and there's no reliable way to determine whether
this is the case.
 
+.. [#] See :ref:`sequence-types`
+
 .. [#] In the current implementation, local variable bindings cannot normally 
be
affected this way, but variables retrieved from other scopes (such as 
modules)
can be.  This may change.
Index: Lib/io.py
===
--- Lib/io.py   (revision 59439)
+++ Lib/io.py   (working copy)
@@ -1136,6 +1136,125 @@
)[self.seennl]
 
 
+class TextIOReverseIterator:
+Line-based reverse iterator wrapper for IOBase objects.
+
+This class is used to implement TextIOWrapper.__reversed__().
+It searches backwards for encoded line terminator, which
+works for UTF-8 but not for encodings where one character encoding
+can be a substring of another longer one.
+
+
+# XXX Should we check for encodings

[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Changes by Skip Montanaro:


Removed file: http://bugs.python.org/file8439/dt-30.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Changes by Skip Montanaro:


Removed file: http://bugs.python.org/file8901/datetime-f.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Christian Heimes

Christian Heimes added the comment:

Updates:

* Moved dictobject.c:unicode_eq() to unicodeobject.c:_PyUnicode_Eq()
* Added another optimization step to _PyUnicode_Eq(). The hash is
required later anyway and comparing two hashes is much faster than
memcmp-ing the unicode objects.
if (unicode_hash(a) != unicode_hash(b))
return 0;
* Factored out the ((PyUnicodeObject *) v)-hash optimization into a
function object.c:_PyObject_HashFast() which does the trick for
PyUnicode and PyString. The trick was used a couple of times in
dictobject.c and setobject.c. We may even think about moving the trick
to PyObject_Hash() directly.

Added file: http://bugs.python.org/file8904/py3k_optimize_set_unicode2.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__Index: Include/unicodeobject.h
===
--- Include/unicodeobject.h	(Revision 59441)
+++ Include/unicodeobject.h	(Arbeitskopie)
@@ -1330,6 +1330,11 @@
 const char *right
 );
 
+PyAPI_FUNC(int) _PyUnicode_Eq(
+PyObject *left,		/* Left string */
+PyObject *right		/* Right string */
+);
+
 /* Rich compare two strings and return one of the following:
 
- NULL in case an exception was raised
Index: Include/object.h
===
--- Include/object.h	(Revision 59441)
+++ Include/object.h	(Arbeitskopie)
@@ -473,6 +473,8 @@
 /* Helpers for hash functions */
 PyAPI_FUNC(long) _Py_HashDouble(double);
 PyAPI_FUNC(long) _Py_HashPointer(void*);
+/* Optimized version for setobject.c and dictobject.c */
+PyAPI_FUNC(long) _PyObject_HashFast(PyObject *);
 
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) PyUnicode_AsString(PyObject_Repr(obj))
Index: Objects/object.c
===
--- Objects/object.c	(Revision 59441)
+++ Objects/object.c	(Arbeitskopie)
@@ -754,7 +754,22 @@
 #endif
 }
 
+long
+_PyObject_HashFast(register PyObject *v)
+{
+	register long hash = -1;
 
+	if (PyUnicode_CheckExact(v))
+		hash = ((PyUnicodeObject *) v)-hash;
+	else if (PyString_CheckExact(v))
+		hash = ((PyStringObject *) v)-ob_shash;
+
+	if (hash == -1)
+		return PyObject_Hash(v);
+	else
+		return hash;
+}
+
 long
 PyObject_Hash(PyObject *v)
 {
Index: Objects/dictobject.c
===
--- Objects/dictobject.c	(Revision 59441)
+++ Objects/dictobject.c	(Arbeitskopie)
@@ -327,32 +327,13 @@
 	return 0;
 }
 
-/* Return 1 if two unicode objects are equal, 0 if not. */
-static int
-unicode_eq(PyObject *aa, PyObject *bb)
-{
-	PyUnicodeObject *a = (PyUnicodeObject *)aa;
-	PyUnicodeObject *b = (PyUnicodeObject *)bb;
-
-	if (a-length != b-length)
-		return 0;
-	if (a-length == 0)
-		return 1;
-	if (a-str[0] != b-str[0])
-		return 0;
-	if (a-length == 1)
-		return 1;
-	return memcmp(a-str, b-str, a-length * sizeof(Py_UNICODE)) == 0;
-}
-
-
 /*
  * Hacked up version of lookdict which can assume keys are always
  * unicodes; this assumption allows testing for errors during
  * PyObject_RichCompareBool() to be dropped; unicode-unicode
  * comparisons never raise exceptions.  This also means we don't need
  * to go through PyObject_RichCompareBool(); we can always use
- * unicode_eq() directly.
+ * _PyUnicode_Eq() directly.
  *
  * This is valuable because dicts with only unicode keys are very common.
  */
@@ -384,7 +365,7 @@
 	if (ep-me_key == dummy)
 		freeslot = ep;
 	else {
-		if (ep-me_hash == hash  unicode_eq(ep-me_key, key))
+		if (ep-me_hash == hash  _PyUnicode_Eq(ep-me_key, key))
 			return ep;
 		freeslot = NULL;
 	}
@@ -399,7 +380,7 @@
 		if (ep-me_key == key
 		|| (ep-me_hash == hash
 		 ep-me_key != dummy
-			 unicode_eq(ep-me_key, key)))
+			 _PyUnicode_Eq(ep-me_key, key)))
 			return ep;
 		if (ep-me_key == dummy  freeslot == NULL)
 			freeslot = ep;
@@ -588,16 +569,11 @@
 	PyThreadState *tstate;
 	if (!PyDict_Check(op))
 		return NULL;
-	if (!PyUnicode_CheckExact(key) ||
-	(hash = ((PyUnicodeObject *) key)-hash) == -1)
-	{
-		hash = PyObject_Hash(key);
-		if (hash == -1) {
-			PyErr_Clear();
-			return NULL;
-		}
+	hash = _PyObject_HashFast(key);
+	if (hash == -1) {
+		PyErr_Clear();
+		return NULL;
 	}
-
 	/* We can arrive here with a NULL tstate during initialization:
 	   try running python -Wi for an example related to string
 	   interning.  Let's just hope that no exception occurs then... */
@@ -637,15 +613,10 @@
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	if (!PyUnicode_CheckExact(key) ||
-	(hash = ((PyUnicodeObject *) key)-hash) == -1)
-	{
-		hash = PyObject_Hash(key);
-		if (hash == -1) {
-			return NULL;
-		}
+	hash = _PyObject_HashFast(key);
+	if (hash == -1) {
+		return NULL;
 	}
-
 	ep = (mp-ma_lookup)(mp, key, hash);
 	if (ep == NULL)
 		return NULL;
@@ -672,12 +643,9 @@
 	assert(key);
 	

[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file8899/py3k_optimize_set_unicode.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1576] First draft of a post import hook

2007-12-09 Thread Phillip J. Eby

Phillip J. Eby added the comment:

It also needs to hold the import lock during both the register and 
notify operations.  In addition, the notify operation needs to be 
exposed for calling from Python (so that lazy module implementations 
can interop).  Finally, it's not clear to me whether there's any way 
one of the import APIs can exit with the module added to sys.modules, 
but *without* the notify operation being called.  It seems to me that 
those code paths were cleared up in 2.4 (i.e. failure to import 
causes the module to be removed from sys.modules), but it might be 
good to doublecheck that.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1576
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1573] Improper use of the keyword-only syntax makes the parser crash

2007-12-09 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Committed revision 59443.

--
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1573
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Which is the common case in Py3k, to have strings or unicode?  By 
trying to catch both, you slow down the optimization.  Also, the 
new hash_fast introduces function call overhead in previously in-
lined code.

My preference is to knock-out the optimization or leave in the way it 
is.  Remember, strings already cache their hash codes and that 
optimization is being short-circuited here.

For sets, I prefer the code to be left as it is.  For dicts, whatever 
you do, don't slow-down the common case of regular attribute lookup.  
This is some of the most time critical code in the language.  Trying to 
generalize the optimization, make actually make it slower.

If unicode strings are the norm and an not PyString_Objects, then 
switch to that one, but I don't think you should try to do both.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-09 Thread Ingemar Nilsson

New submission from Ingemar Nilsson:

If you use shutil.move(src, dst) to move a file src to a directory dst,
the file will not be renamed into the dst directory, but rather
copied-then-removed, even if src and dst is on the same filesystem.
There are several ways to fix this:

* (The easiest) Fix the documentation for shutil.move() so that this is
mentioned.
* Fix shutil.move() so that it rename a file into a new directory.
* Change os.rename() to accept a directory as a destination for a file.

The reason for this problem is that shutil.move() tries to use
os.rename(), but fails since the destination is a directory. It then
proceeds to the copy-then-remove method, even though the documentation
gives the impression that this only happens when src and dst are on
different filesystems.

--
components: Library (Lib)
messages: 58332
nosy: init
severity: normal
status: open
title: shutil.move() does not use os.rename() if dst is a directory
type: behavior
versions: Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1577
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Christian Heimes

Changes by Christian Heimes:


Added file: http://bugs.python.org/file8905/py3k_optimize_set_unicode3.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1576] First draft of a post import hook

2007-12-09 Thread Christian Heimes

Christian Heimes added the comment:

I've moved the result = PyImport_NotifyPostImport(result); inside the
protected block. It's now protected by the import lock. I've also added
the lock protection to the register function.

The notify method is now exposed through the imp module, too.

I've checked multiple code paths. They all end up in 
PyImport_ImportModuleLevel(): builtins.__import__(), PyImport_Import(),
PyImport_ImportModule(). Only PyImport_ImportFrozenModule() doesn't use
the code path in imp_init_frozen().

Added file: http://bugs.python.org/file8906/py3k_post_import_hook2.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1576
__Index: Python/import.c
===
--- Python/import.c	(Revision 59442)
+++ Python/import.c	(Arbeitskopie)
@@ -161,7 +161,7 @@
 void
 _PyImportHooks_Init(void)
 {
-	PyObject *v, *path_hooks = NULL, *zimpimport;
+	PyObject *v, *path_hooks = NULL, *zimpimport, *pihr;
 	int err = 0;
 
 	/* adding sys.path_hooks and sys.path_importer_cache, setting up
@@ -198,6 +198,14 @@
 			  );
 	}
 
+	pihr = PyDict_New();
+	if (pihr == NULL ||
+PySys_SetObject(post_import_hooks, pihr) != 0) {
+		PyErr_Print();
+		Py_FatalError(initialization of post import hook registry 
+			  failed);
+	}
+
 	zimpimport = PyImport_ImportModule(zipimport);
 	if (zimpimport == NULL) {
 		PyErr_Clear(); /* No zip import module -- okay */
@@ -623,6 +631,201 @@
 			  sys.modules failed);
 }
 
+/* post import hook API */
+PyObject *
+PyImport_GetPostImportHooks(void)
+{
+	PyObject *pihr;
+
+	pihr = PySys_GetObject(post_import_hooks);
+	/* This should only happen during initialization */
+	if (pihr == NULL)
+		return NULL;
+
+	if (!PyDict_Check(pihr)) {
+		PyErr_SetString(PyExc_TypeError,
+post import registry is not a dict);
+	}
+
+	Py_INCREF(pihr);
+	return pihr;
+}
+
+PyObject *
+PyImport_NotifyPostImport(PyObject *module)
+{
+	static PyObject *name = NULL;
+	PyObject *mod_name = NULL, *registry = NULL, *o;
+	PyObject *hooks = NULL, *hook, *it = NULL;
+	int status = -1;
+
+	if (module == NULL)
+		return NULL;
+	if (!PyModule_Check(module)) {
+		PyErr_Format(PyExc_TypeError,
+			 A module object was expected, got '%.200s',
+			 Py_Type(module)-tp_name);
+		return NULL;
+	}
+
+	if (!PyModule_IsLoaded(module)) {
+		/* nothing to do here */
+		return module;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		/* This should only happen during initialization */
+		return module;
+	}
+
+	if (name == NULL) {
+		name = PyUnicode_InternFromString(__name__);
+		if (name == NULL)
+			return NULL;
+	}
+
+	mod_name = PyObject_GetAttr(module, name);
+	if (mod_name == NULL) {
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyObject *repr;
+		char *name;
+
+		repr = PyObject_Repr(module);
+		name = repr ? PyUnicode_AsString(repr) : unknown;
+		PyErr_Format(PyExc_TypeError,
+			 Module __name__ attribute of '%.200s' is not 
+			 string, name);
+		Py_XDECREF(repr);
+		goto error;
+	}
+
+	hooks = PyObject_GetItem(registry, mod_name);
+	if (hooks == NULL || hooks == Py_None) {
+		/* Either no hooks are defined or they are already fired */
+		if (hooks == NULL) {
+			PyErr_Clear();
+		}
+		Py_DECREF(mod_name);
+		Py_DECREF(registry);
+		return module;
+	}
+	if (!PyList_Check(hooks)) {
+		PyErr_Format(PyExc_TypeError,
+			 expected None or list of hooks, got '%.200s',
+			 Py_Type(hooks)-tp_name);
+		goto error;
+	}
+
+	it = PyObject_GetIter(hooks);
+	if (it == NULL) {
+		goto error;
+	}
+	while ((hook = PyIter_Next(it)) != NULL) {
+		o = PyObject_CallFunctionObjArgs(hook, module, NULL);
+		if (o == NULL) {
+			goto error;
+		}
+		Py_DECREF(o);
+	}
+
+/* end: */
+	status = 0;
+error:
+	Py_XDECREF(mod_name);
+	Py_XDECREF(hooks);
+	Py_XDECREF(it);
+	Py_XDECREF(registry);
+	if (status  0)
+		return NULL;
+	else
+		return module;
+}
+
+PyObject *
+PyImport_RegisterPostImportHook(PyObject *callable, PyObject *mod_name)
+{
+	PyObject *registry, *hooks;
+	int status = -1;
+
+	if (!PyCallable_Check(callable)) {
+		PyErr_SetString(PyExc_TypeError, expected callable);
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyErr_SetString(PyExc_TypeError, expected string);
+		goto error;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL)
+		goto error;
+
+	lock_import();
+
+	hooks = PyObject_GetItem(registry, mod_name);
+	/* module already loaded, fire hook immediately */
+	if (hooks == Py_None) {
+		PyObject *o, *module, *modules;
+
+		modules = PySys_GetObject(modules);
+		if (modules == NULL)
+			goto error;
+		module = PyObject_GetItem(modules, mod_name);
+		if (module == NULL)
+			goto error;
+		
+		o = PyObject_CallFunctionObjArgs(callable, module, NULL);
+		if (o == NULL)
+			goto error;
+		else {
+			Py_DECREF(o);
+			goto end;
+		}
+	}
+	/* no hook registered so far */
+	if 

[issue1576] First draft of a post import hook

2007-12-09 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file8900/py3k_post_import_hook.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1576
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Okay, then simply go back to the unaltered existing code and replace 
references to PyString with PyUnicode. Skip all the macros, new 
functions, factorings, etc.  Just change strings to unicode and be done 
with it.  IIRC, that was what was done for dicts.  Just do the same for 
sets and not try to get tricky with a new, misnamed C API function like 
PyObject_Hash().

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1202] zlib.crc32() and adler32() return value

2007-12-09 Thread Tim Lesher

Tim Lesher added the comment:

Both CRC-32 and ADLER32 are standards (described in ISO 3309 and RFC
1950 respectively); whatever fix implemented should make sure that the
output complies.  

ISO 3309 isn't available online as far as I can see, but CRC-32
reference code is published in RFC 1952; RFC 1950 contains reference
code for ADLER32.

--
nosy: +tlesher

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1202
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-09 Thread Christian Heimes

Christian Heimes added the comment:

The latest patch does *NOT* add new macros, functions or other stuff. I
simply replaced PyString_* with PyUnicode_* in setobject.c where
appropriate.

The only function I had to factor out is unicode_eq(). It's now in a new
file stringlib/eq.h which is included by setobject.c and dictobject.c.
It's the only way to share the function while keeping it static and
maybe inline.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1564
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1578] Problems in win_getpass

2007-12-09 Thread vizcayno

New submission from vizcayno:

.python
Python 3.0a2 (r30a2:59397:59399, Dec  6 2007, 22:34:52) [MSC v.1500 32 
bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 import getpass
 clave = getpass.getpass('PASSWD= ').strip().upper()
PASSWD= Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\python30\lib\getpass.py, line 63, in win_getpass
pw = pw + c
TypeError: Can't convert 'bytes' object to str implicitly

 I get the error when I try to type the first letter of a password.

--
components: Windows
messages: 58338
nosy: vizcayno
severity: normal
status: open
title: Problems in win_getpass
type: crash
versions: Python 3.0

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1578
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1158] %f format for datetime objects

2007-12-09 Thread Skip Montanaro

Skip Montanaro added the comment:

Stop me before I update it again!  This update touches up
datetime_strptime a bit.  It's more uniform and a bit faster.

Added file: http://bugs.python.org/file8907/datetime-f.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1158
__Index: Doc/library/datetime.rst
===
--- Doc/library/datetime.rst(revision 59446)
+++ Doc/library/datetime.rst(working copy)
@@ -1491,10 +1491,32 @@
 be used, as time objects have no such values.  If they're used anyway, ``1900``
 is substituted for the year, and ``0`` for the month and day.
 
-For :class:`date` objects, the format codes for hours, minutes, and seconds
-should not be used, as :class:`date` objects have no such values.  If they're
-used anyway, ``0`` is substituted for them.
+For :class:`date` objects, the format codes for hours, minutes, seconds, and
+microseconds should not be used, as :class:`date` objects have no such
+values.  If they're used anyway, ``0`` is substituted for them.
 
+:class:`time` and :class:`datetime` objects support a ``%f`` format code
+which expands to the number of microseconds in the object, zero-padded on
+the left to six places.
+
+.. versionadded:: 2.6
+
+For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
+strings.
+
+For an aware object:
+
+``%z``
+   :meth:`utcoffset` is transformed into a 5-character string of the form 
+HHMM or
+   -HHMM, where HH is a 2-digit string giving the number of UTC offset hours, 
and
+   MM is a 2-digit string giving the number of UTC offset minutes.  For 
example, if
+   :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is
+   replaced with the string ``'-0330'``.
+
+``%Z``
+   If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty string.
+   Otherwise ``%Z`` is replaced by the returned value, which must be a string.
+
 The full set of format codes supported varies across platforms, because Python
 calls the platform C library's :func:`strftime` function, and platform
 variations are common.  
@@ -1526,6 +1548,10 @@
 | ``%d``| Day of the month as a decimal  |   |
 |   | number [01,31].|   |
 +---++---+
+| ``%f``| Microsecond as a decimal   | \(1)  |
+|   | number [0,99], zero-padded |   |
+|   | on the left|   |
++---++---+
 | ``%H``| Hour (24-hour clock) as a  |   |
 |   | decimal number [00,23].|   |
 +---++---+
@@ -1541,13 +1567,13 @@
 | ``%M``| Minute as a decimal number |   |
 |   | [00,59].   |   |
 +---++---+
-| ``%p``| Locale's equivalent of either  | \(1)  |
+| ``%p``| Locale's equivalent of either  | \(2)  |
 |   | AM or PM.  |   |
 +---++---+
-| ``%S``| Second as a decimal number | \(2)  |
+| ``%S``| Second as a decimal number | \(3)  |
 |   | [00,61].   |   |
 +---++---+
-| ``%U``| Week number of the year| \(3)  |
+| ``%U``| Week number of the year| \(4)  |
 |   | (Sunday as the first day of|   |
 |   | the week) as a decimal number  |   |
 |   | [00,53].  All days in a new|   |
@@ -1558,7 +1584,7 @@
 | ``%w``| Weekday as a decimal number|   |
 |   | [0(Sunday),6]. |   |
 +---++---+
-| ``%W``| Week number of the year| \(3)  |
+| ``%W``| Week number of the year| \(4)  |
 |   | (Monday as the first day of|   |
 |   | the week) as a decimal number  |   |
 |   | [00,53].  All days in a new|   |
@@ -1578,7 +1604,7 @@
 | ``%Y``| Year with century as a decimal |   |
 |   | number.|   |
 +---++---+
-| ``%z``| UTC offset in the form +HHMM   | \(4)  |
+| ``%z``| UTC offset in the form +HHMM   | \(5)  |
 |   | or -HHMM (empty string if the  |   |
 |   | the object is naive).  |   |
 +---++---+
@@ -1591,17 +1617,22 @@
 Notes:
 
 (1)
+   When used with the :func:`strptime` function, the ``%f`` directive
+   accepts from one to six digits and zero pads on the right.  ``%f`` is
+   an extension to the set of format characters in the C standard.
+
+(2)
When used with the :func:`strptime` function, the ``%p`` directive only 
affects
the output hour field if the 

[issue1597850] Cross compiling patches for MINGW

2007-12-09 Thread John Stowers

John Stowers added the comment:

Hello, 

I recently tried this in combination with jhbuild, cross compiling with
mingw (to built some python gtk extensions). I tried you patch against
the 2.5.1 version and recieved the following error:

checking for /dev/ptmx... yes
checking for /dev/ptc... no
checking for %zd printf() format support... configure: error: cannot run
test program while cross compiling
See `config.log' for more details.
*** error during stage configure of python25: ## Error running
./configure --prefix /home/john/jhbuild/win32/build/  
--build=i686-pc-linux-gnuaout --host=i586-pc-mingw32msvc
--target=i586-pc-mingw32msvc --disable-docs --enable-all-warnings 
AR=/usr/bin/i586-mingw32msvc-ar 
RANLIB=/usr/bin/i586-mingw32msvc-ranlib 
STRIP=/usr/bin/i586-mingw32msvc-strip 
AS=/usr/bin/i586-mingw32msvc-as 
DLLTOOL=/usr/bin/i586-mingw32msvc-dlltool 
OBJDUMP=/usr/bin/i586-mingw32msvc-objdump 
NM=/usr/bin/i586-mingw32msvc-nm 
WINDRES=/usr/bin/i586-mingw32msvc-windres  *** [1/1]

I noticed that the other reference for cross compiling pthon 2.5 at
http://whatschrisdoing.com/blog/2006/10/06/howto-cross-compile-python-25/
patched this check out

--
nosy: +nzjrs

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1597850
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1597850] Cross compiling patches for MINGW

2007-12-09 Thread John Stowers

John Stowers added the comment:

Sorry, I should have clarified further in my last comment. Looking over
the configure script I don't recognize the %zd test as one that could be
circumvented by supplying a config.cache file with the appropriate values.

How do I escape this limitation?

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1597850
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1597850] Cross compiling patches for MINGW

2007-12-09 Thread Scott Tsai

Scott Tsai added the comment:

John,
set ac_cv_printf_zd_format.
In general, read the configure.in source.

On Dec 10, 2007 1:17 PM, John Stowers [EMAIL PROTECTED] wrote:

 John Stowers added the comment:

 Sorry, I should have clarified further in my last comment. Looking over
 the configure script I don't recognize the %zd test as one that could be
 circumvented by supplying a config.cache file with the appropriate values.

 How do I escape this limitation?


 _
 Tracker [EMAIL PROTECTED]
 http://bugs.python.org/issue1597850
 _


_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1597850
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com