[issue1644] Patch submission guidelines outdated

2007-12-21 Thread Georg Brandl

Georg Brandl added the comment:

That page is outdated, the new URL is python.org/dev/patches.
I'll notify the website maintainers to remove/redirect the old URL.

--
resolution:  -> fixed
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



[issue1497] Patch to remove API to create new unbound methods

2007-12-21 Thread Georg Brandl

Georg Brandl added the comment:

As far as I can see, not really.

--
status: pending -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue1678] description of startswith is confused

2007-12-21 Thread MATSUI Tetsushi

New submission from MATSUI Tetsushi:

In the Library Reference 3.6.1 String Method, the description of
startswith is confused with endswith.  It says:
  prefix can also be a tuple of suffixes to look for.
Here, "suffixes" means "prefixes".

Note: This part is new for 2.5.

--
components: Documentation
messages: 58937
nosy: mft
severity: normal
status: open
title: description of startswith is confused
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file9014/trunk_select_epoll_kqueue2.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1677] Ctrl-C will exit out of Python interpreter in Windows

2007-12-21 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

I get the same behaviour with python 2.5.1, and even 2.4.4 (on Windows
2000): I hold down Ctrl-C, and after ~30 "KeyboardInterrupt", the
interpreter stops.

So this is not 3.0 specific. What is new in python3.0 is that file
objects are implemented in python, and are much slower.
It is possible that when the key buffer is full, the next Ctrl-C kills
the program. And this is more likely to happen with python3.0.

--
nosy: +amaury.forgeotdarc

__
Tracker <[EMAIL PROTECTED]>

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



[issue1677] Ctrl-C will exit out of Python interpreter in Windows

2007-12-21 Thread Christian Heimes

Christian Heimes added the comment:

I don't think it's a critical bug but it may be worth to debug it.

--
keywords: +py3k
nosy: +tiran
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file9010/trunk_select_epoll_kqueue.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file9017/trunk_select_epoll_kqueue3.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1678] description of startswith is confused

2007-12-21 Thread Christian Heimes

Changes by Christian Heimes:


--
assignee:  -> georg.brandl
nosy: +georg.brandl
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Thomas Herve

Thomas Herve added the comment:

Here I go for kqueue:
 * the docstring of test_kqueue.py is wrong
 * the tests are a bit light. It would be good the have a test like
test_control_and_wait in test_epoll.
 * the kqueue_queue_control (and the pyepoll_poll) are now completely
wrong! You should not limit to FD_SETSIZE, these 2 systems are there
because they're able to handle for fds than that. Also, this buffer
thing looks like a premature optimization. I'm unable to tell if it's
correct or not.
 * the NETDEV and related flags aren't defined under OS X 10.4. I guess
there are flags for freebsd, but kqueue should build on OS X too.

I've been able to use this module for the twisted reactor, so the
functionality is OK. But thsi FD_SETSIZE limit is a huge problem.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file9018/trunk_select_epoll_kqueue4.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1680] what is decimal.Context.get_manager()?

2007-12-21 Thread MATSUI Tetsushi

New submission from MATSUI Tetsushi:

In the section Context Manager Types of the Library reference, the
__enter__ method of context management protocol is explained as:
  An example of a context manager that returns a related object is
  the one returned by decimal.Context.get_manager(). 
But I can't find anything about decimal.Context.get_manager().
Does it mean decimal.localcontext()?

--
components: Documentation
messages: 58945
nosy: mft
severity: normal
status: open
title: what is decimal.Context.get_manager()?
versions: Python 2.5, Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1678] description of startswith is confused

2007-12-21 Thread Georg Brandl

Georg Brandl added the comment:

This is already fixed in SVN and will be live with the next docs update.
Thanks for reporting!

--
resolution:  -> out of date
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



[issue1679] tokenizer permits invalid hex integer

2007-12-21 Thread Martin Rinehart

New submission from Martin Rinehart:

The tokenizer accepts '0x' as an integer zero. The documentation says:
   hexinteger ::= 0x|Xhexdigit+

