[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

New submission from João Bernardo :

Hi, I'm working on a class which implements the __contains__ method but the way 
I would like it to work is by generating an object that will be evaluated later.

It'll return a custom object instead of True/False


class C:
def __contains__(self, x):
return "I will evaluate this thing later... Don't bother now"


but when I do:


>>> 1 in C()
True


It seems to evaluate the answer with bool!

Reading the docs 
(http://docs.python.org/py3k/reference/expressions.html#membership-test-details)
 It says:

"`x in y` is true if and only if `y.__contains__(x)` is true."

It looks like the docs doesn't match the code and the code is trying to mimic 
the behavior of lists/tuples where "x in y" is the same as

any(x is e or x == e for e in y)

and always yield True or False.

There is a reason why it is that way?


Thanks!

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 150283
nosy: JBernardo, docs@python
priority: normal
severity: normal
status: open
title: __contains__ method behavior
type: behavior
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Georg Brandl

Georg Brandl  added the comment:

"an object is true" is a short way of saying "bool(obj) is True".  So the docs 
match the behavior.

Returning the actual object instead of True/False from the "in" operator is a 
feature request.

--
assignee: docs@python -> 
nosy: +georg.brandl
type: behavior -> enhancement
versions:  -Python 3.2

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

João Bernardo  added the comment:

@Georg Brandl
Oh sorry, now I see... true != True

But still, why is that the default behavior? Shouldn't it use whatever the 
method returns?

--
type: enhancement -> behavior
versions: +Python 3.2

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

Changes by João Bernardo :


--
type: behavior -> enhancement

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Georg Brandl

Georg Brandl  added the comment:

Well, usually what you want *is* a boolean indicating whether the element is in 
the collection or not.

Being able to overload "in", mostly for metaprogramming purposes, is a request 
that probably nobody thought of when implementing "in".

--
nosy: +benjamin.peterson, pitrou -docs@python
versions:  -Python 3.2

___
Python tracker 

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2011-12-28 Thread Anthony Kong

Changes by Anthony Kong :


--
nosy: +Anthony.Kong

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Seems to work also on kfreebsd/debian (with eglibc).

--

___
Python tracker 

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



[issue13668] mute ImportError in __del__ of _threading_local module

2011-12-28 Thread Zhiping Deng

New submission from Zhiping Deng :

If python was configured without-threads:

% ./python
Python 2.7.2+ (2.7:e71e4bd45c89, Dec 28 2011, 21:03:59) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dummy_threading as _threading
>>> a = _threading.local()
>>> del a
Exception ImportError: ImportError('No module named thread',) in > ignored

Patch to mute this Exception:
diff --git a/Lib/_threading_local.py b/Lib/_threading_local.py
--- a/Lib/_threading_local.py
+++ b/Lib/_threading_local.py
@@ -221,7 +221,13 @@
 lock.release()
 
 def __del__(self):
-import threading
+try:
+import threading
+except ImportError:
+import sys
+if '_dummy_threading' in sys.modules:
+return
+raise
 
 key = object.__getattribute__(self, '_local__key')

--
files: _threading_local.mute_ImportError.diff
keywords: patch
messages: 150288
nosy: Zhiping.Deng
priority: normal
severity: normal
status: open
title: mute ImportError in __del__ of _threading_local module
versions: Python 2.7
Added file: 
http://bugs.python.org/file24097/_threading_local.mute_ImportError.diff

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

New submission from Zbyszek Szmek :

Extended attribute support was added in issue 12720. Doesn't compile on 
kfreebsd/debian, which uses eglibc and gcc. The error is that the symbols 
XATTR_LIST_MAX and XATTR_SIZE_MAX are not defined.

After http://hg.python.org/cpython/rev/f325439d7f84 xattr compilation tests for 
'defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__)', but in this case this test 
doesn't work. Anyway, XATTR_SIZE_MAX is defined (on Linux) in , 
and  doesn't know anything about it.

(When defined XATTR_{SIZE,LIST}_MAX to 65536 like on linux to go through with 
the compilation, and os.listxattr('/') returns 'OSError: [Errno 78] Function 
not implemented'...)

--
components: Extension Modules
messages: 150289
nosy: Arfrever, benjamin.peterson, pitrou, skrah, zbysz
priority: normal
severity: normal
status: open
title: XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with 
eglibc
versions: Python 3.3

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2011-12-28 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
stage: needs patch -> patch review

___
Python tracker 

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



[issue13670] Increase test coverage for pstats.py

2011-12-28 Thread andrea crotti

New submission from andrea crotti :

This patch increases test coverage for pstats.py from 25 to 36%.

It's my first proposed patch so sorry in advance if there are problems. Much 
more can be done for pstats.py (which is also not much commented) but I want to 
get some feedback on this first..

--
components: Tests
files: test_pstats.diff
keywords: patch
messages: 150290
nosy: andrea.crotti
priority: normal
severity: normal
status: open
title: Increase test coverage for pstats.py
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file24098/test_pstats.diff

___
Python tracker 

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



[issue13670] Increase test coverage for pstats.py

2011-12-28 Thread Brian Curtin

Changes by Brian Curtin :


--
nosy: +brian.curtin
stage:  -> patch review

___
Python tracker 

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



[issue13670] Increase test coverage for pstats.py

2011-12-28 Thread Georg Brandl

Georg Brandl  added the comment:

I don't understand this comment:
+#TODO: add more complicated tests, which might almost compile

Also, please don't use docstrings for the test methods because of unittest's 
"feature" to display them instead of the test method names.

--
nosy: +georg.brandl

___
Python tracker 

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



[issue13670] Increase test coverage for pstats.py

2011-12-28 Thread andrea crotti

andrea crotti  added the comment:

It's really hard to understand true, and if should not go in the patch in 
general of course.

The sense was that the only test I added is trivial, but I haven't produced 
something better yet.

And ok I will remove the docstrings, I was actually doing it on purpose 
thinking about the unittest feature, but if the name is clear enough than is 
better to leave the docstring out...

Another thing, I didn't want to use tempfile.mktemp to generate a temporary 
file, but dump_stats doesn't accept anything else, is it in general safe to use 
it in this case?

--

___
Python tracker 

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-28 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset a7744f778646 by Jason R. Coombs in branch 'default':
Limit test scope to those platforms that can save the target filenames. 
Reference #11638.
http://hg.python.org/cpython/rev/a7744f778646

--

___
Python tracker 

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-28 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

I've limited the scope of the patch to attempt to only test on those platforms 
that can actually create unicode-named files. I'll watch the buildbots to see 
if that corrects the failures (since I don't have the failing platforms 
available to me).

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Are you telling me that XATTR_SIZE_MAX is defined nowhere on eglibc?

--

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

I think the idea has some merit. I think it should be well vetted on 
python-ideas, though. One thing that will certianly weigh against it is that 
implementation would not be trivial.

--

___
Python tracker 

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



[issue5689] Support xz compression in tarfile module

2011-12-28 Thread Nikolaus Rath

Changes by Nikolaus Rath :


--
nosy:  -Nikratio

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Unless I'm completely confused, XATTR_SIZE_MAX is defined by linux kernel 
headers, not the libc.

On my linux debian box:
$ grep -r XATTR_SIZE_MAX -I /usr
include/linux/limits.h:#define XATTR_SIZE_MAX 65536
$ dpkg -l libc6
libc6  2.11.2-10  Embedded GNU C Library: Shared libraries
$ dpkg -S /usr/include/linux/limits.h
linux-libc-dev: /usr/include/linux/limits.h

On debian/kfreebsd grep XATTR_SIZE_MAX doesn't find anything.

On fedora 16:
$ grep -r XATTR_SIZE_MAX -I /usr
/usr/include/linux/limits.h:#define XATTR_SIZE_MAX 65536
$ rpm -qf /usr/include/linux/limits.h
kernel-headers-3.1.0-0.rc10.git0.1.fc16.x86_64

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Forgot to add (on the fedora box):
$ rpm -q glibc
glibc-2.14.90-13.x86_64
(The GNU libc libraries from http://www.gnu.org/software/glibc/)

So the glibc/eglibc split is not important here.

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> On my linux debian box:
> $ grep -r XATTR_SIZE_MAX -I /usr
> include/linux/limits.h:#define XATTR_SIZE_MAX 65536
> $ dpkg -l libc6
> libc6  2.11.2-10  Embedded GNU C Library: Shared libraries
> $ dpkg -S /usr/include/linux/limits.h
> linux-libc-dev: /usr/include/linux/limits.h

But linux/limits.h is included by the glibc:

$ \grep -r linux/limits.h /usr/include/
/usr/include/sys/param.h:#include 
[...]
$ \rpm -qf /usr/include/sys/param.h
glibc-devel-2.12.1-11.2.mga1

--

___
Python tracker 

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-28 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 9b681e0c04ed by Jason R. Coombs in branch '2.7':
Limit test scope to those platforms that can save the target filenames. 
Reference #11638.
http://hg.python.org/cpython/rev/9b681e0c04ed

--

___
Python tracker 

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2011-12-28 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

The changes to the default branch seem to have cleaned up the test failures on 
most platforms (still waiting on the ARM results). So I've backported the test 
skips to the Python 2.7 branch as well.

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Yes, it must be, because XATTR_SIZE_MAX is only defined in 
linux/limits.h. The problem is that with the kfreebsd kernel,
/usr/include/sys/limits.h doesn't define or include anything that 
defines XATTR_SIZE_MAX.

Maybe the test should be 'defined(HAVE_SYS_XATTR_H) && 
defined(XATTR_SIZE_MAX)'?

--

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

João Bernardo  added the comment:

I see that every other comparison operator (<, >, <=, >=, ==, !=) except for 
`is` work the way I expect and is able to return anything.

e.g.

>>> numpy.arange(5) < 3
array([ True,  True,  True, False, False], dtype=bool)

I didn't checked the code (and probably I'm talking nonsense), but seems like 
the `in` operator has an extra call to `PyObject_IsTrue` that maybe could be 
dropped?

Of course it can break code relying on `x in y` being True/False but it would 
only happen on customized classes.

Another option that won't break code is to add a different method to handle 
these cases. Something like "__contains_non_bool__", but that'd be a big api 
change.

--
components:  -Documentation

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

2011/12/28 João Bernardo :
>
> João Bernardo  added the comment:
>
> I see that every other comparison operator (<, >, <=, >=, ==, !=) except for 
> `is` work the way I expect and is able to return anything.
>
> e.g.
>
 numpy.arange(5) < 3
> array([ True,  True,  True, False, False], dtype=bool)
>
> I didn't checked the code (and probably I'm talking nonsense), but seems like 
> the `in` operator has an extra call to `PyObject_IsTrue` that maybe could be 
> dropped?

I'm not sure what you're referring to, but I doubt that would do the job.

>
> Of course it can break code relying on `x in y` being True/False but it would 
> only happen on customized classes.
>
> Another option that won't break code is to add a different method to handle 
> these cases. Something like "__contains_non_bool__", but that'd be a big api 
> change.

And completely hideous.

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Stefan Krah

Stefan Krah  added the comment:

So the problem occurs on:

http://www.debian.org/ports/kfreebsd-gnu/


Did I get that right? Is __FreeBSD__ defined on that system?


I'm not sure though if we should start supporting hybrid systems.

--

___
Python tracker 

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



[issue13671] double comma cant be parsed in config module

2011-12-28 Thread Александр Балезин

New submission from Александр Балезин :

In conf file:
"keyе_ = ,,"
Get next exception:
  File "/usr/lib/python2.6/dist-packages/configobj.py", line 1230, in __init__
self._load(infile, configspec)
  File "/usr/lib/python2.6/dist-packages/configobj.py", line 1306, in _load
self._parse(infile)
  File "/usr/lib/python2.6/dist-packages/configobj.py", line 1660, in _parse
ParseError, infile, cur_index)
  File "/usr/lib/python2.6/dist-packages/configobj.py", line 1721, in 
_handle_error
 raise error
configobj.ParseError: Parse error in value at line 15.

--
components: Regular Expressions
messages: 150306
nosy: ezio.melotti, lukasz.langa, Александр.Балезин
priority: normal
severity: normal
status: open
title: double comma cant be parsed in config module
versions: Python 2.7, Python 3.2

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

João Bernardo  added the comment:

Using my poor grep abilities I found that on Objects/typeobject.c
(I replaced some declarations/error checking from the code with ...)

static int
slot_sq_contains(PyObject *self, PyObject *value) {
...
func = lookup_maybe(self, "__contains__", &contains_str);
if (func != NULL) {
...
res = PyObject_Call(func, args, NULL);
...
if (res != NULL) {
result = PyObject_IsTrue(res);
Py_DECREF(res);
}
}
else if (! PyErr_Occurred()) {
/* Possible results: -1 and 1 */
result = (int)_PySequence_IterSearch(self, value,
 PY_ITERSEARCH_CONTAINS);
}
}


I don't know if I'm in the right place, but the function returns `int` and 
evaluates the result to 1 or 0 if __contains__ is found.

I also don't know what SQSLOT means, but unlike the other operators (which are 
defined as TPSLOT), `slot_sq_contains` is a function returning "int" while 
`slot_tp_richcompare` returns "PyObject *".

