[issue20363] BytesWarnings triggerred by test suite

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

And

'print(hash(eval(%s.decode(utf-8' % repr_.encode(utf-8)

can be simplified to

'print(hash(eval(%a)))' % repr_

--

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



[issue20376] Argument Clinic: backslashes in docstrings are not escaped

2014-01-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Argument Clinic copies backslashes in docstrings as is. This can produce wrong 
or even invalid C string. Either backslashes should be escaped, or current 
behavior should be documented.

--
components: Demos and Tools
messages: 209044
nosy: larry, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Argument Clinic: backslashes in docstrings are not escaped
type: behavior
versions: Python 3.4

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



[issue20377] Argument Clinic: get rid of the _impl suffix

2014-01-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

For now most hand-written functions which use Argument Clinic have the _impl 
suffix and generated wrapper functions without the _impl suffix are less 
interested and visible to developer (generated *_METHODDEF macros are used in 
method list). I propose to revert things and name implementation functions 
without the _impl suffix, but add the _wrapper (or _method?) suffix to 
generated wrapper functions.

--
components: Demos and Tools
messages: 209045
nosy: larry, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Argument Clinic: get rid of the _impl suffix
type: enhancement
versions: Python 3.4

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



[issue20173] Derby #4: Convert 53 sites to Argument Clinic across 5 files

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Here is the updated patch of codecsmodule, based on Larry's review. Thanks! I 
didn't realize clinic releases pybuffer implicitly. I also turned 
_codecs.Codecs to _codecs since all of these methods are module methods.

--
Added file: http://bugs.python.org/file33677/clinic_codecsmodule_v2.patch

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



[issue20185] Derby #17: Convert 49 sites to Argument Clinic across 13 files

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Updated marshal patch. I just learned we don't need to release pybuffer (y*) 
manually.

--
Added file: http://bugs.python.org/file33678/clinic_marshal_v3.patch

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



[issue20377] Argument Clinic: get rid of the _impl suffix

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

We had this discussion already, some months ago.  The consensus was to leave it 
the way it is.

--
resolution:  - rejected
status: open - closed

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



[issue20376] Argument Clinic: backslashes in docstrings are not escaped

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Oops!  They should be escaped.

--

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



[issue20377] Argument Clinic: get rid of the _impl suffix

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

For the record, I was actually in favor of swapping them.  You can try bringing 
it up again on python-dev if you like, but I'm not sure there's anything really 
new to say.

--

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



[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Serhiy said, Why do you cast PyDict_Size(kwds) to int?

Sorry, Serhiy! Today I just realized there is your review for this ticket. I 
couldn't really remember but I think I got conversion warning if I did not 
downcast it. Something about I shouldn't not have operation involving ssize_t 
and int in one statement. Strangely when I tested it again, it did not 
complain. Perhaps I used different distro back then.

Well, since Larry has a patch intersecting with this ticket, I guess we should 
let him does this work. Thanks, Serhiy!

I tried to reply you in the rietveld but I got an error page.

--

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



[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I don't have a patch for this issue.  If you're thinking of my nullable ints 
patch, that was just an experiment.  I'd prefer we figure out what we're going 
to do on this issue, and we can talk abut conversion to Argument Clinic later.

--

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



[issue20218] Add `pathlib.Path.write` and `pathlib.Path.read`

2014-01-24 Thread Ram Rachum

Ram Rachum added the comment:

I like the patch. Except I'd like to have support for the 'x' flag in the 
`write_text` and `write_bytes` methods. I suggest an argument `exclusive`, 
which defaults to `False`. When `exclusive=True`, the mode will be 'x' or 'xb'.

The first lines after each method definition should be:

if append and exclusive:
raise Exception(Can't use both `append` and `exclusive` modes 
together; `append` implies that the file exists, while `exclusive` implies it 
does not.)

If you don't like long exception texts, you can shorten it to just the first 
sentence. Also, you may want to choose a different exception class than 
`Exception`.

--

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



[issue18670] Using read_mime_types function from mimetypes module gives resource warning

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Here is the updated patch based on Ezio's review. Sorry, for a long time, I 
didn't notice you had reviewed my code, Ezio. Thanks for the review!

--
Added file: 
http://bugs.python.org/file33679/fix_resource_warning_read_mime_types_v3.patch

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Ned Deily

Ned Deily added the comment:

The checked-in fixes break builds on OS X that use the Apple-supplied libedit 
readline compatibility layer.  See, for example:  
http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%203.x/builds/1077/steps/compile/logs/stdio

gcc -fno-strict-aliasing -Werror=declaration-after-statement -g -O0 -Wall 
-Wstrict-prototypes -I./Include -I. -IInclude 
-I/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Include 
-I/Users/buildbot/buildarea/3.x.murray-snowleopard/build -c 
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c -o 
build/temp.macosx-10.6-x86_64-3.4-pydebug/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.o
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c: In 
function ‘setup_readline’:
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1001: 
error: ‘rl_hook_func_t’ undeclared (first use in this function)
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1001: 
error: (Each undeclared identifier is reported only once
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1001: 
error: for each function it appears in.)
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1001: 
error: expected expression before ‘)’ token
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1003: 
error: expected expression before ‘)’ token
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1006: 
error: ‘rl_completion_func_t’ undeclared (first use in this function)
/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Modules/readline.c:1006: 
error: expected expression before ‘)’ token

--
assignee:  - benjamin.peterson
nosy: +ned.deily
resolution: fixed - 
stage: committed/rejected - needs patch
status: closed - open

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



[issue20311] epoll.poll(timeout) and PollSelector.select(timeout) must round the timeout to the upper bound

2014-01-24 Thread STINNER Victor

STINNER Victor added the comment:

Guido van Rossum added the comment:
 I've lost some context, but perhaps we should have the notion of
 granularity of the poll/select timeout (e.g. 1 msec), and consider
 events that are in the future by less than that granularity as ready?
 Then we can round the timeout down: if someone passes a timeout of 1.1
 msec, poll would wait for approximately 1 msec, and when it returns
 the event would be considered due now as long as the balance (about
 0.1 msec) was under 1 msec.