Stumbled on this testing a tokenizer I wrote in Python for another
language. Expected an Error on "int( '0x', 16 )", but didn't get one.

--
components: Interpreter Core
messages: 58943
nosy: MartinRinehart
severity: normal
status: open
title: tokenizer permits invalid hex integer
type: compile error
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1555570] email parser incorrectly breaks headers with a CRLF at 8192

2007-12-21 Thread Karen Tracey

Changes by Karen Tracey:


--
nosy: +kmtracey

_
Tracker <[EMAIL PROTECTED]>

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



[issue1676] Fork/exec issues with Tk 8.5/Python 2.5.1 on OS X

2007-12-21 Thread Kevin Walzer

Kevin Walzer added the comment:

I already queried the Tcl-Mac mailing list about this to see if it 
should be reported as a bug against Tk. Daniel Steffen, the maintainer 
of Tcl/Tk on the Mac, thinks it may stem from Python-Tk interaction. His 
detailed reply is here:

http://www.nabble.com/Re%3A-Fork-vs.-exec-in-RC-5-of-Tk-8.5-
p14394315.html

I have not seen this error when running Tcl/Tk applications against 8.5-
-just Python-Tkinter.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Thomas Herve

Changes by Thomas Herve:


Added file: http://bugs.python.org/file9020/test_kqueue.diff

__
Tracker <[EMAIL PROTECTED]>

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



[issue1657] [patch] epoll and kqueue wrappers for the select module

2007-12-21 Thread Thomas Herve

Thomas Herve added the comment:

I attached a patch with a more complete test of kqueue. It's not that
great, but it's a thing. I've only tested on OS X, but it works.

Regarding the ability of building an epoll object from a fd, it might be
usefull in some corner cases, but that's not a priority.

exarkun looked at the patch and told me that there may be some
threadsafety issues: for example, when calling epoll_wait, you use
self->evs unprotected. It's not very important, but you may want to tell
it in the documentation.

As you started the rich comparison for kevent objects, it may be
interesting to have full comparison (to sort list of events). It's not a
high priority though.

That's all for now!

__
Tracker <[EMAIL PROTECTED]>

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



[issue1681] parameter name for optparse parse_args incorrect

2007-12-21 Thread Wichert Akkerman

New submission from Wichert Akkerman:

http://www.python.org/doc/2.4.4/lib/optparse-parsing-arguments.html
documents that second named parameter to be 'options'. This is not
correct: the actual name is 'values'.

--
components: Documentation
messages: 58948
nosy: wichert
severity: normal
status: open
title: parameter name for optparse parse_args incorrect
versions: Python 2.4, Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue1679] tokenizer permits invalid hex integer

2007-12-21 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> gvanrossum
nosy: +gvanrossum
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1680] what is decimal.Context.get_manager()?

2007-12-21 Thread Facundo Batista

Changes by Facundo Batista:


--
assignee:  -> facundobatista
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

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



[issue1675] Race condition in os.makedirs

2007-12-21 Thread Isaac Morland

Isaac Morland added the comment:

Attached is an svn diff against the trunk.  I was looking at os.py from
Python 2.5 not the trunk, and it appears that an attempt at fixing the
race condition has already been put into os.py, but I don't believe it's
correct.

The attached patch renames the existing mkdir to _mkdir, and creates a
new mkdir with an additional "excl" parameter to select
error-if-already-exists or not.  It defaults to the current behaviour. 
Similarly, makedirs gets the same extra parameter which is passed down
to mkdir.

By simply using the new versions as before, one obtains the old
behaviour unchanged except that the race condition is corrected.  By
using excl=False one gets the new behaviour.

I have updated the documentation also but I don't really know what I'm
doing there so my use of the rst format may not be right.

Added file: http://bugs.python.org/file9022/patch.txt

__
Tracker <[EMAIL PROTECTED]>

__Index: Doc/library/os.rst
===
--- Doc/library/os.rst  (revision 59590)
+++ Doc/library/os.rst  (working copy)
@@ -1007,17 +1007,20 @@
.. versionadded:: 2.3
 
 
-.. function:: mkdir(path[, mode])
+.. function:: mkdir(path[, mode[, excl=True]])
 