Why is that defined that way?

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

That's the one.

No. I'm putting the complete list below.

Actually python2.5-7 and 3.2 is normally packaged by debian for
is arch, so it mostly works.

$ gcc -dM -E - < /dev/null
#define __DBL_MIN_EXP__ (-1021)
#define __UINT_LEAST16_MAX__ 65535
#define __FLT_MIN__ 1.17549435082228750797e-38F
#define __UINT_LEAST8_TYPE__ unsigned char
#define __INTMAX_C(c) c ## L
#define __CHAR_BIT__ 8
#define __UINT8_MAX__ 255
#define __WINT_MAX__ 4294967295U
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __SIZE_MAX__ 18446744073709551615UL
#define __WCHAR_MAX__ 2147483647
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L)
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __FLT_EVAL_METHOD__ 0
#define __unix__ 1
#define __x86_64 1
#define __UINT_FAST64_MAX__ 18446744073709551615UL
#define __SIG_ATOMIC_TYPE__ int
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 2
#define __UINT_FAST8_MAX__ 255
#define __DEC64_MAX_EXP__ 385
#define __INT8_C(c) c
#define __UINT_LEAST64_MAX__ 18446744073709551615UL
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINT_LEAST8_MAX__ 255
#define __UINTMAX_TYPE__ long unsigned int
#define __DEC32_EPSILON__ 1E-6DF
#define __unix 1
#define __UINT32_MAX__ 4294967295U
#define __LDBL_MAX_EXP__ 16384
#define __WINT_MIN__ 0U
#define __SCHAR_MAX__ 127
#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
#define __INT64_C(c) c ## L
#define __DBL_DIG__ 15
#define __SIZEOF_INT__ 4
#define __SIZEOF_POINTER__ 8
#define __USER_LABEL_PREFIX__ 
#define __GLIBC__ 1
#define __STDC_HOSTED__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __FLT_EPSILON__ 1.1920928955078125e-7F
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
#define __DEC32_MAX__ 9.99E96DF
#define __INT32_MAX__ 2147483647
#define __SIZEOF_LONG__ 8
#define __UINT16_C(c) c
#define __DECIMAL_DIG__ 21
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 4
#define __MMX__ 1
#define __FLT_HAS_DENORM__ 1
#define __SIZEOF_LONG_DOUBLE__ 16
#define __BIGGEST_ALIGNMENT__ 16
#define __DBL_MAX__ ((double)1.79769313486231570815e+308L)
#define __INT_FAST32_MAX__ 9223372036854775807L
#define __DBL_HAS_INFINITY__ 1
#define __DEC32_MIN_EXP__ (-94)
#define __INT_FAST16_TYPE__ long int
#define __LDBL_HAS_DENORM__ 1
#define __DEC128_MAX__ 9.9E6144DL
#define __INT_LEAST32_MAX__ 2147483647
#define __DEC32_MIN__ 1E-95DF
#define __DBL_MAX_EXP__ 1024
#define __DEC128_EPSILON__ 1E-33DL
#define __SSE2_MATH__ 1
#define __PTRDIFF_MAX__ 9223372036854775807L
#define __amd64 1
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __SIZEOF_SIZE_T__ 8
#define __SIZEOF_WINT_T__ 4
#define __GCC_HAVE_DWARF2_CFI_ASM 1
#define __GXX_ABI_VERSION 1002
#define __FLT_MIN_EXP__ (-125)
#define __INT_FAST64_TYPE__ long int
#define __DBL_MIN__ ((double)2.22507385850720138309e-308L)
#define __LP64__ 1
#define __DEC128_MIN__ 1E-6143DL
#define __REGISTER_PREFIX__ 
#define __UINT16_MAX__ 65535
#define __DBL_HAS_DENORM__ 1
#define __UINT8_TYPE__ unsigned char
#define __NO_INLINE__ 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "4.6.2"
#define __UINT64_C(c) c ## UL
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __INT32_C(c) c
#define __DEC64_EPSILON__ 1E-15DD
#define __ORDER_PDP_ENDIAN__ 3412
#define __DEC128_MIN_EXP__ (-6142)
#define __INT_FAST32_TYPE__ long int
#define __UINT_LEAST16_TYPE__ short unsigned int
#define unix 1
#define __INT16_MAX__ 32767
#define __SIZE_TYPE__ long unsigned int
#define __UINT64_MAX__ 18446744073709551615UL
#define __INT8_TYPE__ signed char
#define __ELF__ 1
#define __FLT_RADIX__ 2
#define __INT_LEAST16_TYPE__ short int
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
#define __UINTMAX_C(c) c ## UL
#define __SSE_MATH__ 1
#define __k8 1
#define __SIG_ATOMIC_MAX__ 2147483647
#define __SIZEOF_PTRDIFF_T__ 8
#define __x86_64__ 1
#define __DEC32_SUBNORMAL_MIN__ 0.01E-95DF
#define __INT_FAST16_MAX__ 9223372036854775807L
#define __UINT_FAST32_MAX__ 18446744073709551615UL
#define __UINT_LEAST64_TYPE__ long unsigned int
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 9223372036854775807L
#define __DEC128_SUBNORMAL_MIN__ 0.1E-6143DL
#define __FLT_HAS_INFINITY__ 1
#define __UINT_FAST16_TYPE__ long unsigned int
#define __DEC64_MAX__ 9.999E384DD
#define __CHAR16_TYPE__ short unsigned int
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __INT_LEAST16_MAX__ 32767
#define __DEC64_MANT_DIG__ 16
#define __INT64_MAX__ 9223372036854775807L
#define __UINT_LEAST32_MAX__ 4294967295U
#define __INT_LEAST64_TYPE__ long int
#define __INT16_TYPE__ short int
#define __INT_LEAST8_TYPE__ signed char
#define __DEC32_MAX_EXP__ 97
#define __INT_FAST8_MAX__ 127
#define __INTPTR_MAX__ 9223372036854775807L
#define __SSE2_