Well, it sounds like a good compromise according to my experimentation in my 
last commits on epoll and selectors.

New attached asyncio_granularity.patch:

- Restore the previous rounding method for poll and epoll (in select and 
selectors modules), remove unit tests which were designed to test the rounding 
the timeout away from zero
- Add a new resolution attribute to selectors.BaseSelector (select: 1e-6, poll 
and epoll: 1e-3, kqueue: 1e-9)
- Add a new granularity attribute to asyncio.BaseEventLoop: maximum of time 
resolution and selector resolution
- Add a unit test for asyncio counting the number of calls to _run_once(), 
independent of the selector and the platform
- BaseEventLoop._run_once() rounds the deadline and current time using 
granularity

I tested the patch on Linux, FreeBSD and Windows (select, selectors and asyncio 
tests pass). Granularity:

- Linux. poll, epoll: 1 ms, select: 1 us (resolution of time.monotonic: 1 ns)
- FreeBSD. poll: 1 ms, select: 1 us, kqueue: 11 ns (resolution of 
time.monotonic: 11 ns)
- Windows (tested on my Windows 7 VM): select, proactor: 15.6 ms (resolution of 
time.monotonic(): 15.6 ms)

BaseProactorEventLoop doesn't use the resolution of IocpProactor because I 
don't know the resolution :-) Anyway, time.monotonic() has a low resolution 
(15.6 ms) and so it should be fine.

If the patch is accepted, my changes on Python 3.3 should also be reverted.

--
Added file: http://bugs.python.org/file33680/asyncio_granularity.patch

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



[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Here is the updated patch. I try to be conservative here, preserving the 
current behaviour.

Negative times is same as zero.
Default value (which can be passed by omitting times) means unlimited.

I did not change the signature repeat(object [,times]) because the only 
suitable default value, in my opinion, is repeat(object [,times=unlimited]) 
which is impossible at the moment.

Well, let see what Raymond has anything to say about this.

--
Added file: 
http://bugs.python.org/file33681/fix_itertools_repeat_negative_number_means_0_v3.patch

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



[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

2014-01-24 Thread Vajrasky Kok

Vajrasky Kok added the comment:

def repeat(object, times=-1):  = it could break the code in the wild.

Current behaviour: repeat(object) - unlimited, repeat(object, -1) - 0 
repetitions.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

Note that tp_new is a static method, not a class method (the type creation
machinery takes care of passing in the right class rather than the
descriptor machinery)

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

 Note that tp_new is a static method, not a class method (the type
 creation machinery takes care of passing in the right class rather
 than the descriptor machinery)

I admit I didn't know that.

But from a practical perspective, surely you agree that tp_new walks and quacks 
like a class method?  That I, as an author of an extension type, should think 
of it as such?

--

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



[issue20377] Argument Clinic: get rid of the _impl suffix

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you please provide a link on this discussion? There were too many 
discussions and I had quickly lost them.

Argument Clinic was changed too much for last weeks, so perhaps consensus is 
changed.

--

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



[issue20377] Argument Clinic: get rid of the _impl suffix

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I'm sorry, but I simply don't have the time to spend to dig it up right now.  
It was a while ago and I'm not sure exactly where to look.

I dimly recall it was last year, probably during September-December, and that 
both Nick and I were in it.  It was probably in python-dev but it might have 
been on the tracker.

--

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



[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Your patch does not address my concern.

My concern is that itertools.repeat doesn't parse its arguments like other 
Python functions.  It behaves differently depending on whether times is 
passed by position or by keyword.  Therefore its actual calling signature 
cannot be represented accurately with an inspect.Signature object.

Let me state this precisely.  Currently, inspect.signature doesn't produce a 
Signature object for itertools.repeat.  But let's assume for the moment that it 
did, and that the default value for the times parameter was -1.  Then, for 
this code:

  sig = inspect.signature(itertools.repeat)
  a = itertools.repeat('a')
  b = itertools.repeat('a', sig.parameters['times'].default)
  c = itertools.repeat('a', times=sig.parameters['times'].default)

I'd expect the a, b, and c objects to behave identically and be 
interchangeable.  Passing in the default value for an optional parameter should 
always produce the same result as not passing in a value for that parameter, 
and for positional-or-keyword parameters it shouldn't matter whether that's 
done by position or by keyword.

However, b is different from a and c: a and c yields infinitely-many 'a's, 
whereas b never yields anything.

I want to see a patch where, after applying the patch, a b and c would be 
interchangeable.  Such a patch should be *simpler* than the existing code, as 
it would remove all the special-case code that examines the length of the args 
tuple.

Special cases aren't special enough to break the rules.  I think 
itertools.repeat's argument parsing should stop breaking the rules.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

It doesn't act like a class method, though, it acts like a static method:

 int.__new__()
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: int.__new__(): not enough arguments
 int.__new__(int)
0

You have to *write* __new__ and tp_new as if they were class methods (because 
the type machinery expects you to do so), but you have to *call* them like 
static methods if you're invoking them directly for some reason.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

(Also, I can't give you a solid reason for *why* it's like that - Guido just 
wrote it that way, and the type machinery is hairy enough that I have no 
intentions of second guessing him on that one)

--

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



[issue20218] Add `pathlib.Path.write` and `pathlib.Path.read`

2014-01-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy:  -serhiy.storchaka

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

Oh, yes, now I remember - it *has* to be that way, otherwise upcalls from 
subclass __new__ methods don't do the right thing (int.__new__(MyInt), etc), 
just as you need to pass the current type in explicitly for cooperative super 
calls. This is perhaps *the* most obscure design detail of the type system that 
I'm aware of - I have to go scratching around in my brain for the reason every 
time it comes up, which is fortunately almost never :)

--

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What if remove casts at all? Ned, is it compiled with libedit?

--
keywords: +patch
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file33682/readline_func_cast.patch

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



[issue20317] ExitStack hang if enough nested exceptions

2014-01-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b3eaeb4bdf84 by Nick Coghlan in branch '3.3':
Issue 20317: Remove debugging code from contextlib
http://hg.python.org/cpython/rev/b3eaeb4bdf84

New changeset a0bf53afedfa by Nick Coghlan in branch 'default':
Merge removal of issue 20317 debugging code from 3.3
http://hg.python.org/cpython/rev/a0bf53afedfa

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Okay, one more diff.  I have high hopes for this, but then I had high hopes 
yesterday.

Nick, could you review the PyTypeObject changes in this patch?  Obviously I'd 
love a review of the whole thing, but if you can only make a little time, the 
crucial part is the delta from patch set 5 for typeobject.c.

First thing: I must never have run the unit test suite before cutting the diff 
yesterday, because I did today and there were a bunch of problems.  That's 
clowny and I apologize.  But it's fixed now, and I assure you, there's no way I 
would have actually checked this in without running the test suite immediately 
before.

Here's what changed today:

Core:
* Modified typeobject.c so that when creating an object,
  if it copies the type's __doc__, it skips past
  the signature, because type objects are callable
  and have signatures now.

* Default value for dict.fromkeys parameter is now None.
  (Previously it was NULL, which was simply wrong.)

Lib and tests:

* pydoc now catches both ValueError and TypeError when it tries
  inspect.signature.

* Added a fix for unittest.mock courtesy of Michael Foord.
  It previously assumed that anything it could get an
  inspect.Signature for was written in Python.  Now that
  that's no longer true, it broke some other code.  Michael's
  pretty confident that's the right fix, and in any case it
  makes the tests pass again.

* Bashed up some IDLE unit tests that depend on docstrings.  These are
  accurate for now, but look wrong because of the __text_signature__
  grabbing the first line when it shouldn't.  When I get to put in
  the new signature syntax, these will break again and I'll put them
  back.

* General unit test fixes, to live in this modern world.

Tools:

* Argument Clinic now makes sure that parser functions for __new__
  are always of type newfunc, the type of the tp_new slot.
  Similarly, parser functions for __init__ are now always of
  type initproc, the type of tp_init.

--
Added file: 
http://bugs.python.org/file33683/larry.support.text_signature.on.more.types.7.txt

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



[issue20264] Update patchcheck to looks for files with clinic comments

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Maybe I'm not reading this correctly.  It looks like the function returns True 
if it finds any .c or .h file that contains the string '[clinic input]'.  It 
doesn't seem to only check files that have changed.

I was considering adding a checkum for the *input* to the third comment (what I 
call the output line).  That would let this checker compute the checksum for 
the input and output sections and confirm that they match.  If the input had 
changed, the checksum would fail, and you'd know they hadn't run clinic 
recently.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

Scanned the whole patch, especially the type changes. This looks like a solid 
approach to me.

For 3.5, PEP 457 might want to consider proposing a tp_sig slot and splitting 
the signature out at type creation time rather than on attribute lookup. The 
current dynamic approach is fine for 3.4, though.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Okay, I'm checking this beast in.  Hooray!  Thanks for your reviews, everybody!

--

I thought it was still possible to introduce objects into Python at runtime 
without calling PyType_Ready on their type.  If that's true,
then there wouldn't necessarily *be* a type creation time at which
we could do the signature splitting.

Is that no longer allowed as of 3.4?  Are all types required to be
registered with PyType_Ready before objects of that type are introduced into 
the Python runtime?  If so, hooplah!

--

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



[issue20223] inspect.signature does not support new functools.partialmethod

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

Yury, I believe the review comments from Rietveld go to the address you have 
registered as primary in the tracker, so that's currently your address with the 
.ml suffix rather than your main one.

My only suggestion was to use ._partialmethod for the attribute name, rather 
than __partialmethod__, since this feels a bit more like an ordinary private 
attribute, rather than a new protocol. Lots of introspection tools deliberately 
*display* dunder names, and that doesn't really feel appropriate here.

--

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



[issue20223] inspect.signature does not support new functools.partialmethod

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

As far as pushing goes, I'd wait until Larry lands issue 20189 - I suspect 
there's a risk of conflict between these patches in the inspect module, and 
that one is key to getting builtin signatures supported properly :)

--
dependencies: +inspect.Signature doesn't recognize all builtin types

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

There are probably still ways to do it, but we don't *support* doing it (and 
I'm pretty sure we've fixed them all in the builtins and stdlib).

