[Python-Dev] A misredirected ticket link in hg.python.org/cpython

2014-02-19 Thread Vajrasky Kok
Go to any commit link in hg.python.org/cpython, for example
http://hg.python.org/cpython/rev/d11ca14c9a61.

You have this commit message:

Issue #6815: os.path.expandvars() now supports non-ASCII Unicode
environment variables names and values. [#6815]

The [#6815] link is going to http://bugs.python.org/6815. If you
follow that link, it redirects to http://legacy.python.org/sf/ and you
get message: You did not provide a report number. The link should be
http://bugs.python.org/issue6815.

Cheers,
Vajrasky Kok
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] The desired behaviour for resolve() when the path doesn't exist

2014-02-16 Thread Vajrasky Kok
On Wed, Jan 8, 2014 at 4:45 AM, Serhiy Storchaka storch...@gmail.com wrote:
 --canonicalize is not strict. --canonicalize-existing is most strict and
 --canonicalize-missing is least strict. When you have a function which have
 non-strict behavior (--canonicalize), you can implement a wrapper with
 strict behavior (--canonicalize-existing), but not vice verse.


Sorry, only now that I have time to look into this. So what we are
going to do before implementing the behaviour for
resolve(strict=False) is to change the behaviour of
resolve(strict=True) from --canonicalize-existing to --canonicalize?
Is there any time left because we are in RC1 already? Should we
postpone it to 3.5? But then, we'll have backward compatibility
problem.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-27 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 5:38 PM, Antoine Pitrou solip...@pitrou.net wrote:

 I would say not backport at all. The security threat is highly
 theoretical. If someone blindly accepts user values for repeat(), the
 user value can just as well be a very large positive with similar
 effects (e.g. 2**31).


I can not comment about whether this is security issue or not. But the
effect of large positive number is not similar to the effect of
unlimited repetitions.

 from itertools import repeat
 list(repeat('a', 2**31))
Traceback (most recent call last):
  File stdin, line 1, in module
MemoryError
 list(repeat('a', 2**99))
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: Python int too large to convert to C ssize_t
 list(repeat('a', times=-1))
...this freezes my computer...

That is why I prefer we backport the fix (either partial or full). If
not, giving a big warning in the documentation should suffice.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-27 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 9:13 PM, Larry Hastings la...@hastings.org wrote:

 I apologize for not making myself clear.  But that's part of what I meant,
 yes: we should preserve the existing behavior of times=-1 when passed in by
 position or by keyword.  However, we should *also* add a deprecation warning
 when passing times=-1 by keyword, suggesting that they use times=None
 instead.  The idea is that we could eventually remove the PyTuple_Size check
 and make times=-1 always behave like times=0.  In practice it'd be okay with
 me if we never did, or at least not until Python 4.


So we only add deprecation warning to only times=-1 via keyword or for
all negative numbers to times via keyword?

I mean, what about:
 from itertools import repeat
 list(repeat('a', times=-2))
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: Python int too large to convert to C ssize_t

Deprecation warning or not?
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-27 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 8:29 PM, Antoine Pitrou solip...@pitrou.net wrote:

 Sure, just adjust the number to fit the available memory (here, 2**29
 does the trick).


I get your point. But strangely enough, I can still recover from
list(repeat('a', 2**29)). It only slows down my computer. I can ^Z the
application then kill it later. But with list(repeat('a', times=-1)),
rebooting the machine is compulsory.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-27 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 9:13 PM, Larry Hastings la...@hastings.org wrote:


 While it's a bug, it's a very minor bug.  As Python 3.4 release manager, my
 position is: Python 3.4 is in beta, so let's not change semantics for
 purity's sakes now.  I'm -0.5 on adding times=None right now, and until we
 do we can't deprecate the old behavior.



I bow to your decision, Larry. So I believe the doc fix is required
then. I propose these for doc fix:

1. Keeps the status quo
=

 repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.'

We don't explain the meaning of negative `times`. Well, people
shouldn't repeat with negative times because statement such as, Kids,
repeat the push-up
negative two times more., does not make sense.

2. Explains the negative times, ignores the keyword
=

 repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.
Negative times means zero repetitions.'

The signature repeat(object [,times]) suggest this function does not
accept keyword as some core developers have stated. So if the user
uses keyword with this function,
well, it's too bad for them.

3. Explains the negative times, warns about keyword
==

 repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.
Negative times means zero repetitions.  This function accepts keyword
argument but the behaviour is buggy and should be avoided.'

4. Explains everything


 repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.
Negative times means zero repetitions via positional-only arguments.
-1 value for times via keyword means endless repetitions and is same
as omitting
times argument and other negative number for times means endless
repetitions as well but with different implementation.'

If you are wondering about the last statement:
 from itertools import repeat
 list(repeat('a', times=-4))
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: Python int too large to convert to C ssize_t
 a = repeat('a', times=-4)
 next(a)
'a'
 next(a)
'a'
 a = repeat('a', times=-1)
 next(a)
'a'
 next(a)
'a'
 list(repeat('a', times=-1))
... freezes your computer ...

Which one is better? Once we settle this, I can think about the doc
fix for Doc/library/itertools.rst.

Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-26 Thread Vajrasky Kok
Dear comrades,

I would like to bring to your attention my disagreement with Larry
Hastings in this ticket: http://bugs.python.org/issue19145
(Inconsistent behaviour in itertools.repeat when using negative
times).

Let me give you the context:

 from itertools import repeat
 repeat('a')
repeat('a')
 repeat('a', times=-1)
repeat('a')
 repeat('a', -1)
repeat('a', 0)
 repeat('a', times=-4)
repeat('a', -4)
 repeat('a', -4)
repeat('a', 0)

Right now, the only way you can tell repeat to do endless repetitions
is to omit the `times` argument or by setting `times` argument to -1
via keyword.

Larry intends to fix this in Python 3.5 by making None value to
`times` argument as a representative of unlimited repetitions and
negative `times` argument (either via keyword or positional) ALWAYS
means 0 repetitions. This will ensure repeat has the appropriate
signature. I have no qualms about it. All is well.

My disagreement is related to Larry's decision not to fix this bug in
Python 2.7, 3.3, and 3.4. Both of us agree that we should not let
Python 2.7, 3.3, and 3.4 happily accepts None value because that is
more than bug fix. What we don't agree is whether we should make
negative `times` argument via keyword behaviour needs to be changed or
not. He prefer let it be. I prefer we change the behaviour so that
negative `times` argument in Python 2.7, 3.3, and 3.4 ALWAYS means 0
repetitions.

My argument is that, on all circumstances, argument sent to function
via positional or keyword must mean the same thing.

Let's consider this hypothetical code:

# 0 means draw, positive int means win, negative int means lose
result = goals_result_of_the_match()

# For every goal of the winning match, we donate money to charity.
# Every donation consists of 10 $.
import itertools
itertools.repeat(donate_money_to_charity(), result)

Later programmer B refactor this code:

# 0 means draw, positive int means win, negative int means lose
result = goals_result_of_the_match()

# For every goal of the winning match, we donate money to charity.
# Every donation consists of 10 $
from itertools import repeat
repeat(object=donate_money_to_charity(), times=result)

They use Python 2.7 (remember Python 2.7 is here to stay for a long
long time). And imagine the match is lost 0-1 or 1-2 or 2-3 (so the
goal difference is negative one / -1). It means they donate money to
charity endlessly!!! They can go bankrupt.

So I hope my argument is convincing enough. We need to fix this bug in
Python 2.7, 3.3, and 3.4, by making `times` argument sent via
positional or keyword in itertools.repeat ALWAYS means the same thing,
which is 0 repetitions.

If this is not possible, at the very least, we need to warn this
behaviour in the doc.

Whatever decision that comes up from this discussion, I will make peace with it.

Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-26 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 12:20 PM, Alexander Belopolsky
alexander.belopol...@gmail.com wrote:

 +1

 A partial backport will do a disservice to both users and maintainers.

In case we are taking not backporting anything at all road, what is
the best fix for the document?

Old
 itertools.repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.'


New
 itertools.repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.

If times is specified through positional and negative numbers, it
always means 0 repetitions.
If times is specified through keyword and -1, it means endless
repetition. Other negative numbers for times through keyword should be
avoided.'
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

2014-01-26 Thread Vajrasky Kok
On Mon, Jan 27, 2014 at 12:02 PM, Nick Coghlan ncogh...@gmail.com wrote:


 That is, I'm OK with either not backporting anything at all, or
 backporting the full change. The only idea I object to is the one of
 removing the infinite iteration capability without providing a
 replacement spelling for it.


Is repeat('a') (omitting times argument) not a replacement spelling for it?

What about this alternative? Makes -1 consistently mean unlimited
repetition and other negative numbers consistently mean zero
repetitions then document this behaviour. Just throwing suggestion. I
am not so keen to it, though.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] .clinic.c vs .c.clinic