Create a directory named *path* with numeric mode *mode*. The default 
*mode* is
``0777`` (octal).  On some systems, *mode* is ignored.  Where it is used, 
the
current umask value is first masked out. Availability: Macintosh, Unix, 
Windows.
 
+   By default, if the directory already exists, :exc:`OSError` is thrown.  If 
excl is
+   False, it is not an error for the directory to exist already.
+
It is also possible to create temporary directories; see the
:mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
 
 
-.. function:: makedirs(path[, mode])
+.. function:: makedirs(path[, mode[, excl=True]])
 
.. index::
   single: directory; creating
@@ -1029,6 +1032,10 @@
created.  The default *mode* is ``0777`` (octal).  On some systems, *mode* 
is
ignored. Where it is used, the current umask value is first masked out.
 
+   By default, if the directory already exists, :exc:`OSError` is thrown.  If
+   excl is False, it is not an error for the directory to exist already.  It
+   is never an error for ancestor directories to exist already.
+
.. note::
 
   :func:`makedirs` will become confused if the path elements to create 
include
Index: Lib/os.py
===
--- Lib/os.py   (revision 59590)
+++ Lib/os.py   (working copy)
@@ -146,29 +146,39 @@
 
 # Super directory utilities.
 # (Inspired by Eric Raymond; the doc strings are mostly his)
+_mkdir = mkdir
 
-def makedirs(name, mode=0777):
-"""makedirs(path [, mode=0777])
+def mkdir(name, mode=0777, excl=True):
+"""mkdir(path [, mode=0777 [, excl=True]])
+
+Create the named directory in the indicated mode.  By default, if the
+directory already exists, OSError is thrown.  If excl is False, it is
+not an error for the directory to exist already.
+"""
+try:
+_mkdir(name, mode)
+except OSError, e:
+if excl or not (e.errno == errno.EEXIST and path.isdir (name)):
+raise
 
+def makedirs(name, mode=0777, excl=True):
+"""makedirs(path [, mode=0777 [, excl=True]])
+
 Super-mkdir; create a leaf directory and all intermediate ones.
 Works like mkdir, except that any intermediate path segment (not
 just the rightmost) will be created if it does not exist.  This is
-recursive.
-
+recursive.  By default, if the directory already exists, OSError is
+thrown.  If excl is False, it is not an error for the directory to exist
+already.  It is never an error for ancestor directories to exist already.
 """
 head, tail = path.split(name)
 if not tail:
 head, tail = path.split(head)
 if head and tail and not path.exists(head):
-try:
-makedirs(head, mode)
-except OSError, e:
-# be happy if someone already created the path
-if e.errno != errno.EEXIST:
-raise
+makedirs(head, mode, excl=False)
 if tail == curdir:   # xxx/newdir/. exists if xxx/newdir exists
 return
-mkdir(name, mode)
+mkdir(name, mode, excl)
 
 def removedirs(name):
 """removedirs(path)
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1675] Race condition in os.makedirs

2007-12-21 Thread Isaac Morland

Isaac Morland added the comment:

I should add that the new parameter is called "excl" by analogy with the
O_EXCL option to os.open().

Also, I'm not absolutely certain about the test for which exceptions
should be ignored when excl == False:

e.errno == errno.EEXIST and path.isdir (name)

This will not work if errno is set to something other than EEXIST when
mkdir fails due to the directory already existing.  The above works on
my system but I can't be certain that all mkdir implementations report
EEXIST.

It should be safe to drop the errno check altogether, and I'm starting
to think that we should; at present it's really just an optimization to
avoid using .isdir, but only in what should be rather uncommon
circumstances.  I think the smell of "premature optimization" may be
hard to ignore.

So the if statement would be:

if excl or not path.isdir (name):
raise

__
Tracker <[EMAIL PROTECTED]>

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



[issue1432] Strange behavior of urlparse.urljoin

2007-12-21 Thread Isaac Morland

Isaac Morland added the comment:

RFC 1808 has been obsoleted by RFC 3986:

http://tools.ietf.org/html/rfc3986

__
Tracker <[EMAIL PROTECTED]>

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



[issue1683] Thread local storage and PyGILState_* mucked up by os.fork()

2007-12-21 Thread roudkerk

New submission from roudkerk:

I got a report that one of the tests for processing
(http://cheeseshop.python.org/pypi/processing) was failing with

Fatal Python error: Invalid thread state for this thread

when run with a debug interpreter.  This appears to be caused by the
interaction between os.fork() and threads.  The following attached
program reliably reproduces the problem for me on Ubuntu edgy for x86.

All that happens is that the parent process starts a subthread then
forks, and then the child process starts a subthread.

With the normal interpreter I get

started thread -1211028576 in process 18683
I am thread -1211028576 in process 18683
started thread -1211028576 in process 18685
I am thread -1211028576 in process 18685

as expected, but with the debug interpreter I get

started thread -1210782816 in process 18687
I am thread -1210782816 in process 18687
started thread -1210782816 in process 18689
Fatal Python error: Invalid thread state for this thread
[5817 refs]

Notice that the child process is reusing a thread id that was 
being used by the parent process at the time of the fork.

The code raising the error seems to be in pystate.c:

PyThreadState *
PyThreadState_Swap(PyThreadState *new)
{
PyThreadState *old = _PyThreadState_Current;

_PyThreadState_Current = new;
/* It should not be possible for more than one thread state
   to be used for a thread.  Check this the best we can in
debug 
   builds.
*/
#if defined(Py_DEBUG) && defined(WITH_THREAD)
if (new) {
PyThreadState *check = PyGILState_GetThisThreadState();
if (check && check != new)
Py_FatalError("Invalid thread state for this
thread");
}
#endif
return old;
}

It looks as though PyGILState_GetThisThreadState() is returning the
thread state of the thread from the parent process which has the same
id as the current thread.  Therefore the check fails.

I think the thread local storage implementation in thread.c should
provide a function _PyThread_ReInitTLS() which PyOS_AfterFork() can
call.  I think _PyThread_ReInitTLS() just needs to remove and free
each "struct key" in the linked list which does not match the id of
the calling thread.

--
components: Interpreter Core
files: dbg2.py
messages: 58954
nosy: roudkerk
severity: normal
status: open
title: Thread local storage and PyGILState_* mucked up by os.fork()
type: crash
versions: Python 2.4, Python 2.5
Added file: http://bugs.python.org/file9023/dbg2.py

__
Tracker <[EMAIL PROTECTED]>

__import time, os, thread

def f():
print "I am thread %d in process %d" % (thread.get_ident(),os.getpid())
time.sleep(1)

ident = thread.start_new_thread(f, ())
print "started thread %d in process %d" % (ident, os.getpid())
time.sleep(0.5)  # give thread a chance to start

pid = os.fork()
if pid == 0:
ident = thread.start_new_thread(f, ())
print "started thread %d in process %d" % (ident, os.getpid())
time.sleep(0.5)  # give thread a chance to start
os._exit(0)

os.waitpid(pid, 0)
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1432] Strange behavior of urlparse.urljoin

2007-12-21 Thread Isaac Morland

Isaac Morland added the comment:

Issue 1637, Issue 1779700, and Issue 1462525 also relate to this problem.

--
nosy: +ijmorlan

__
Tracker <[EMAIL PROTECTED]>

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



[issue1682] Move Demo/classes/Rat.py to Lib/rational.py and fix it up.

2007-12-21 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> gvanrossum
nosy: +gvanrossum
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

2007-12-21 Thread Fazal Majid

New submission from Fazal Majid:

The CGI specification does not specify the working directory the CGI is
invoked in, but the usual behavior is to use the directory containing
the script.

CGIHTTPServer should either change working directory by default (see
patch below), or offer a hook to be called before the exec() call to the
CGI.


*** /usr/local/lib/python2.4/CGIHTTPServer.py   Tue Apr  4 11:13:23 2006
--- kCGIHTTPServer.py   Fri Dec 21 13:31:40 2007
***
*** 227,232 
--- 227,233 
  pass
  os.dup2(self.rfile.fileno(), 0)
  os.dup2(self.wfile.fileno(), 1)
+ os.chdir(os.path.dirname(scriptfile))
  os.execve(scriptfile, args, os.environ)
  except:
  self.server.handle_error(self.request,
self.client_address)

--
components: Library (Lib)
messages: 58955
nosy: majid
severity: normal
status: open
title: CGIHTTPServer does not chdir prior to executing the CGI script
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

2007-12-21 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Can you give some reference to demonstrate that this is the usual behavior?

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

2007-12-21 Thread Fazal Majid

Fazal Majid added the comment:

There isn't any normative reference that I know of, in fact the default
behavior is different on Unix and Windows.

Apache 2.2 (and most certainly older versions as well) implements this
in mod_cgi.c. The relevant lines:

/* Transmute ourselves into the script.
 * NB only ISINDEX scripts get decoded arguments.
 */
if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
((rc = apr_procattr_io_set(procattr,
   e_info->in_pipe,
   e_info->out_pipe,
   e_info->err_pipe)) != APR_SUCCESS) ||
((rc = apr_procattr_dir_set(procattr,
ap_make_dirstr_parent(r->pool,
  r->filename))) !=
APR_SUCCESS) ||



apr_procattr_dir_set sets the cwd for the child subprocess
ap_make_dirstr_parent is equivalent to os.path.dirname.

As the default behavior is system-dependent, it should not be hardcoded
but some sort of hook should provided to allow implementing either the
UNIX or Windows semantics.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1685] linecache .updatecache fails on utf8 encoded files