[issue13667] __contains__ method behavior

2011-12-28 Thread Georg Brandl

Georg Brandl  added the comment:

It's defined that way because it's a slot returning a bool, so it doesn't need 
to return anything except for 0 or 1.

Changing this to return a PyObject would mean that every extension module (i.e. 
module written in C) that defines a custom __contains__ would need to be 
adapted.  That is the non-trivial implementation that Benjamin was talking 
about.

--

___
Python tracker 

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



[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-12-28 Thread James B

James B  added the comment:

I have encountered this issue(python 2.7) with respect to positional arguments 
that begin with a dash (linux/ bash).

In the following example, the parser requires three positional arguments. I 
attempted to encase the arguments in single-quotes as that is expected in 
general to result in strings to be correctly handled (these args are API keys, 
so they could contain shell-unfriendly chars like - and &).

./tool.py  arg1 'arg2' '-arg3&otherstuff' 

You'll note there are no optional arguments in this example, it just boils down 
to a positional argument being broken up on parse.

Needless to say it was quite confusing to see the script complain after passing 
in what would typically be perfectly valid strings in most other apps / scripts.

Is it possible to get argparse to correctly notice and handle shell-appropriate 
single-quoting methods(dont break down a string that has been implied as a 
complete token via ' ')

As it stands, it appears I have two workaround options: 1) adopt the ./tool.py 
--  convention mentioned in this thread, or 2) escape leading 
dashes in positional argument strings to avoid this issue.