2014-01-20 Thread Vajrasky Kok

 The contestants so far:

 Contestant 1: Add .clinic.h

 foo.c - foo.c.clinic.h
 foo.h - foo.h.clinic.h

+0


 Contestant 2: Add .ac.h

 foo.c - foo.c.ac.h
 foo.h - foo.h.ac.h

+1


 Contestant 3: Add .clinic

 foo.c - foo.c.clinic
 foo.h - foo.h.clinic

+0


 Contestant 4: Put in clinic directory, add .h

 foo.c - clinic/foo.c.h
 foo.h - clinic/foo.h.h

-1


 Contestant 5: Put in __clinic__ directory, add .h

 foo.c - __clinic__/foo.c.h
 foo.h - __clinic__/foo.h.h

-1
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Signature of function with default value uncapturable in Python and C

2014-01-15 Thread Vajrasky Kok
Dear friends,

 from itertools import repeat
 list(repeat('a', 3))
['a', 'a', 'a']
 list(repeat('a', 0))
[]
 repeat.__doc__
'repeat(object [,times]) - create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.'

If you omit the times argument:

 list(repeat('a'))
... unlimited of a  sometimes it can hang your machine 

In the C code it self, the default value of variable handling times
argument is -1. It checks how many arguments you give to the function.
So if you give -1 directly:

 list(repeat('a', -1))