However, yes, that's another good reason to be conservative in only doing the 
split into signature+doc at attribute lookup time.

--

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I just realized, I forgot to fix the bug Zach reported, where help(bound_thing) 
should still show the class or self parameter.
I'm going to check this in anyway, and file a fresh bug on myself to
address that.

--

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



[issue17481] inspect.getfullargspec should use __signature__

2014-01-24 Thread Nick Coghlan

Nick Coghlan added the comment:

Another case of don't land it until Larry has dealt with the builtins.

The patch itself looks fine, though :)

--
dependencies: +inspect.Signature doesn't recognize all builtin types

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



[issue20378] Implement `Signature.__repr__`

2014-01-24 Thread Ram Rachum

Changes by Ram Rachum r...@rachum.com:


--
components: Library (Lib)
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Implement `Signature.__repr__`
versions: Python 3.5

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



[issue20379] help(bound_builtin_class) does not display self

2014-01-24 Thread Larry Hastings

New submission from Larry Hastings:

For an object O that are bound to something (either a class or an instance), 
help(O) traditionally shows the bound argument.  For this code:

class C:
def foo(self, a):  pass

c = C()

help(c.foo) would show the signature as (self, a), even though self has been 
bound.

My recent changes to Python's type system (#20189), to add inspect.Signature 
support for builtins, broke this.  The previous behavior should be restored.

--
assignee: larry
messages: 209078
nosy: larry, zach.ware
priority: deferred blocker
severity: normal
stage: needs patch
status: open
title: help(bound_builtin_class) does not display self
type: behavior
versions: Python 3.4

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Phew!  Thanks again, everybody!

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue20189] inspect.Signature doesn't recognize all builtin types

2014-01-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 85710aa396ef by Larry Hastings in branch 'default':
Issue #20189: Four additional builtin types (PyTypeObject,
http://hg.python.org/cpython/rev/85710aa396ef