--
nosy: +skilletaudio

___
Python tracker 

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



[issue12715] Add symlink support to shutil functions

2011-12-28 Thread Hynek Schlawack

Changes by Hynek Schlawack :


Added file: http://bugs.python.org/file24099/23e6204efe20.diff

___
Python tracker 

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



[issue12715] Add symlink support to shutil functions

2011-12-28 Thread Hynek Schlawack

Hynek Schlawack  added the comment:

Added another patch fixing the issues pointed out by Antoine and 
Charles-François.

--

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

New submission from Arfrever Frehtes Taifersar Arahesis 
:

PEP 3155 added qualified name as __qualname__ attribute in classes and 
functions. It would be useful if qualified name was also available as 
co_qualname attribute of code objects.

>>> import sys
>>> class A:
... def f1():
... return B.f2()
... 
>>> class B:
... def f2():
... return sys._getframe(1)
...
>>> A.f1.__name__
'f1'
>>> A.f1.__qualname__
'A.f1'
>>> B.f2.__name__
'f2'
>>> B.f2.__qualname__
'B.f2'
>>> frame = A.f1()
>>> frame

>>> frame.f_code
", line 2>
>>> frame.f_code.co_name
'f1'
>>> frame.f_code.co_qualname
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'code' object has no attribute 'co_qualname'