[]

Negative value of times argument means 0.

So what is the correct signature of this function? The value is not
really capturable in Python and C.

repeat(object [,times = unlimited]) 

Can we do this in Clinic? If not, should we?

Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] The desired behaviour for resolve() when the path doesn't exist

2014-01-06 Thread Vajrasky Kok
Dear friends,

This is related with ticket 19717: resolve() fails when the path
doesn't exist.

Assuming /home/cutecat exists but not /home/cutecat/aa,

what is the desired output of
Path('/home/cutecat/aa/bb/cc').resolve(strict=False)?

Should it be:

/home/cutecat (the existed path only),
/home/cutecat/aa (the first non-existed path; my current strategy), or
/home/cutecat/aa/bb/cc (the default behaviour of os.path.realpath)?

Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How long the wrong type of argument should we limit (or not) in the error message (C-api)?

2013-12-14 Thread Vajrasky Kok
On Sun, Dec 15, 2013 at 7:52 AM, Victor Stinner
victor.stin...@gmail.com wrote:

 Oh, I like this proposition! The following pattern is very common in Python:

 ... %.400s ..., Py_TYPE(self)-tp_name


Okay, I have created ticket (and preliminary patch) for this
enhancement: http://bugs.python.org/issue19984

Vajrasky Kok
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] How long the wrong type of argument should we limit (or not) in the error message (C-api)?

2013-12-13 Thread Vajrasky Kok
Greetings,

When fixing/adding error message for wrong type of argument in C code,
I am always confused, how long the wrong type is the ideal?

The type of error message that I am talking about:

Blabla() argument 1 must be integer not wrong_type.

We have inconsistency in CPython code, for example:

Python/sysmodule.c
===
PyErr_Format(PyExc_TypeError,
can't intern %.400s, s-ob_type-tp_name);

Modules/_json.c

PyErr_Format(PyExc_TypeError,
 first argument must be a string, not %.80s,
 Py_TYPE(pystr)-tp_name);


Objects/typeobject.c
===
PyErr_Format(PyExc_TypeError,
 can only assign string to %s.__name__, not '%s',
 type-tp_name, Py_TYPE(value)-tp_name);

So is it %.400s or %.80s or %s? I vote for %s.

Other thing is which one is more preferable? Py_TYPE(value)-tp_name
or value-ob_type-tp_name? I vote for Py_TYPE(value)-tp_name.

Or this is just a matter of taste?

Thank you.

Vajrasky Kok
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Running the unit test as root/administrator

2013-12-05 Thread Vajrasky Kok
On Thu, Dec 5, 2013 at 11:06 PM, Martin v. Löwis mar...@v.loewis.de wrote:

 Can you please phrase your question more explicit? What is it that
 you want to be done before writing unit tests for the spwd module?

I am asking buildbot of Linux/Unix/BSD with root account. Do we have it now?


 Anybody could run the test suite, and somebody might run it as root -
 so you must be asking for something else.


Of course, I can write unit test for spwd module right now and mark it
only to be run with root account and skipped with regular user
account. But I would argue that it would be hard to find people
running test suite with root account. That's why buildbot is helping
much in this case.

--Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Running the unit test as root/administrator

2013-12-04 Thread Vajrasky Kok
On Thu, Dec 5, 2013 at 7:07 AM, Brian Curtin br...@python.org wrote:

 Not helpful.

 I'm in meetings/training/traveling all week, but I'll get another Windows
 build slave up within the next few days. I used to have a spare desktop box
 that ran a build slave as admin so it would exercise the os.symlink code,
 but I moved, then the box died, etc.



Cool. What about Linux/Unix/BSD with root account? If we have
something similar, I may plan to write unit test for spwd module.

--Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Running the unit test as root/administrator

2013-12-03 Thread Vajrasky Kok
Greetings, comrades!

Having handled these two issues personally:

http://bugs.python.org/issue19877
- test related with symlink fails on Windows Vista with administrator
account (in Windows NT 6, only account in administrator group can
create symlink)
http://bugs.python.org/issue18678
- bug in spwd module, which can be used only by root

I believe there is a virtue of running the unit test as
root/administrator to catch these errors automatically. Currently
there is no unit test for spwd module.

What do you say, comrades?

--Vajrasky
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com