--
nosy: +python-dev

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



[issue17481] inspect.getfullargspec should use __signature__

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

The patch from #20189 has landed.

--

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



[issue20223] inspect.signature does not support new functools.partialmethod

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

The patch from #20189 has landed.

--

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



[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

2014-01-24 Thread Glenn Langford

Glenn Langford added the comment:

Proposed patch for as_completed(). #20369 fixes wait(), and behaviour is 
consistent between the two.

--
keywords: +patch
Added file: http://bugs.python.org/file33684/issue20367.patch

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



[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

2014-01-24 Thread STINNER Victor

STINNER Victor added the comment:

 Proposed patch for as_completed().

Could you please try to write a unit test. The unit test should fail without 
the patch, and fail with the patch. Then create a new patch including the patch.

If it's tricky to write a reliable test reproducing the race condition, you can 
use unittest.mock to mock some objects.

--

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



[issue20380] __defaults__ changed by *args

2014-01-24 Thread Ram Rachum

New submission from Ram Rachum:

Check the following example out. Putting *args in a function makes its 
__defaults__ be empty.

Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan  5 2014, 16:13:26) [MSC v.1600 
64 bit (AMD64)] on win32
Type help, copyright, credits or license for more information.
 def f(x, *args, y='meow'): pass
...
 f.__defaults__
 def g(x, y='meow'): pass
...
 g.__defaults__
('meow',)


--
components: Interpreter Core
messages: 209085
nosy: cool-RR
priority: normal
severity: normal
status: open
title: __defaults__ changed by *args
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue20380] __defaults__ changed by *args

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

That's because in f, y is after *args, so it is a keyword-only parameter.  Its 
default value is in __kwdefaults__.  If you move y to before *args, its default 
will be in __defaults__.

This is working as designed.

--
nosy: +larry
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue20380] __defaults__ changed by *args

2014-01-24 Thread Ram Rachum

Ram Rachum added the comment:

Though perhaps a note in the documentation would be helpful for future confused 
people.

--

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



[issue20380] __defaults__ changed by *args

2014-01-24 Thread Ram Rachum

Ram Rachum added the comment:

My mistake. Thanks for the clarification.

--

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



[issue20355] -W command line options should have higher priority than PYTHONWARNINGS environmental variable

2014-01-24 Thread Brett Cannon

Brett Cannon added the comment:

I agree with Antoine; this can wait for Python 3.5.

--

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



[issue20355] -W command line options should have higher priority than PYTHONWARNINGS environmental variable

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Okay, then yes, let's save this for 3.5.  Thanks!

--

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