Suggested behavior:
>>> frame.f_code.co_qualname
'A.f1'

--
components: Interpreter Core
messages: 150312
nosy: Arfrever, pitrou
priority: normal
severity: normal
status: open
title: Add co_qualname attribute in code objects
versions: Python 3.3

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Eric Snow

Eric Snow  added the comment:

with f_func (see #12857) you would get that for free:

>>> frame.f_func.__qualname__
'A.f1'

--
nosy: +eric.snow

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

-1 on this proposal.  It has everyone paying a price for a questionable feature 
that would benefit very few.

--
nosy: +rhettinger

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Alex Gaynor

Alex Gaynor  added the comment:

For what it's worth I proposed this on -ideas a while ago, the sticking points 
were what does `not in` do (no one had an answer anyone was happy with for 
this), and do we need a way to override it from the other perspective (e.g. if 
I want to do `SpecialObj() in [1, 2, 3]`, is there a way to do that?).

--
nosy: +alex

___
Python tracker 

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



[issue12857] Expose called function on frame object

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

co_qualname could still be useful if somebody has code object without frame 
object.

--

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Eric Snow

Eric Snow  added the comment:

True.  I wonder, though if perhaps a co_func (as a weak ref) or co_orig_func 
would be better, since co_qualname would be built from the original function 
anyway.  Then you could call "code.co_func.func_qualname".

One sticky point is that there isn't a guarantee of one-to-one between function 
object and code object.  A code object could be bound to several different 
functions as happens with function definitions (particularly lambdas) inside 
comprehensions.

Also, if a code object is not associated with a function, i.e. one generated by 
exec, what should the qualname for the code object be?  How about, in CPython, 
the code objects created for classes and modules?

--

___
Python tracker 

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



[issue13669] XATTR_SIZE_MAX and XATTR_LIST_MAX undefined on kfreebsd/debian with eglibc

2011-12-28 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

[Why does roundup remove quoted text being replied to???]

On 12/28/2011 06:05 PM, Stefan Krah wrote:
> http://www.debian.org/ports/kfreebsd-gnu/
That's the one.

> Is __FreeBSD__ defined on that system?
No. I'm putting the complete list below.

> I'm not sure though if we should start supporting hybrid systems.
Actually python2.5-7 and 3.2 is normally packaged by debian for
is arch, so it mostly works.

--

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue13673] SIGINT prevents raising of exceptions unless PyErr_CheckSignals() called