2007-12-21 Thread PyScripter

New submission from PyScripter:

linecache.updatecache works as follows after it finds a module name:

fp = open(fullname, 'rU')
lines = fp.readlines()
fp.close()

It then tries to detect a file encoding comment...

The problem is that readlines fails with a UnicodeDecodeError if the 
file is utf8 encoded, the preferred locale encoding is something else 
and the file contains characters that cannot be decoded.

Instead the function should:
a) read the raw data into a bytes object 
b)then search for a file encoding comment and
c)use one if found else use utf8 since this is not the default file 
encoding.

--
components: Library (Lib)
messages: 58958
nosy: pyscripter
severity: normal
status: open
title: linecache .updatecache fails on utf8 encoded files
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1686] string.Template.safe_substitute fail when overriding pattern attribute

2007-12-21 Thread Hagai Gold

Changes by Hagai Gold:


--
components: Library (Lib)
files: string.py.diff
nosy: hagaigold
severity: normal
status: open
title: string.Template.safe_substitute fail when overriding  pattern attribute
versions: Python 3.0
Added file: http://bugs.python.org/file9024/string.py.diff

__
Tracker <[EMAIL PROTECTED]>

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



[issue1686] string.Template.safe_substitute fail when overriding pattern attribute

2007-12-21 Thread Hagai Gold

New submission from Hagai Gold:

When overriding  the pattern attribute on string.Template, with your own
delimiters, exmp: change the ${..} to $@@..@@, safe_substitute method
fail to restore the new delimiters, in case of keyerror.

Problem is that the method return a specific value ==>
""" return self.delimiter + '{' + braced + '}'  """ 
I change it to be generic, with the help of the MatchObject.group() that
return the whole match.

Demonstration of the problem:

>>> from string import Template
>>> class MyTemplate(Template):
... pattern = r"""
... \$(?:
...   (?P\&) |  # Escape sequence of two
delimiters
...   (?P[_a-z][_a-z0-9]*)  | # delimiter and a Python
identifier
...   @@(?P[_a-z][_a-z0-9]*)@@ | # delimiter and a braced
identifier
...   (?P)  # Other ill-formed
delimiter exprs
... )
... """
... 
>>> b4_str = '$@@keyError@@ change the orignal string'
>>> t = MyTemplate(b4_str)
>>> res = t.safe_substitute()
>>> print res
${keyError} change the orignal string
>>> print res == b4_str
False
>>>

__
Tracker <[EMAIL PROTECTED]>

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