[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

2014-01-24 Thread Glenn Langford

Glenn Langford added the comment:

 Could you please try to write a unit test.

Revised patch with unit test for as_completed().

--
Added file: http://bugs.python.org/file33685/issue20367.patch

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



[issue20260] Argument Clinic: add unsigned integers converters

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I can start citing data points if you like.

socket.if_indextoname just calls PyLong_AsUnsignedLong().  Not sure what that 
throws.

--

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



[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

2014-01-24 Thread STINNER Victor

STINNER Victor added the comment:

Hum, you should also modify the documentation to explicit the
behaviour. Example: Duplicates futures are only yielded once.

You may add the same sentence in the asyncio.as_completed()
documentation. It looks like asyncio tests doesn't test as_completed()
with duplicated future. You may write a new patch to modify asyncio
doc and tests. It should be very similar.

+completed = [f for f in futures.as_completed( [f1,f1] ) ]

You can just use list(futures.as_completed([f1,f1])). Please no space
around parenthesis (see the PEP 8).

+self.assertEqual( len(completed), 1 )

No space around parenthesis (see the PEP 8):
self.assertEqual(len(completed), 1).

You may check the list value instead: self.assertEqual(completed, [f1])

(Why f1 name? There is no f2, maybe rename to f?)

--

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Zachary Ware

New submission from Zachary Ware:

The fix for #20189 broke simple expression defaults.  Specifically, with the 
latest #20172 patch applied, Clinic fails on winreg.c at winreg line 1351 with 
this traceback:

Error in file PC\winreg.c on line 1351:
Exception raised during parsing:
Traceback (most recent call last):
  File Tools\clinic\clinic.py, line 1541, in parse
parser.parse(block)
  File Tools\clinic\clinic.py, line 2942, in parse
self.state(line)
  File Tools\clinic\clinic.py, line 3482, in state_parameter_docstring
return self.next(self.state_parameter, line)
  File Tools\clinic\clinic.py, line 2975, in next
self.state(line)
  File Tools\clinic\clinic.py, line 3321, in state_parameter
bad = default != repr(eval(default))
  File string, line 1, in module
NameError: name 'winreg' is not defined

In this case, 'default' is 'winreg.KEY_WRITE'.  The 'default != 
repr(eval(default))' check cannot succeed with such a default even if winreg 
were defined, as it will return an int, 131078.

--
assignee: larry
components: Demos and Tools
messages: 209094
nosy: larry, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: Argument Clinic: expression default arguments broken
type: behavior
versions: Python 3.4

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Ned Deily

Ned Deily added the comment:

Serhiy, I'm not sure I understand your question.  libedit includes a GNU 
readline compatibility layer and that is what _readline.so builds and links 
with on OS X systems (with an ABI of 10.5 and later) since OS X does not ship 
with GNU readline.  This is also the case on some BSD systems.  With your 
patch, _readline.so again builds correctly.

--

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 With your patch, _readline.so again builds correctly.

Yes, this is what I wanted to know. Sorry for the awkward formulation.

Type casting is dangerous because it may hide the signature mismatch, which 
can cause problems later in run time. It is better to rely on static type 
checking if possible.

--

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Okay then. Off we go.

--

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



[issue20374] Failure to compile with readline-6.3-rc1

2014-01-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5e42e5764ac6 by Benjamin Peterson in branch '2.7':
new plan: just remove typecasts (closes #20374)
http://hg.python.org/cpython/rev/5e42e5764ac6

New changeset fc62fcd8e990 by Benjamin Peterson in branch '3.3':
new plan: just remove typecasts (closes #20374)
http://hg.python.org/cpython/rev/fc62fcd8e990

New changeset 3c3624fec6c8 by Benjamin Peterson in branch 'default':
merge 3.3 (#20374)
http://hg.python.org/cpython/rev/3c3624fec6c8

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue20382] Typo in cStringIO tp_name

2014-01-24 Thread mailination

New submission from mailination:

python/Modules/cStringIO.c:648

  cStringIO.StringI,/*tp_name*/

maybe Should be

  cStringIO.StringIO,/*tp_name*/

--
components: Library (Lib)
messages: 209099
nosy: mailination
priority: normal
severity: normal
status: open
title: Typo in cStringIO tp_name
type: behavior
versions: Python 2.7

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



[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-01-24 Thread Brett Cannon

New submission from Brett Cannon:

Would allow for the name attribute to be optional since it can be grabbed from 
the spec. Since having module.__spec__ set is now expected we should help 
ensure that by supporting it in the constructor.

--
components: Library (Lib)
messages: 209100
nosy: brett.cannon, eric.snow, ncoghlan
priority: low
severity: normal
stage: test needed
status: open
title: Add a keyword-only spec argument to types.ModuleType
versions: Python 3.5

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



[issue20382] Typo in cStringIO tp_name

2014-01-24 Thread STINNER Victor

STINNER Victor added the comment:

I don't think that it is a typo. cStringIO.StringIO(str) returns a StringI 
object, whereas cStringIO.StringIO() returns a StringO object.

$ python
Python 2.7.5 (default, Nov 12 2013, 16:45:54) 
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux2
Type help, copyright, credits or license for more information.
 import cStringIO
 cStringIO.StringIO('abc')
cStringIO.StringI object at 0x7f407d1dae88
 cStringIO.StringIO()
cStringIO.StringO object at 0x7f407d0f4e68

--
nosy: +haypo
resolution:  - invalid
status: open - closed

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



[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

2014-01-24 Thread Glenn Langford

Glenn Langford added the comment:

Thanks for the feedback. The new patch is modified for PEP8 with naming 
consistent with other concurrent tests. assertEqual I think is clearer by 
checking list length, so it is not changed. The docstring is updated.

I suggest asyncio be handled separately.

--
Added file: http://bugs.python.org/file33686/issue20367.patch

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Zachary Ware

Zachary Ware added the comment:

This also prevents a vanilla trunk build (as of 85710aa396ef) from succeeding 
at 'Tools/clinic/clinic.py --make':

Error in file .\Modules\_sre.c on line 574:
Unsupported expression as default value: 'sys.maxsize'

I think the only reasonable check we can do is to make sure there aren't any 
syntax errors in the default value (see patch), but there may well be something 
I'm missing here.

--
keywords: +patch
Added file: http://bugs.python.org/file33687/issue20381.diff

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



[issue20376] Argument Clinic: backslashes in docstrings are not escaped

2014-01-24 Thread Zachary Ware

Zachary Ware added the comment:

This should do it, correct?

--
keywords: +patch
nosy: +zach.ware
Added file: http://bugs.python.org/file33688/issue20376.diff

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



[issue19077] More robust TemporaryDirectory cleanup

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here are updated patches for 3.3 and 3.4. Changed tests for 3.4, a patch for 
3.3 is changed more. Unfortunately in 3.3 exceptions still can be raised when 
try to emit a warning during shutdown. Is there any way to determine the 
shutdown mode?

--
Added file: http://bugs.python.org/file33689/tempdir_cleanup-3.3.patch
Added file: http://bugs.python.org/file33690/tempdir_finalize-3.4.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19077
___diff -r fc62fcd8e990 Lib/tempfile.py
--- a/Lib/tempfile.py   Fri Jan 24 11:44:16 2014 -0500
+++ b/Lib/tempfile.py   Fri Jan 24 19:52:38 2014 +0200
@@ -29,9 +29,9 @@
 
 import functools as _functools
 import warnings as _warnings
-import sys as _sys
 import io as _io
 import os as _os
+import shutil as _shutil
 import errno as _errno
 from random import Random as _Random
 
@@ -355,10 +355,13 @@
 underlying file object, without adding a __del__ method to the
 temporary file.
 
+# Set here since __del__ checks it
+file = None
+close_called = False
+
 def __init__(self, file, name, delete=True):
 self.file = file
 self.name = name
-self.close_called = False
 self.delete = delete
 
 # NT provides delete-on-close as a primitive, so we don't need
@@ -370,14 +373,13 @@
 # that this must be referenced as self.unlink, because the
 # name TemporaryFileWrapper may also get None'd out before
 # __del__ is called.
-unlink = _os.unlink
 
-def close(self):
-if not self.close_called:
+def close(self, unlink=_os.unlink):
+if not self.close_called and self.file is not None:
 self.close_called = True
 self.file.close()
 if self.delete:
-self.unlink(self.name)
+unlink(self.name)
 
 # Need to ensure the file is deleted on __del__
 def __del__(self):
@@ -677,9 +679,11 @@
 in it are removed.
 
 
+# Handle mkdtemp raising an exception
+name = None
+_closed = False
+
 def __init__(self, suffix=, prefix=template, dir=None):
-self._closed = False
-self.name = None # Handle mkdtemp raising an exception
 self.name = mkdtemp(suffix, prefix, dir)
 
 def __repr__(self):
@@ -688,23 +692,18 @@
 def __enter__(self):
 return self.name
 
-def cleanup(self, _warn=False):
+def cleanup(self, _warn=False, _warnings=_warnings):
 if self.name and not self._closed:
 try:
+_shutil.rmtree(self.name)
+except (TypeError, AttributeError) as ex:
+if None not in '%s' % (ex,):
+raise
 self._rmtree(self.name)
-except (TypeError, AttributeError) as ex:
-# Issue #10188: Emit a warning on stderr
-# if the directory could not be cleaned
-# up due to missing globals
-if None not in str(ex):
-raise
-print(ERROR: {!r} while cleaning up {!r}.format(ex, self,),
-  file=_sys.stderr)
-return
 self._closed = True
-if _warn:
-self._warn(Implicitly cleaning up {!r}.format(self),
-   ResourceWarning)
+if _warn and _warnings.warn:
+_warnings.warn(Implicitly cleaning up {!r}.format(self),
+   ResourceWarning)
 
 def __exit__(self, exc, value, tb):
 self.cleanup()
@@ -713,36 +712,19 @@
 # Issue a ResourceWarning if implicit cleanup needed
 self.cleanup(_warn=True)
 
-# XXX (ncoghlan): The following code attempts to make
-# this class tolerant of the module nulling out process
-# that happens during CPython interpreter shutdown
-# Alas, it doesn't actually manage it. See issue #10188
-_listdir = staticmethod(_os.listdir)
-_path_join = staticmethod(_os.path.join)
-_isdir = staticmethod(_os.path.isdir)
-_islink = staticmethod(_os.path.islink)
-_remove = staticmethod(_os.remove)
-_rmdir = staticmethod(_os.rmdir)
-_os_error = OSError
-_warn = _warnings.warn
-
-def _rmtree(self, path):
+def _rmtree(self, path, _OSError=OSError, _sep=_os.path.sep,
+_listdir=_os.listdir, _remove=_os.remove, _rmdir=_os.rmdir):
 # Essentially a stripped down version of shutil.rmtree.  We can't
 # use globals because they may be None'ed out at shutdown.
-for name in self._listdir(path):
-fullname = self._path_join(path, name)
-try:
-isdir = self._isdir(fullname) and not self._islink(fullname)
-except self._os_error:
-isdir = False
-if isdir:
-

[issue20209] Deprecate PROTOCOL_SSLv2

2014-01-24 Thread Derek Wilson

Derek Wilson added the comment:

sslv2 should not be deprecated yet.

in the field of security research it is highly valuable to locate servers that 
are still using sslv2 because it is a security risk.

i'm fine with making it not used by default, but there is no reason to remove 
the capability from the language itself. thats way overkill.

once sslv2 is no longer in the wild i have no problem with deprecation but the 
fact is that there is still a strong reason to keep the capability around.

--
nosy: +underrun

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



[issue20209] Deprecate PROTOCOL_SSLv2

2014-01-24 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the insight. Then I suggest to close this issue as postponed or 
rejected.

--

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



[issue20379] help(bound_builtin_class) does not display self

2014-01-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

What matters to other programs is what the inspect functions return, not what 
help() does or does not do to the returned string before displaying it. So I 
see the issue as the discrepancy in this.

class C:
def foo(self, a):  pass
c = C()

import inspect
print('garg - C.foo ', inspect.formatargspec(*inspect.getfullargspec(C.foo)))
print('garg - c.foo', inspect.formatargspec(*inspect.getfullargspec(c.foo)))
print('sig - C.foo ', str(inspect.signature(C.foo)))
print('sig - c.foo', str(inspect.signature(c.foo)))
 
garg - C.foo  (self, a)
garg - c.foo (self, a)
sig - C.foo  (self, a)
sig - c.foo (a)

Idle calltips attempt to remind the user what they must and might enter after 
'('. For this, the sig output correct and the garg output is buggy. Idle 
currently works around the garg bug by selectively deleting the first param 
name with
if (isinstance(ob, (type, types.MethodType)) or
isinstance(ob_call, types.MethodType)):
argspec = _first_param.sub(, argspec)

If signatures for bound builtins are similarly buggy, by including 'self' when 
it should be omitted, calltips would need a means to detect when to omit. 
Perhaps
 type([].append)
class 'builtin_function_or_method'
will work, but the name implies otherwise. In any case, I would prefer that 
inspect.signature give correct results instead of being made bug-compatible 
with .getfullargspec. In other words, it should include the 'delete self' code 
that is correct for the implementation. Then I could omit the yet-to-be-written 
expanded workaround.

I regard this help output as buggy.

 help(c.foo)
Help on method foo in module __main__:
foo(self, a) method of __main__.C instance

It identifies foo as a bound method, but gives the wrong signature for a bound 
method. So in my view, your changes fix a bug rather than breaking correct 
behavior.

--
nosy: +terry.reedy

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

On Linux for 2.7, 3.3 and 3.4 the open of non-existing file raises an exception 
which contains file name.

Python 2.7:

 open('non-existing', 'rb')
Traceback (most recent call last):
  File stdin, line 1, in module
IOError: [Errno 2] No such file or directory: 'non-existing'
 import io
 io.open('non-existing', 'rb')
Traceback (most recent call last):
  File stdin, line 1, in module
IOError: [Errno 2] No such file or directory: 'non-existing'

Python 3.3 and 3.4:

 open('non-existing', 'rb')
Traceback (most recent call last):
  File stdin, line 1, in module
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'

On Windows for 2.7 and 3.4 raised exception also contains file name. But on 3.3 
error message is only [Errno 2] No such file or directory and doesn't 
contains file name.

This change affects tests. test_tarfile failed on all Windows buildbots for 3.3.

http://buildbot.python.org/all/builders/x86%20Windows7%203.3/builds/1252/steps/test/logs/stdio

I suppose this is 3.3 bug.

--
components: IO
messages: 209109
nosy: benjamin.peterson, hynek, pitrou, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: open() exception doesn't contain file name on Windows
type: behavior
versions: Python 3.3

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Mark Lawrence

Mark Lawrence added the comment:

Not on my system, so what's changed?

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit 
(Intel)] on win32
Type help, copyright, credits or license for more information.
 open('non-existing', 'rb')
Traceback (most recent call last):
  File stdin, line 1, in module
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'

--
nosy: +BreamoreBoy

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Mark, could you please try following commands?

import tarfile; tarfile.open('non-existing', 'r|')

--

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
components: +Windows

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +brian.curtin, tim.golden

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



[issue20378] Implement `Signature.__repr__`

2014-01-24 Thread Terry J. Reedy

New submission from Terry J. Reedy:

Signature.__repr__ already exits. It is inherited from object. So you must be 
proposing to override the inherited method. For what purpose? With what outcome?

Without reading the signature PEP, I believe the current difference between str 
and repr is intentional, not accidental. Example:
 repr(s)
'inspect.Signature object at 0x02E7BC08'
 str(s)
'(self, a)'

If so, this issue should be closed unless you can provide an excellent reason 
to break code the expects the current behavior.

--
nosy: +terry.reedy, yselivanov
stage:  - test needed

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Mark Lawrence

Mark Lawrence added the comment:

Two attempts, one with the pipe | symbol in the mode, one without.

 import tarfile; tarfile.open('non-existing', 'r|')
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python33\lib\tarfile.py, line 1594, in open
stream = _Stream(name, filemode, comptype, fileobj, bufsize)
  File C:\Python33\lib\tarfile.py, line 362, in __init__
fileobj = _LowLevelFile(name, mode)
  File C:\Python33\lib\tarfile.py, line 335, in __init__
self.fd = os.open(name, mode, 0o666)
FileNotFoundError: [Errno 2] No such file or directory

 import tarfile; tarfile.open('non-existing', 'r')
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python33\lib\tarfile.py, line 1566, in open
return func(name, r, fileobj, **kwargs)
  File C:\Python33\lib\tarfile.py, line 1614, in taropen
return cls(name, mode, fileobj, **kwargs)
  File C:\Python33\lib\tarfile.py, line 1442, in __init__
fileobj = bltn_open(name, self._mode)
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'

--

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



[issue20378] Implement `Signature.__repr__`

2014-01-24 Thread Ram Rachum

Ram Rachum added the comment:

My impression is that the `__repr__` method of any object is intended to 
describe that object, hopefully in a succinct way, possibly in a REPL-friendly 
way (like `list.__repr__`  for example) but if not then at least 
human-friendly. This is for easy introspection. When I come across a Signature 
object in the shell, I want to immediately get a good feel for what it contains 
without exploring `vars(sig)` manully.

If you have a `Signature` object, why not have its `__repr__` return something 
like 'Signature f: alpha, beta=3, *args, **kwargs`? This would do an awesome 
job at helping me understand what kind of signature object I'm looking at.

--

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, here is os.open() raises an exception. Thank you Mark.

On Linux it raises an exception with file name.

 import os; os.open('non-existing', os.O_RDONLY | getattr(os, 'O_BINARY', 
 0), 0x666)
Traceback (most recent call last):
  File stdin, line 1, in module
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'

--

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 69d885ac042d by Serhiy Storchaka in branch '3.3':
Issue #20384: Fix the test_tarfile test on Windows.
http://hg.python.org/cpython/rev/69d885ac042d

--
nosy: +python-dev

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Mark Lawrence

Mark Lawrence added the comment:

I think there's a typo in the patch, test = 'xxx' but after the check for 
platform and mode, text = ''.

--

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



[issue20384] open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes, thank you. It is alredy fixed in 38a50d8102be (thanks Arfrever).

--

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



[issue20384] os.open() exception doesn't contain file name on Windows

2014-01-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
title: open() exception doesn't contain file name on Windows - os.open() 
exception doesn't contain file name on Windows

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



[issue20379] help(bound_builtin_class) does not display self

2014-01-24 Thread Zachary Ware

Zachary Ware added the comment:

I don't think there's any danger of changing inspect.Signature's behavior here; 
it's doing the right thing.  What we're concerned with here is just making sure 
that the output of 'help(some_kind_of_method)' is equivalent to the output of 
'help(some_kind_of_method_in_C)', which should just mean changes to pydoc.

pydoc currently shows the 'self' parameter because before trying to find the 
signature, it replaces the object it is looking at with that object's __func__ 
attribute (see Lib/pydoc.py:1315).  To get rid of that behavior for 
Python-implemented methods is as simple as removing that line.

Is that the route we want to go, though?  It makes sense and it does make 
Python and C methods (mostly) match so I'd be happy with it, but it does change 
the help output for every Python-implemented method.

There is still the issue that the help output for C-implemented methods don't 
say anything about whether they're bound or not, but that issue is just a 
sibling to this one.

--

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Remove the winreg.

On Jan 24, 2014 8:02 AM, Zachary Ware rep...@bugs.python.org wrote:


 New submission from Zachary Ware: 

 The fix for #20189 broke simple expression defaults.  Specifically, with the 
 latest #20172 patch applied, Clinic fails on winreg.c at winreg line 1351 
 with this traceback: 

 Error in file PC\winreg.c on line 1351: 
 Exception raised during parsing: 
 Traceback (most recent call last): 
   File Tools\clinic\clinic.py, line 1541, in parse 
     parser.parse(block) 
   File Tools\clinic\clinic.py, line 2942, in parse 
     self.state(line) 
   File Tools\clinic\clinic.py, line 3482, in state_parameter_docstring 
     return self.next(self.state_parameter, line) 
   File Tools\clinic\clinic.py, line 2975, in next 
     self.state(line) 
   File Tools\clinic\clinic.py, line 3321, in state_parameter 
     bad = default != repr(eval(default)) 
   File string, line 1, in module 
 NameError: name 'winreg' is not defined 

 In this case, 'default' is 'winreg.KEY_WRITE'.  The 'default != 
 repr(eval(default))' check cannot succeed with such a default even if winreg 
 were defined, as it will return an int, 131078. 

 -- 
 assignee: larry 
 components: Demos and Tools 
 messages: 209094 
 nosy: larry, zach.ware 
 priority: normal 
 severity: normal 
 stage: needs patch 
 status: open 
 title: Argument Clinic: expression default arguments broken 
 type: behavior 
 versions: Python 3.4 

 ___ 
 Python tracker rep...@bugs.python.org 
 http://bugs.python.org/issue20381 
 ___

--

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Zachary Ware

Zachary Ware added the comment:

Removing 'winreg.' gives the very similar traceback:

Error in file PC\winreg.c on line 1351:
Exception raised during parsing:
Traceback (most recent call last):
  File Tools\clinic\clinic.py, line 1541, in parse
parser.parse(block)
  File Tools\clinic\clinic.py, line 2942, in parse
self.state(line)
  File Tools\clinic\clinic.py, line 3482, in state_parameter_docstring
return self.next(self.state_parameter, line)
  File Tools\clinic\clinic.py, line 2975, in next
self.state(line)
  File Tools\clinic\clinic.py, line 3321, in state_parameter
bad = default != repr(eval(default))
  File string, line 1, in module
NameError: name 'KEY_WRITE' is not defined

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat

New submission from Tal Einat:

To quote issue20294 where Larry Hastings added AC support for __new__ and 
__init__:


* __init__ and __new__ always take kwargs.
  * if the function signature doesn't accept keyword arguments,
it calls _PyArg_NoKeywords().


However, due to issue1486663, many classes only do a _PyArg_NoKeywords if the 
type is the original class, but not for sub-classses. Examples are 
_random.Random (in which case I found a workaround) and many itertools classes, 
for which there are also tests that check this.

One possibility is to simply allow these classes to also accept keyword 
arguments. It doesn't break backwards compatibility, and once there are proper 
argument names and doc-strings, why not?

Otherwise, currently I have to make generated __new__ functions accept keyword 
arguments, and then wrap them with a function that checks _PyArg_NoKeywords 
only if the the type is the original class.

--
components: Build, Demos and Tools
messages: 209122
nosy: larry, taleinat
priority: normal
severity: normal
status: open
title: Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for 
sub-classes
type: enhancement
versions: Python 3.4

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Let's not catch Exception there.  Does catching NameError make the problem go 
away?

And, #20189 changed the rules for simple expressions.  Now names you want from 
the local module should not have the name of the module in front.  You wouldn't 
have to do this in foo.py:
 
IMPORTANT_SYMBOLIC_CONSTANT=83
def fn(a=foo.IMPORTANT_SYMBOLIC_CONSTANT): ...

So it was always a dumb idea to require it for Argument Clinic code too.

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

How about I add the if type == our own type checks as per #1486663?

--

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



[issue20209] Deprecate PROTOCOL_SSLv2

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I agree.

--

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



[issue20209] Deprecate PROTOCOL_SSLv2

2014-01-24 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
resolution:  - rejected
status: open - closed

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



[issue20379] help(bound_builtin_class) does not display self

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Huh.  So inspect.getfullargspec is the code ignoring whether or not a function 
is bound.

Well, help(x) should be consistent, whether x is a bound builtin class instance 
or a bound Python class instance.  Right now it isn't; it displays the self 
for the Python one but not for the builtin one.

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat

Tal Einat added the comment:

In general, that sounds like a reasonable suggestion to me. A quick search 
shows that most classes that call _PyArg_NoKeywords check the type first. I 
think we should strive for uniformity in this respect, so I'm +1 for your 
suggestion.

I do see some classes which accept only positional arguments but where that 
check isn't in place. Examples:

* itertools.tee just calls PyArg_ParseTuple without checking _PyArg_NoKeywords 
(is this a bug?) (this is fairly common, I think)

* range always calls _PyArg_NoKeywords, without checking the type (is this a 
bug?) (this is rare)

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

I think it's a bug that they don't do the subclass check.  In practice, nobody 
subclasses range and itertools.tee.  But they should probably still be fixed.

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat

Tal Einat added the comment:

Great. Most of the classes in itertools could use this.

BTW, you'll need to supply a way to supply the C name of the type, to use in 
the type check.

--

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Zachary Ware

Zachary Ware added the comment:

How does this one strike you?  Somewhat reversed logic compared to the first 
patch, but with this one we get either success or a nicely formatted fail 
message, no more tracebacks.

--
Added file: http://bugs.python.org/file33691/issue20381.v2.diff

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

Way ahead of you.  The class directive will have to change:

class name typedef type_object

On the other hand, this means that Argument Clinic can automatically give the 
right type to the default self converter.  So most people won't have to write 
custom self converter classes anymore.  Argument Clinic giveth, and it taketh 
away.

--

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat

Tal Einat added the comment:

+1 for that as well, I've written quite a few self converters for that reason.

--

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

It's considered bad form to catch Exception.  We should catch the minimum 
necessary.  If there are exceptions we forgot, people will complain and then 
we'll add those.

Also, I want to make sure (if possible) that the value round-trips correctly 
through eval and repr. We need to repr the value, and if it doesn't round-trip 
properly the user needs to know.

On the other hand, I'm okay with starting with bad=False and going from there.  
The previous block (with DetectBadNodes()) already does that.  Hang on for a 
patch.

--

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



[issue20386] socket.SocketType is different in Python 3.4

2014-01-24 Thread Giampaolo Rodola'

New submission from Giampaolo Rodola':

Python 2.7

 import socket
 socket.SocketType
class 'socket._socketobject'
 s = socket.socket()
 isinstance(s, socket.SocketType)
True
 


Python 3.4

 socket.SocketType
enum 'SocketType'
 s = socket.socket()
 isinstance(s, socket.SocketType)
False
 

SocketType was already present and documented in Python 2 so it should be 
preserved: http://docs.python.org/2/library/socket.html#socket.SocketType

Also, socket.SocketType and socket.AddressFamily names suggest they should be 
public but they're not mentioned in the doc.  I think they should just be 
private though (frankly I fail to understand why a set of constants such as 
AF_* and SOCK_* should be grouped in a common container in the first place).

--
messages: 209134
nosy: giampaolo.rodola
priority: normal
severity: normal
status: open
title: socket.SocketType is different in Python 3.4
versions: Python 3.4

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



[issue20381] Argument Clinic: expression default arguments broken

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

How about this?  I'm going to do a rollup patch today with three fixes: this, 
#20385, and changing the default filename for the file destination.

--
Added file: 
http://bugs.python.org/file33692/larry.clinic.rollup.jan.24.diff.1.txt

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



[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings

Larry Hastings added the comment:

How about this?  I'm going to do a rollup patch today with three fixes: this, 
#20381, and changing the default filename for the file destination.

--
Added file: 
http://bugs.python.org/file33693/larry.clinic.rollup.jan.24.diff.1.txt

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



  1   2   >