2011-12-28 Thread sbt

New submission from sbt :

If SIGINT arrives while a function implemented in C is executing, then it 
prevents the function from raising an exception unless the function first calls 
PyErr_CheckSignals().  (If the function returns an object (instead of NULL) 
then KeyboardInterrupt is raised as expected.)

For example, the following function just spins for 5 seconds before raising 
RuntimeError:

  static PyObject *
  testsigint_wait(PyObject *self, PyObject *arg)
  {
  clock_t start = clock();
  while (clock() - start < 5 * CLOCKS_PER_SEC) {
  /* pass */
  }
  //PyErr_CheckSignals();
  PyErr_SetNone(PyExc_RuntimeError);
  return NULL;
  }

If I call this function and press Ctrl-C before it completes, then I get the 
following:

  >>> import testsigint
  >>> a = testsigint.wait()
  ^C>>> print(a)
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'a' is not defined

So the call failed, but no exception was raised, and the variable "a" was not 
set!

I would have expected RuntimeError (or KeyboardInterrupt) to be raised.  If I 
uncomment the PyErr_CheckSignals() line then I get RuntimeError as expected:

  >>> import testsigint
  >>> a = testsigint.wait()
  ^CTraceback (most recent call last):
File "", line 1, in 
  RuntimeError

Also, if I wrap the call in try...finally or try...except, I get a sensible 
"chained" traceback:

  >>> try:
  ...   testsigint.wait()
  ... finally:
  ...   print("done")
  ... 
  ^CTraceback (most recent call last):
