[issue1291] test_resource fails on recent linux systems (

2007-10-18 Thread Matthias Klose

Matthias Klose added the comment:

$ python Lib/test/test_resource.py
True
Traceback (most recent call last):
  File Lib/test/test_resource.py, line 42, in module
f.close()
IOError: [Errno 27] File too large

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



[issue1292] libffi needs an update to support mips64, arm and armeabi on linux

2007-10-18 Thread Matthias Klose

New submission from Matthias Klose:

libffi needs an update to support mips64, arm and armeabi on linux; the
current bits are all available in GCC trunk. as an alternative, those
systems should be default to --with-system-ffi, unless this is
xplicitely disabled.

--
assignee: theller
components: Extension Modules
messages: 56522
nosy: doko, theller
severity: normal
status: open
title: libffi needs an update to support mips64, arm and armeabi on linux
type: compile error
versions: Python 2.6

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



[issue1291] test_resource fails on recent linux systems (

2007-10-18 Thread Matthias Klose

New submission from Matthias Klose:

The test_resource test fails at least on all non x86 linux systems; the
test case notes:

# Now check to see what happens when the RLIMIT_FSIZE is small.  Some
# versions of Python were terminated by an uncaught SIGXFSZ, but
# pythonrun.c has been fixed to ignore that exception.  If so, the
# write() should return EFBIG when the limit is exceeded.

however instead of EFBIG errno is set to ESPIPE, causing an IOException.
and letting the test fail.

--
components: Extension Modules
files: tst.c
messages: 56520
nosy: doko
severity: normal
status: open
title: test_resource fails on recent linux systems (
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8561/tst.c

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1291
__#include signal.h
#include errno.h
#include sys/time.h
#include sys/resource.h

#include stdio.h

void catch_sigxfsz(int sig_num)
{
  signal(SIGINT, catch_sigxfsz);
  printf(catched SIGXFSZ\n);
  fflush(stdout);
}

int main()
{
  int rc, fd, i;
  struct sigaction context, ocontext;
  struct rlimit fsize;

  context.sa_handler = SIG_IGN;
  context.sa_handler = catch_sigxfsz;
  sigemptyset(context.sa_mask);
  context.sa_flags = 0;
  if (sigaction(SIGXFSZ, context, ocontext) == -1)
perror(sigaction);

  getrlimit(RLIMIT_FSIZE, fsize);
  fsize.rlim_cur = 8 * 128;
  if (setrlimit(RLIMIT_FSIZE, fsize))
perror(setrlimit);

  unlink(tstrlimit);
  fd = creat(tstrlimit, 0);
  for (i=0; i128; i++)
if (write(fd, 1234567\n, 8) == -1)
  perror(write);

  if (write(fd, 1234567\n, 1) == -1)
{
  perror(write2);
  printf(errno: %d (EFBIG=%d, ESPIPE=%d)\n, errno, EFBIG, ESPIPE);
}

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



[issue1293] Trailing slash in sys.path cause import failure

2007-10-18 Thread Guillaume Girard

New submission from Guillaume Girard:

On win32, the following code:

import sys
sys.path.append('../bar/')
import bar

where the file bar.py is present in ../bar/ will return an import error
No module named bar. Remove the trailing slash and the bar.py is
imported correctly. The problem is identical with backslash. This code
works in Python 2.4.

Not a very serious bug, but it breaks programs working with Python 2.4.

--
components: Interpreter Core
messages: 56523
nosy: guillaumegirard
severity: minor
status: open
title: Trailing slash in sys.path cause import failure
type: behavior
versions: Python 2.5

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



[issue1294] Management of KeyboardInterrupt in cmd.py

2007-10-18 Thread BULOT

New submission from BULOT:

According to me, the Ctrl-C is not managed correctly in cmd.py. Ctrl-C
generates a a KeyboardInterrupt exceptions, and only EOFError is
managed. I propose to manage KeyboardInterrupt on line 130:
   print 'are you sure you want to exit? y/n'
answer =''
while (answer != 'y')  (answer != 'n'):
answer = raw_input()
if answer == 'y':
exit(0)

Here is attached my new cmd.py
Hope ti will help.

--
components: None
files: cmd.py
messages: 56524
nosy: stephbul
severity: normal
status: open
title: Management of KeyboardInterrupt in cmd.py
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8562/cmd.py

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1294
__A generic class to build line-oriented command interpreters.

Interpreters constructed with this class obey the following conventions:

1. End of file on input is processed as the command 'EOF'.
2. A command is parsed out of each line by collecting the prefix composed
   of characters in the identchars member.
3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method
   is passed a single argument consisting of the remainder of the line.
4. Typing an empty line repeats the last command.  (Actually, it calls the
   method `emptyline', which may be overridden in a subclass.)
5. There is a predefined `help' method.  Given an argument `topic', it
   calls the command `help_topic'.  With no arguments, it lists all topics
   with defined help_ functions, broken into up to three topics; documented
   commands, miscellaneous help topics, and undocumented commands.
6. The command '?' is a synonym for `help'.  The command '!' is a synonym
   for `shell', if a do_shell method exists.
7. If completion is enabled, completing commands will be done automatically,
   and completing of commands args is done by calling complete_foo() with
   arguments text, line, begidx, endidx.  text is string we are matching
   against, all returned matches must begin with it.  line is the current
   input line (lstripped), begidx and endidx are the beginning and end
   indexes of the text being matched, which could be used to provide
   different completion depending upon which position the argument is in.

The `default' method may be overridden to intercept commands for which there
is no do_ method.

The `completedefault' method may be overridden to intercept completions for
commands that have no complete_ method.

The data member `self.ruler' sets the character used to draw separator lines
in the help messages.  If empty, no ruler line is drawn.  It defaults to =.

If the value of `self.intro' is nonempty when the cmdloop method is called,
it is printed out on interpreter startup.  This value may be overridden
via an optional argument to the cmdloop() method.

The data members `self.doc_header', `self.misc_header', and
`self.undoc_header' set the headers used for the help function's
listings of documented functions, miscellaneous topics, and undocumented
functions respectively.

These interpreters use raw_input; thus, if the readline module is loaded,
they automatically support Emacs-like command history and editing features.


import string

__all__ = [Cmd]

PROMPT = '(Cmd) '
IDENTCHARS = string.ascii_letters + string.digits + '_'

class Cmd:
A simple framework for writing line-oriented command interpreters.

These are often useful for test harnesses, administrative tools, and
prototypes that will later be wrapped in a more sophisticated interface.

A Cmd instance or subclass instance is a line-oriented interpreter
framework.  There is no good reason to instantiate Cmd itself; rather,
it's useful as a superclass of an interpreter class you define yourself
in order to inherit Cmd's methods and encapsulate action methods.


prompt = PROMPT
identchars = IDENTCHARS
ruler = '='
lastcmd = ''
intro = None
doc_leader = 
doc_header = Documented commands (type help topic):
misc_header = Miscellaneous help topics:
undoc_header = Undocumented commands:
nohelp = *** No help on %s
use_rawinput = 1

def __init__(self, completekey='tab', stdin=None, stdout=None):
Instantiate a line-oriented interpreter framework.

The optional argument 'completekey' is the readline name of a
completion key; it defaults to the Tab key. If completekey is
not None and the readline module is available, command completion
is done automatically. The optional arguments stdin and stdout
specify alternate input and output file objects; if not specified,
sys.stdin and sys.stdout are used.


import sys
if stdin is not None:
 

[issue1295] logging records cache the result of formatException()

2007-10-18 Thread Thomas Heller

New submission from Thomas Heller:

I needed two logging handlers in my application, one notifiying the user
of errors, the other writing errors to a logfile.  So I created a custom
subclass of logging.Formatter and redefined the formatException() method
that returned a summary of the exception like 'ZeroDivisionError'
instead of the full traceback.

Unfortunately the logging record caches the result of the
handler.formatException() call in the exc_text variable, and the
formatException() method of the second handler isn't called at all.

The attached patch removes the caching and fixes the problem.

--
components: Library (Lib)
files: logging.patch
keywords: patch
messages: 56525
nosy: theller
severity: normal
status: open
title: logging records cache the result of formatException()
type: behavior
versions: Python 2.4, Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file8563/logging.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1295
__Index: Lib/logging/__init__.py
===
--- Lib/logging/__init__.py	(revision 58033)
+++ Lib/logging/__init__.py	(working copy)
@@ -247,7 +247,6 @@
 self.filename = pathname
 self.module = Unknown module
 self.exc_info = exc_info
-self.exc_text = None  # used to cache the traceback text
 self.lineno = lineno
 self.funcName = func
 self.created = ct
@@ -420,14 +419,10 @@
 record.asctime = self.formatTime(record, self.datefmt)
 s = self._fmt % record.__dict__
 if record.exc_info:
-# Cache the traceback text to avoid converting it multiple times
-# (it's constant anyway)
-if not record.exc_text:
-record.exc_text = self.formatException(record.exc_info)
-if record.exc_text:
+exc_text = self.formatException(record.exc_info)
 if s[-1:] != \n:
 s = s + \n
-s = s + record.exc_text
+s = s + exc_text
 return s
 
 #
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1296] optparse's OptionGroup not described

2007-10-18 Thread Paul Melis

New submission from Paul Melis:

The current 2.5 documentation does not seem to describe the OptionGroup
feature of the optparse module.

In 2003 there was a patch submitted that added a section on OptionGroup (
http://bugs.python.org/issue697941). The issue entry mentions it was
accepted, but the current docs do not seem to contain that section.

--
components: Documentation
messages: 56526
nosy: paulmelis
severity: normal
status: open
title: optparse's OptionGroup not described
versions: Python 2.5

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



[issue1296] optparse's OptionGroup not described

2007-10-18 Thread Paul Melis

Paul Melis added the comment:

It seems it got edited out when the documentation was overhauled for
optik 1.5, in r37468

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



[issue1291] test_resource fails on recent linux systems (

2007-10-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Patch please?

--
nosy: +gvanrossum

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



[issue1294] Management of KeyboardInterrupt in cmd.py

2007-10-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Would you mind submitting a patch instead of a whole new file?

--
nosy: +gvanrossum

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



[issue1295] logging records cache the result of formatException()

2007-10-18 Thread Guido van Rossum

Guido van Rossum added the comment:

This is tough. On the one hand you are right that different classes that
have different formatException() methods aren't treated correctly; on
the other hand I think the caching is important for other cases where
there are multiple loggers all using the default formatException().

I recommend that instead of getting rid of the cache, you fix your class
by overriding format() to reset record.ex c_text and then calling the
base class format() method.

--
nosy: +gvanrossum

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



[issue1297] pyconfig.h not compatible with MS VC++ Express Edition

2007-10-18 Thread Nick

New submission from Nick:

pyconfig.h checks for _MSC_VER and based on its value decides to include
basetsd.h.

MS VC++ Express reports _MSC_VER to be 1400 but does _NOT_ have the file
basetsd.h.

So when including Python.h with the Microsoft VC Express compiler,
pyconfig.h will try to include the non existing basetsd.h and compiling
fails.

--
components: Build
messages: 56531
nosy: weegreenblobbie
severity: normal
status: open
title: pyconfig.h not compatible with MS VC++ Express Edition
type: compile error
versions: Python 2.5

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



[issue1299] distutils.sysconfig is not cross-platform compatible

2007-10-18 Thread Nick

New submission from Nick:

I'm using scons (www.scons.org) and Python's distutils.sysconfig to
determine the correct compiler flags automatically to embed Python into
my C++ application.  I discovered that distuils.sysconfig is not fully
implemented on Windows.  Using distutils.sysconfg.get_config_var() or
get_config_vars() does not work on the Windows distribution.

The above calls will return values for INCLUDEPY LIBDIR LIB on Ubuntu
Linux, however, on Windows, these variables are not all declared.

These variables should be declared on all platforms so one can
automatically get the correct compiler flags needed to embed python in
one's C/C++ project.

--
components: Build
messages: 56533
nosy: weegreenblobbie
severity: normal
status: open
title: distutils.sysconfig is not cross-platform compatible
type: compile error
versions: Python 2.5

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



[issue1300] subprocess.list2cmdline doesn't do pipe symbols

2007-10-18 Thread Andrew Moise

New submission from Andrew Moise:

I expected subprocess.list2cmdline() to convert my list of arguments
into a command line which results in behavior equivalent to the Unix
exec() functions -- that is, that I can safely pass arbitrary characters
to it and it'll make it such that those characters are escaped.  It
looks to me, though, like it doesn't handle the pipe symbol, so that if
I call list2cmdline(['echo', 'foo|bar']), I get the command line 'echo
foo|bar' instead of 'echo foo|bar' as I would expect.

If this is actually a result of my misunderstanding (or if it's fixed in
a more recent version), please accept my apologies.

--
components: Windows
messages: 56534
nosy: [EMAIL PROTECTED]
severity: normal
status: open
title: subprocess.list2cmdline doesn't do pipe symbols
type: behavior
versions: Python 2.5

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



[issue1298] Support for z/OS and EBCDIC.

2007-10-18 Thread Guido van Rossum

Guido van Rossum added the comment:

How important is z/OS?  I'm very skeptical of the viability of any OS
that uses an encoding that is not a superset of ASCII.

--
nosy: +gvanrossum

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



[issue1295] logging records cache the result of formatException()

2007-10-18 Thread Thomas Heller

Thomas Heller added the comment:

  This is tough. On the one hand you are right that different classes that
  have different formatException() methods aren't treated correctly; on
  the other hand I think the caching is important for other cases where
  there are multiple loggers all using the default formatException().
  
  I recommend that instead of getting rid of the cache, you fix your class
  by overriding format() to reset record.ex c_text and then calling the
  base class format() method.

That is what I have been doing although I think that I have to reset
record.exc_text also AFTER the call to format() for the following
handlers, if any.

So, should this issue be closed as 'wont fix' ?

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



[issue1295] logging records cache the result of formatException()

2007-10-18 Thread Thomas Heller

Thomas Heller added the comment:

I think that a warning or an example in the docs would be nice, but I
have no time to make a patch for that.

--
resolution:  - wont fix
status: open - closed

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



[issue1295] logging records cache the result of formatException()

2007-10-18 Thread Guido van Rossum

Guido van Rossum added the comment:

I think so.

On 10/18/07, Thomas Heller [EMAIL PROTECTED] wrote:

 Thomas Heller added the comment:

   This is tough. On the one hand you are right that different classes that
   have different formatException() methods aren't treated correctly; on
   the other hand I think the caching is important for other cases where
   there are multiple loggers all using the default formatException().
  
   I recommend that instead of getting rid of the cache, you fix your class
   by overriding format() to reset record.ex c_text and then calling the
   base class format() method.

 That is what I have been doing although I think that I have to reset
 record.exc_text also AFTER the call to format() for the following
 handlers, if any.

 So, should this issue be closed as 'wont fix' ?

 __
 Tracker [EMAIL PROTECTED]
 http://bugs.python.org/issue1295
 __


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



[issue1281] typo in documentation - lib ref section 14.3.3.4

2007-10-18 Thread Ben Sherman

Ben Sherman added the comment:

There were typos in my original bug report - the typo in the
documentation is still a bug.  Ugh, someone must have brewed decaf.

--
title: type in docutmentation - lib ref section 14.3.3.4 - typo in 
documentation - lib ref section 14.3.3.4

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



[issue1297] pyconfig.h not compatible with MS VC++ Express Edition

2007-10-18 Thread Martin v. Löwis

Martin v. Löwis added the comment:

What version of VC++ Express are you specifically referring to?

--
nosy: +loewis

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



[issue1290] xml.dom.minidom not able to handle utf-8 data

2007-10-18 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

I forgot to show dom.py source.

marvin:cpython$ cat dom.py 
import xml.dom.minidom as dom
data = open('testdata.txt','r').read()
mydom = dom.parseString(data)
mydom.firstChild.childNodes

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



[issue1290] xml.dom.minidom not able to handle utf-8 data

2007-10-18 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

When I run the code in a script, I don't get the error.

***
marvin:cpython$ python
Python 2.5 (r25:51908, Jan 24 2007, 12:48:15) 
[GCC 4.1.0 (SUSE Linux)] on linux2
Type help, copyright, credits or license for more information.
 import xml.dom.minidom as dom
 data = open('testdata.txt','r').read()
 mydom = dom.parseString(data)
 mydom.firstChild.childNodes
Traceback (most recent call last):
  File stdin, line 1, in module
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022' in
position 18: ordinal not in range(128)
 import sys
 sys.getdefaultencoding()
'ascii'

marvin:cpython$ python dom.py 
marvin:cpython$ 
***

Can you try and see if you can run it from the script too?

--
nosy: +draghuram

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



[issue1281] typo in documentation - lib ref section 14.3.3.4

2007-10-18 Thread Georg Brandl

Georg Brandl added the comment:

In fact, the error is not a typo, but a glitch in latex2html's handling
of --. It's already corrected in the 2.5 branch and needs no
correction in later branches.

--
nosy: +georg.brandl
resolution:  - out of date
status: open - closed

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



[issue1631171] implement warnings module in C

2007-10-18 Thread Brett Cannon

Brett Cannon added the comment:

Regression test suite now passes.  =)  Had to add the support for when
warnings.showwarning() is set and a bug in PyErr_WarnExplicit() where a
NULL value for the module name was not being allowed.

Couple things still left to implement.  One is the second output line in
show_warning().  Don't notice this in unit tests as it imports warnings
and thus uses the Python implementation that works properly.  Also need
to implement warn_explicit().  Lastly, -W arguments need to be handled.

In terms of differing semantics, file paths are different.  Old way did
absolute paths.  It also handled what the file path should be when
executing a warning from the interpreter differently.

In terms of testing, some _warnings-specific tests are needed.  As
mentioned above, the differences between _warnings.show_warning() and
warnings.showwarning() are not being picked up.  This shows how tests
for setting of 'filters', 'onceregistry', and 'showwarning' needs to be
tested.

Assigning to Neal to see if there is anything I missed in terms of todos
and see if he wants to take any of them on.  =)

--
assignee: brett.cannon - nnorwitz
Added file: http://bugs.python.org/file8565/_warnings.c

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1631171
_#include Python.h
#include frameobject.h

#define MODULE_NAME _warnings
#define DEFAULT_ACTION_NAME default_action

PyDoc_STRVAR(warnings__doc__,
MODULE_NAME  provides basic warning filtering support.\n
It is a helper module to speed up interpreter start-up.);

/* Both 'filters' and 'onceregistry' can be set in warnings.py;
   get_warnings_attr() will reset these variables accordingly. */
static PyObject *_filters;  /* List */
static PyObject *_once_registry;  /* Dict */


static int
check_matched(PyObject *obj, PyObject *arg)
{
PyObject *result;
int rc;

if (obj == Py_None)
return 1;
result = PyObject_CallMethod(obj, match, O, arg);
if (result == NULL)
return -1;

rc = PyObject_IsTrue(result);
Py_DECREF(result);
return rc;
}

/*
   Returns a new reference.
   A NULL return value can mean false or an error.
*/
static PyObject *
get_warnings_attr(const char *attr)
{
static PyObject *warnings_str = NULL;
PyObject *all_modules;
PyObject *warnings_module;
int result;

if (warnings_str == NULL) {
warnings_str = PyString_FromString(warnings);
if (warnings_str == NULL)
return NULL;
}

all_modules = PyImport_GetModuleDict();
result = PyDict_Contains(all_modules, warnings_str);
if (result == -1 || result == 0)
return NULL;

warnings_module = PyDict_GetItem(all_modules, warnings_str);
if (!PyObject_HasAttrString(warnings_module, attr))
return NULL;
return PyObject_GetAttrString(warnings_module, attr);
}


PyObject *
get_once_registry(void)
{
PyObject *registry;

registry = get_warnings_attr(onceregistry);
if (registry == NULL) {
if (PyErr_Occurred())
return NULL;
return _once_registry;
}
Py_DECREF(_once_registry);
_once_registry = registry;
return registry;
}


/* The item is a borrowed reference. */
static const char *
get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
   PyObject *module, PyObject **item)
{
PyObject *action, *m, *d;
Py_ssize_t i;
PyObject *warnings_filters;

warnings_filters = get_warnings_attr(filters);
if (warnings_filters == NULL) {
if (PyErr_Occurred())
return NULL;
}
else {
Py_DECREF(_filters);
_filters = warnings_filters;
}

if (!PyList_Check(_filters)) {
PyErr_SetString(PyExc_ValueError,
MODULE_NAME .filters must be a list);
return NULL;
}

/* _filters could change while we are iterating over it. */
for (i = 0; i  PyList_GET_SIZE(_filters); i++) {
PyObject *tmp_item, *action, *msg, *cat, *mod, *ln_obj;
Py_ssize_t ln;
int is_subclass, good_msg, good_mod;

tmp_item = *item = PyList_GET_ITEM(_filters, i);
if (PyTuple_Size(tmp_item) != 5) {
PyErr_Format(PyExc_ValueError,
 MODULE_NAME .filters item %zd isn't a 5-tuple, i);
return NULL;
}

/* Python code: action, msg, cat, mod, ln = item */
action = PyTuple_GET_ITEM(tmp_item, 0);
msg = PyTuple_GET_ITEM(tmp_item, 1);
cat = PyTuple_GET_ITEM(tmp_item, 2);
mod = PyTuple_GET_ITEM(tmp_item, 3);
ln_obj = PyTuple_GET_ITEM(tmp_item, 4);

good_msg = check_matched(msg, text);
good_mod = check_matched(mod, module);
is_subclass = PyObject_IsSubclass(category, cat);
ln = PyInt_AsSsize_t(ln_obj);
if (good_msg == -1 || good_mod == -1 || is_subclass == -1 ||
(ln == -1  PyErr_Occurred()))

[issue1301] Bad assertion in _tkinter.c

2007-10-18 Thread Brett Cannon

Brett Cannon added the comment:

Patch is inlined in a comment.

--
keywords: +patch
nosy: +brett.cannon

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



[issue1301] Bad assertion in _tkinter.c

2007-10-18 Thread Stephen P. Schaefer

New submission from Stephen P. Schaefer:

The following fails with python 2.5 as built by Fedora 7:

t2.py:
import sys, Tkinter
Tkinter.Button(text=u).pack( )
Tkinter.mainloop( )

$ python t2.py
python: ./Modules/_tkinter.c:941: AsObj: Assertion `size  size *
sizeof(Tcl_UniChar)' failed.
Aborted

The following patch corrects the problem:

--- Python-2.5-fc7/Modules/_tkinter.c   2006-08-11 22:33:36.0 -0400
+++ Python-2.5/Modules/_tkinter.c   2007-10-18 18:44:40.0 -0400
@@ -938,7 +938,7 @@
 #if defined(Py_UNICODE_WIDE)  TCL_UTF_MAX == 3
Tcl_UniChar *outbuf;
Py_ssize_t i;
-   assert(size  size * sizeof(Tcl_UniChar));
+   assert(size == 0 || size  size * sizeof(Tcl_UniChar));
outbuf = (Tcl_UniChar*)ckalloc(size * sizeof(Tcl_UniChar));
if (!outbuf) {
PyErr_NoMemory();

--
components: Tkinter
messages: 56546
nosy: thyrsus
severity: normal
status: open
title: Bad assertion in _tkinter.c
versions: Python 2.5

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