File "", line 2, in 
  RuntimeError

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
File "", line 2, in 
  KeyboardInterrupt

(Tested under Linux and Windows with the default branch.)

--
files: testsigint.zip
messages: 150319
nosy: sbt
priority: normal
severity: normal
status: open
title: SIGINT prevents raising of exceptions unless PyErr_CheckSignals() called
versions: Python 3.3
Added file: http://bugs.python.org/file24100/testsigint.zip

___
Python tracker 

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



[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-12-28 Thread Anders Kaseorg

Anders Kaseorg  added the comment:

James: That’s not related to this issue.  This issue is about options taking 
arguments beginning with dash (such as a2x --asciidoc-opts --safe, where --safe 
is the argument to --asciidoc-opts), not positional arguments beginning with 
dash.

Your observation isn’t a bug.  In all getopt-like parsers, -- is the only way 
to pass positional arguments beginning with -.  (Whether you shell-quoted the 
argument is irrelevant; the - is interpreted by the program, not the shell, 
after the shell has already stripped off the shell quoting.)

If your program doesn’t take any options and you’d like to parse positional 
arguments without requiring --, don’t use a getopt-like parser; use sys.argv 
directly.

If you still think your example is a bug, please file a separate report.

--

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo

João Bernardo  added the comment:

The problem with `not in` is because it must evaluate the result. It's not just 
another operator like "==" and "!=".

Looks like we're suffering from premature optimization and now it would break a 
lot of code to make it good.

For my application, I created a different method to generate the object (Not as 
good as I wanted, but there's no option right now):

`MyClass().has(1)` instead of `1 in MyClass()`

So, if no one comes up with a better idea, this issue should be closed.

Thanks

--

___
Python tracker 

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



[issue13667] __contains__ method behavior

2011-12-28 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

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



[issue12857] Expose called function on frame object

2011-12-28 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Meador Inge

Changes by Meador Inge :


--
nosy: +meador.inge
stage:  -> needs patch
type:  -> enhancement

___
Python tracker 

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



[issue9260] A finer grained import lock

2011-12-28 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

New prototype with per-module import locks and deadlock avoidance.
When a deadlock due to threaded circular imports is detected, the offending 
import returns the partially constructed module object (as would happen in 
single-threaded mode).

Probably lacks a test and some cleanup.

--
nosy: +neologix
versions: +Python 3.3 -Python 3.2
Added file: http://bugs.python.org/file24101/implock3.patch

___
Python tracker 

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



[issue13668] mute ImportError in __del__ of _threading_local module

2011-12-28 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue13508] ctypes' find_library breaks with ARM ABIs

2011-12-28 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +haypo
stage: needs patch -> patch review
versions: +Python 3.3 -Python 2.6

___
Python tracker 

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