Re: What is elegant way to do configuration on server app

2015-03-26 Thread Ben Finney
Jerry OELoo oylje...@gmail.com writes:

 Currently, I can just think out that I put status into a configure
 file, and service schedule read this file and get status value,

That sounds like a fine start. Some advice:

* You may be tempted to make the configuration file executable (e.g.
  Python code). Resist that temptation; keep it *much* simpler, a
  non-executable data format.

  Python's standard library has the ‘configparser’ module
  URL:https://docs.python.org/3/library/configparser.html to parse and
  provide the values from a very common configuration file format.
  Use that unless you have a good reason not to.

* Your program can “poll” the configuration file to see whether it has
  changed. At startup, read the config file's modification timestamp
  URL:https://docs.python.org/3/library/os.html#os.stat_result.st_mtime.

  Make a part of your event loop (assuming your server runs an event
  loop) that wakes up every N seconds (e.g. every 60 seconds) and
  checkes the file's modification timestamp again; if it's newer, record
  that value for future comparisons, then re-read the file for its
  values.

Hope that helps.

-- 
 \ “For your convenience we recommend courteous, efficient |
  `\self-service.” —supermarket, Hong Kong |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23782] Leak in _PyTraceback_Add

2015-03-26 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

There is a leak of fetched exception in _PyTraceback_Add() 
(Python/traceback.c:146).

--
messages: 239319
nosy: georg.brandl, haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Leak in _PyTraceback_Add
type: resource usage

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



[issue23780] Surprising behaviour when passing list to os.path.join.

2015-03-26 Thread Pikec

Boštjan Mejak (Pikec) added the comment:

Using Python 3.4.3 on Windows 7 Home Premium 64 bit, Service Pack 1:

 import os
 os.path.join([1, 2, 3])
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Program Files\Python 3.4\lib\ntpath.py, line 108, in join
result_drive, result_path = splitdrive(path)
  File C:\Program Files\Python 3.4\lib\ntpath.py, line 161, in splitdrive
normp = p.replace(_get_altsep(p), sep)
AttributeError: 'list' object has no attribute 'replace'

I think this atribute error should be handled differently, like informing the 
programmer that you cannot use a list in the join method.

--
nosy: +Boštjan Mejak (Pikec)

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



[issue18408] Fixes crashes found by pyfailmalloc

2015-03-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b742c1c5c0bf by Victor Stinner in branch 'default':
PEP 490: add issue 18408
https://hg.python.org/peps/rev/b742c1c5c0bf

--

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



[issue23781] Add private _PyErr_ReplaceException() in 2.7

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

FIY I'm working on a draft of new PEP to chain exceptions at C level: PEP 490.

--

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



Re: Sudoku solver

2015-03-26 Thread Frank Millman

Marko Rauhamaa ma...@pacujo.net wrote in message 
news:87r3sdnw5t@elektro.pacujo.net...


 I post below a sudoku solver. I eagerly await neater implementations (as
 well as bug reports).


Here is another python-based sudoku solver -

http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py

From its docstring -

A proper Sudoku puzzle must have a unique solution, and it should be 
possible to reach that solution by a sequence of logical deductions without 
trial and error.  To the extent possible, we strive to keep the same ethic 
in our automated solver, by mimicking human rule-based reasoning, rather 
than resorting to brute force backtracking search.

A neat feature is that, having printed the solution, it then lists every 
step it took in its reasoning process to arrive at the solution.

It solved Marko's original puzzle and Ian's puzzle in less than a second. It 
could not solve Marko's second one, returning impossible immediately.

Here is another one that does not use python, but uses SQL -

https://www.sqlite.org/lang_with.html

You will find it at the bottom of the page, under the heading Outlandish 
Recursive Query Examples.

Frank Millman



-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-26 Thread Ivan Evstegneev


 -Original Message-
 From: Python-list [mailto:python-list-
 bounces+webmailgroups=gmail@python.org] On Behalf Of Steven
 D'Aprano
 Sent: Thursday, March 26, 2015 01:49
 To: python-list@python.org
 Subject: Re: Function Defaults - avoiding unneccerary combinations of
 arguments at input
 
 On Thu, 26 Mar 2015 04:43 am, Ivan Evstegneev wrote:
 
  Hello all ,
 
 
  Just a little question about function's default arguments.
 
  Let's say I have this function:
 
  def  my_fun(history=False, built=False, current=False, topo=None,
  full=False, file=None):
  if currnet and full:
  do something_1
  elif current and file:
  do something_2
  elif history and full and file:
  do something_3
 
 
 This is an extreme example that shows why Guido's Law No constant
 arguments is a good design principle. (Well, it's not really so much a
law as a
 guideline.)
 
 If you have a function that looks like this:
 
 def spam(arg, flag=True):
 if flag:
 return do_this(arg)
 else:
 return do_that(arg)
 
 
 then you should just use do_this and do_that directly and get rid of spam.
 
 In your case, its hard to say *exactly* what you should do, since you are
only
 showing a small sketch of my_fun, but it looks to me that it tries to do
too
 much. You can probably split it into two or four smaller functions, and
avoid
 needing so many (or any!) flags.
 
 That will avoid (or at least reduce) the need to check for mutually
 incompatible sets of arguments.
 
 Another useful design principle: if dealing with the combinations of
 arguments is too hard, that's a sign that you have too many combinations
of
 arguments.
 
 If there are combinations which are impossible, there are three basic ways
to
 deal with that. In order from best to worst:
 
 
 (1) Don't let those combinations occur at all. Redesign your function, or
split
 it into multiple functions, so the impossible combinations no longer
exist.
 
 (2) Raise an error when an impossible combination occurs.
 
 (3) Just ignore one or more argument so that what was impossible is now
 possible.
 
 
 
 
 --
 Steven
 
 --
 https://mail.python.org/mailman/listinfo/python-list



Hello Steven,

As I said in a previous mail, main purpose of this arguments is to define
what path should be chose. It is actually one xls file that could be placed
into various placed within my folder tree. 

For instance, I have following folder tree:

data_lib/
current/
history/
built/

Say  I have test.xls that could be in one of those three folders. 
I wrote a function that reads it out, and its input arguments just define
where it should be read. So  all those ifs related to path definition.



Still now I'm thinking to really split it out...  I'll have a separate
function for path definition and then it will call a common reader_fun() in
order to read this file.


Sincerely,

Ivan



-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23781] Add private _PyErr_ReplaceException() in 2.7

2015-03-26 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch adds internal private function _PyErr_ReplaceException() in 2.7. 
This functions is like _PyErr_ChainExceptions() in 3.x, but doesn't set the 
context. It makes the code of 2.x simpler and more similar to 3.x and makes the 
backporting from 3.x easier.

--
components: Interpreter Core
files: capi_PyErr_ReplaceException.patch
keywords: patch
messages: 239317
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Add private _PyErr_ReplaceException() in 2.7
type: enhancement
versions: Python 2.7
Added file: http://bugs.python.org/file38697/capi_PyErr_ReplaceException.patch

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



What is elegant way to do configuration on server app

2015-03-26 Thread Jerry OELoo
Hi.
I have used python to provide a web service app, it will running 7*24,
and it will return some data to client by API.

Now I want to add some extra data in return data, ex, status = 1,
and I want this value 1 can be configured, that means I can control
that service app return status with 0, 1 or other value, and I want to
keep service running always.

Currently, I can just think out that I put status into a configure
file, and service schedule read this file and get status value, Is
there any other elegant way to achieve this? What is standard way in
python for this requirement?

Thanks!


Best Regards
Jerry

-- 
Rejoice,I Desire!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23780] Surprising behaviour when passing list to os.path.join.

2015-03-26 Thread Boštjan Mejak

Changes by Boštjan Mejak bostjan.xpe...@gmail.com:


--
versions: +Python 3.5

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



Re: Supply condition in function call

2015-03-26 Thread Cameron Simpson

On 26Mar2015 10:03, Peter Otten __pete...@web.de wrote:

Cameron Simpson wrote:

  vars = locals()
  varnames = list(vars.keys())


That leaves varnames in undefined order. Consider

varnames = sorted(vars)


Actually, not necessary.

I started with sorted, but it is irrelevant, so I backed off to list to avoid 
introducing an unwarranted implication, in fact precisely the implicaion you 
are making.


The only requirement, which I mentioned, is that the values used to initialise 
the namedtuple are supplied in the same order as the tuple field names, so all 
that is needed is to suck the .keys() out once and use them in the same order 
when we construct the namedtuple. Hence just a list.


Cheers,
Cameron Simpson c...@zip.com.au
--
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Ian Kelly
On Wed, Mar 25, 2015 at 1:49 PM, Tiglath Suriol tiglathsur...@gmail.com wrote:
 Two possibilities:

You are a moderator. If you are a moderator you are welcome to delete my 
 tests posts. This is of course improbably because this newsgroup is not 
 moderated.

 The other possibility is that you are just a guy, who despite the fact that 
 my posts cost you nothing, and you are absolutely free to ignore them, your 
 life is so dull that that you just must intervene and comment on anything you 
 do not comprehend, because appointing yourself net cop is about as exciting 
 as it gets.

 It's a free country, I know.  You have every right to engage in pathetic 
 speech.

 To that guy I say:  

 It's safe, you can't go back to watching grass grow.

*plonk*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Peter Otten
Cameron Simpson wrote:

 On 26Mar2015 07:27, Manuel Graune manuel.gra...@koeln.de wrote:
Gary Herron gher...@digipen.edu writes:
 On 03/25/2015 10:29 AM, Manuel Graune wrote:
 def test1(a, b, condition=True):
  for i,j in zip(a,b):
  c=i+j
  if eval(condition):
 print(Foo)

 test1([0,1,2,3],[1,2,3,4],i+j 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],c 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],a[i] 2)

 This is nicely done with lambda expressions:

 To pass in a condition as a function:
test1([0,1,2,3],[1,2,3,4], lambda i,j: i+j4)

 To check the condition in the function:
 if condition(i,j):

This seems to be the right direction and a good solution for simple
cases. Unfortunately this:

 To get the full range of conditions, you will need to include all the
 variables needed by any condition you can imagine.  So the above
 suggestions may need to be expanded to:
  ... lambda i,j,a,b: ... or whatever

 and
   ... condition(i,j,a,b) ... or whatever


is not as concise as I had hoped for. Is there a possibility to do
(maybe with a helper function inside the main function's body) solve
this more elegantly? I'm thinking of some combination of e. g. **kwargs,
dir() and introspection.
 
 Yes.
 
 Consider locals():
 
   https://docs.python.org/3/library/functions.html#locals
 
 which is a built in function returning a copy of the current local
 variables in a dict. Example:
 
   condition_test = lambda vars: vars['i'] + vars[j']  4
 
   def test1(a, b, condition):
 for i, j in zip(a,b):
   c = i + j
   if condition(locals()):
 print(Foo)
 
   test1([0,1,2,3], [1,2,3,4], condition_test)
 
 This passes the local variables inside test1() to condition as a single
 parameter. Now, I grant that vars['i'] is a miracle of tediousness. So
 consider this elaboration:
 
   from collections import namedtuple
 
   condition_test = lambda vars: vars.i + vars.j  4
 
   def test1(a, b, condition):
 for i, j in zip(a,b):
   c = i + j
   vars = locals()
   varnames = list(vars.keys())

That leaves varnames in undefined order. Consider

varnames = sorted(vars)

instead or pass the list of arguments explicitly, optionally with some 
inspect fallback:

$ cat pass_condition_inspect.py
import inspect

def test3(a, b, condition, args=None):
if args is None:
args = inspect.getargspec(condition).args

for i, j in zip(a,b):
c = i + j
_locals = locals()
if condition(*[_locals[name] for name in args]):
print(Foo, i, j)

def condition(c, i):
return i * i  c

test3([1, 2, 3], [2, 3, 4], condition)
print(---)
# note reverse order of argument names
test3([1, 2, 3], [2, 3, 4], condition, [i, c]) 
$ python3 pass_condition_inspect.py
Foo 3 4
---
Foo 1 2
Foo 2 3
Foo 3 4

A simpler alternative is changing the signature of condition() and passing 
keyword arguments:

$ cat pass_condition.py
def test2(a, b, condition):
for i, j in zip(a,b):
c = i + j
if condition(**locals()):
print(Foo, i, j)

def condition(c, i, **unused):
return i * i  c

test2([1, 2, 3], [2, 3, 4], condition)
$ python3 pass_condition.py 
Foo 3 4

Creating a locals() dict on every iteration is still costly, and personally 
I would prefer the tighter interface where you pass a limited set of 
arguments explicitly.

   varstupletype = namedtuple(locals, varnames)
   varstuple = varstupletype(*[ vars[k] for k in varnames ])
   if condition(varstuple):
 print(Foo)
 
 Here, the condition_test function/lambda uses vars.i and vars.j, which
 i think you'll agree is easier to read and write. The price is the
 construction of a namedtuple to hold the variable name values. See:
 
   
https://docs.python.org/3/library/collections.html#collections.namedtuple
 
 So the (untested) code above:
 
   - get the locals() as before
   - get the names of the variables; it is important to have this in a
   array because we need to access the values in the same order when we
   make the tuple - make a new namedtuple class varstupletype, which is
   used to make the named tuple - make the named tuple itself with the
   values of the variables in order
 
 If you're writing a lot of test functions like test1 you can push the
 namedtuple stuff off into a helper function:
 
   def vartuple(vars):
 varnames = list(vars.keys())
 varstupletype = namedtuple(locals, varnames)
 varstuple = varstupletype(*[ vars[k] for k in varnames ])
 return varstuple
 
 and then test1() can look like this:
 
   def test1(a, b, condition):
 for i, j in zip(a,b):
   c = i + j
   if condition(vartuple(locals())):
 print(Foo)
 
 which makes it much easier to write test2 and so on later.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module attributes and docstrings

2015-03-26 Thread Mario Figueiredo
Sorry for the late reply. We experienced a 3 day blackout following
one of the most amazing thunderstorms I've witnessed in my life.

On Tue, 24 Mar 2015 22:49:49 +1100, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Tue, 24 Mar 2015 07:55 pm, Mario Figueiredo wrote:

 Reading PEP 257 and 258 I got the impression that I could document
 module attributes and these would be available in the __doc__
 attribute of the object.

PEP 258 is rejected, so you can't take that as definitive.

Ah! That explains it then. Thank you.

(Also learned to start paying more attention to the status field).


PEP 257 has this definition very early in the document:

A docstring is a string literal that occurs as the first 
statement in a module, function, class, or method definition.


Nothing there about documenting arbitrary attributes.

That did get me a little confused. But since PEP 258 required PEP 257,
I just assumed the former would redefine the latter and didn't make
much of the apparent contradiction.


Even if there was support from the compiler to extract the docstring, where
would it be stored? Consider:

spam = None
Spammy goodness.
eggs = None
Scrambled, not fried.

There's only one None object, and even if it could take a docstring (and it
can't), which docstring would it get? Presumably the second, which would
make help(spam) confusing, but when we say eggs = 23 the docstring would
disappear too.

This is a byproduct of me still thinking in terms of C variables. When
I first read that paragraph of yours, it didn't make sense to me --
What is he talking about? I'm documenting the spam and eggs
identifiers, not the None object.

But when I was trying to reply to you by mounting a case around
writing directly to the __doc__ attribute of the spam and eggs
identifiers, the python shell was quick to make me realized my
foolishness, and I remembered about Python variables not being the
same as C variables.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module attributes and docstrings

2015-03-26 Thread Mario Figueiredo
On Tue, 24 Mar 2015 15:33:41 -0400, Terry Reedy tjre...@udel.edu
wrote:


You have discovered one of advantages of a def statement over a 
name=lambda assignment statement.  In Python, there is no good reason to 
use the latter form and PEP 8 specifically discourages it: Always use a 
def statement instead of an assignment statement that binds a lambda 
expression directly to an identifier.

Chris also suggested me this. And frankly, I don't see why I shouldn't
follow that advise. It's good advice.

However, lambda functions do read well in my mind and I find it hard
to spot where they obscure the code more than a function. So the
explicit vs. implicit part of the argument doesn't translate well with
me. I however agree that a function declaration brings other benefits,
like the ability to decorate or document.

I will reserve the use of lambdas to only where they are necessary.
Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module attributes and docstrings

2015-03-26 Thread Chris Angelico
On Thu, Mar 26, 2015 at 8:53 PM, Mario Figueiredo mar...@gmail.com wrote:
 However, lambda functions do read well in my mind and I find it hard
 to spot where they obscure the code more than a function. So the
 explicit vs. implicit part of the argument doesn't translate well with
 me. I however agree that a function declaration brings other benefits,
 like the ability to decorate or document.

A function is a function is a function, so really, it's just a
question of whether you create them with a statement (def) or an
expression (lambda). Two basic rules of thumb:

1) If you're assigning a lambda function to a simple name, then you
don't need it to be an expression, so use def.
2) If you're warping your function body to make it an expression, use def.

Basically, look at the outside and look at the inside. In some cases,
it's obvious that it's all expressions:

# Sort a list of widget objects by name
widgets.sort(key=lambda w: w.name)

Other times, it's pretty obvious that you should be using statements:

delete_name_if_blank = lambda w: delattr(w, name) if w.name ==  else None
list(map(delete_name_if_blank, widgets))

In between, there's a lot of room to call it either way.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23782] Leak in _PyTraceback_Add

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

If a new exception is raised by _PyTraceback_Add(), the original exception is 
lost. It's sad because _PyTraceback_Add() is supposed to enhance the current 
exception, not to drop it.

In the draft of my PEP 490, I propose to chain the two exceptions.

--

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



[issue18828] urljoin behaves differently with custom and standard schemas

2015-03-26 Thread Martin Panter

Martin Panter added the comment:

The current behaviour when no scheme is present is fairly sensible to me and 
should not be changed to do string concatenation nor raise an exception:

 urljoin(//netloc/old/path, new/path)
'//netloc/old/new/path'

I am posting urljoin-non-hier.patch as an alternative to my first patch. This 
one changes urljoin() to work on any URL scheme not in the existing 
“non_hierarchical” blacklist. I removed the gopher, wais, and imap schemes from 
the list, and added tel, so that urljoin() continues to treat these special 
cases as before. Out of the schemes mentioned in the module but missing from 
uses_relative, I think non_hierarchical now has all those without directory 
components: hdl, mailto, news, sip, sips, snews, tel, telnet.

However I am still not really convinced that my first urljoin-scheme.patch is a 
bad idea. Do people actually use urljoin() with these schemes like mailto in 
the first place?

--
Added file: http://bugs.python.org/file38698/urljoin-non-hier.patch

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



Re: Regex Python Help

2015-03-26 Thread Denis McMahon
On Wed, 25 Mar 2015 14:19:39 -0700, Gregg Dotoli wrote:

 On Wednesday, March 25, 2015 at 4:36:01 PM UTC-4, Denis McMahon wrote:
 On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote:
 
  I am creating a tool to search a filesystem for one simple string.
 
 man grep
 
 STOP! REINVENTING! THE! WHEEL!
 
 Your new wheel will invariably be slower and less efficient than the
 old one.

 Grep is regular expressions. If I'm using Python, I'll use the Python
 modules.
 Silly

1. Please don't top post, this is usenet, we don't top post, comments go 
after the text they comment on soi we can read down the page and it makes 
sense.

2. You gave the thread the title of regex python help.

3. Your initial comment was I am creating a tool to search a filesystem 
for one simple string.

4. The tool (see 3) already exists, it's called grep, it uses regular 
expressions (see 2). It's also going to be a lot faster than using python.

5. According to your post, grep seems to be the tool you are looking for.

6. Reinventing grep in python seems much more silly to me, by the time 
you've finished writing and testing the python code (especially if you 
need to seek help from a newsgroup in the process) grep would have found 
and identified every file containing your one simple string.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Peter Otten
Cameron Simpson wrote:

 On 26Mar2015 10:03, Peter Otten __pete...@web.de wrote:
Cameron Simpson wrote:
   vars = locals()
   varnames = list(vars.keys())

That leaves varnames in undefined order. Consider

varnames = sorted(vars)
 
 Actually, not necessary.
 
 I started with sorted, but it is irrelevant, so I backed off to list to
 avoid introducing an unwarranted implication, in fact precisely the
 implicaion you are making.
 
 The only requirement, which I mentioned, is that the values used to
 initialise the namedtuple are supplied in the same order as the tuple
 field names, so all that is needed is to suck the .keys() out once and use
 them in the same order when we construct the namedtuple. Hence just a
 list.

You are right. 

Once I spotted the error I failed to notice that you pass the named tuple 
as a single argument, i. e. condition(nt), not condition(*nt) :(

By the way, in this case you don't need the list at all:

def vartuple(vars):
return namedtuple(locals, vars)._make(vars.values())


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23784] Reloading tokenize module leads to error

2015-03-26 Thread David Marks

New submission from David Marks:

On 432 in tokenize.py there is an assignment

_builtin_open = open

Followed in 434 with a redefinition of open

def open(filename):

If the module is reloaded, _builtin_open gets reassigned to the new function 
and subsequent calls to _builtin_open fail.

--
components: Library (Lib)
messages: 239322
nosy: dmarks
priority: normal
severity: normal
status: open
title: Reloading tokenize module leads to error
type: behavior
versions: Python 3.4

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



Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Abhiram R abhi.darkn...@gmail.com:

 On Thu, Mar 26, 2015 at 8:54 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R abhi.darkn...@gmail.com wrote:
 On Mar 26, 2015 5:39 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 $ cat sudoku2.dat
 . . . 7 . . . . .
 1 . . . . . . . .
 . . . 4 3 . 2 . .
 . . . . . . . . 6
 . . . 5 . 9 . . .
 . . . . . . 4 1 8
 . . . . 8 1 . . .
 . . 2 . . . . 5 .
 . 4 . . . . 3 . .

 I tried the first puzzle you posted, and it took about a second. I
 then started running it on this one before I started typing up this
 post, and it hasn't finished yet.

 So... Is it done yet? And if yes, how long did it take?

 I don't know, I killed it at about 16 minutes.

 :( Too bad. I'll give it a go myself. And then try implementing my own
 solution. Have a lot of time on my hands today :D

Early optimization and so on and so forth...

I have optimized my solution slightly:

  1. precalculated integer division operations (big savings)

  2. interned integers (little savings)

The example above now finishes in 41 minutes on my computer. (The C
version finishes in 13 seconds).

The program runs single-threaded. Taking the trouble to parallelize the
algorithm is out of scope for the purposes of this discussion; it would
necessarily destroy the compactness of the solution.


#!/usr/bin/env python3

import sys

M = 3
N = M * M
P = M * N
Q = M * P

buddies = [ [ buddy
  for buddy in range(Q)
  if buddy != slot and
  (buddy % N == slot % N or
   buddy // N == slot // N or
   buddy // P == slot // P and
   buddy % N // M == slot % N // M) ]
for slot in range(Q) ]
interned = { n : n for n in range(1, N + 1) }
candidates = list(interned.values())

def main():
board = []
for n in sys.stdin.read().split():
try:
board.append(int(n))
except ValueError:
board.append(None)
solve(board)

def solve(board, slot=0):
if slot == Q:
report(board)
elif board[slot] is None:
for candidate in candidates:
if not any(board[buddy] is candidate for buddy in buddies[slot]):
board[slot] = candidate
solve(board, slot + 1)
board[slot] = None
else:
solve(board, slot + 1)

def report(board):
print(\n.join(
 .join(str(board[row * N + col])
 for col in range(N))
for row in range(N)))
print()

if __name__ == '__main__':
main()



Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23783] Leak in PyObject_ClearWeakRefs

2015-03-26 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

If restore_error == 1 in PyObject_ClearWeakRefs() (Objects/weakrefobject.c:883) 
and PyTuple_New() fails in Objects/weakrefobject.c:923, PyErr_Fetch is called 
twice and both exceptions leak.

--
components: Extension Modules
messages: 239320
nosy: fdrake, haypo, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Leak in PyObject_ClearWeakRefs
type: resource usage

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



RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-26 Thread Steven D'Aprano
On Thu, 26 Mar 2015 08:47 pm, Ivan Evstegneev wrote:

 
 
 -Original Message-
 From: Python-list [mailto:python-list-
 bounces+webmailgroups=gmail@python.org] On Behalf Of Steven
 D'Aprano
 Sent: Thursday, March 26, 2015 01:49
 To: python-list@python.org
 Subject: Re: Function Defaults - avoiding unneccerary combinations of
 arguments at input
 
 On Thu, 26 Mar 2015 04:43 am, Ivan Evstegneev wrote:
 
  Hello all ,
 
 
  Just a little question about function's default arguments.
 
  Let's say I have this function:
 
  def  my_fun(history=False, built=False, current=False, topo=None,
  full=False, file=None):
  if currnet and full:
  do something_1
  elif current and file:
  do something_2
  elif history and full and file:
  do something_3

[...]

 As I said in a previous mail, main purpose of this arguments is to define
 what path should be chose. It is actually one xls file that could be
 placed into various placed within my folder tree.
 
 For instance, I have following folder tree:
 
 data_lib/
 current/
 history/
 built/
 
 Say  I have test.xls that could be in one of those three folders.
 I wrote a function that reads it out, and its input arguments just define
 where it should be read. So  all those ifs related to path definition.

Perhaps something like this?

def my_func(subdir):
if subdir not in (current, history, built):
raise ValueError(invalid sub-directory)
# Better to use os.path.join, but I'm feeling lazy.
path = path/to/data_lib/ + subdir + /test.xls
process(path)




-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23784] Reloading tokenize module leads to error

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Fixed in issue23615.

--
nosy: +serhiy.storchaka
resolution:  - out of date
stage:  - resolved
status: open - closed

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



[issue23663] Crash on failure in ctypes on Cygwin

2015-03-26 Thread Masayuki Yamamoto

Masayuki Yamamoto added the comment:

similar issue #23338: PyErr_Format in ctypes uses invalid parameter

--
nosy: +masamoto

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



[issue23783] Leak in PyObject_ClearWeakRefs

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch should fix the issue.

--
keywords: +patch
stage:  - patch review
versions: +Python 2.7, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file38700/issue23783.patch

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



Fwd: test1

2015-03-26 Thread Igor Korot
 On Thu, Mar 26, 2015 at 9:01 AM, alister
alister.nospam.w...@ntlworld.com wrote:
 On Thu, 26 Mar 2015 00:36:49 +, Mark Lawrence wrote:

 On 26/03/2015 00:17, MRAB wrote:
 On 2015-03-25 22:36, Chris Angelico wrote:
 On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol
 tiglathsur...@gmail.com wrote:
 Two possibilities:

You are a moderator. If you are a moderator you are welcome to
 delete my tests posts. This is of course improbably because this
 newsgroup is not moderated.

 You misunderstand newsgroups and mailing lists. Posts do not get
 deleted after the event. Even on a web forum, where an administrator
 can delete posts, the information is already out there; the instant
 any one person has seen your post, you've lost control of it. So think
 about what you post - especially when (as in your other thread) it
 contains private information.

 The other possibility is that you are just a guy, who despite the
 fact that my posts cost you nothing, and you are absolutely free to
 ignore them, your life is so dull that that you just must intervene
 and comment on anything you do not comprehend, because appointing
 yourself net cop is about as exciting as it gets.

 It's a free country, I know.  You have every right to engage in
 pathetic speech.

 You also misunderstand freedom. I suggest you explore all three
 concepts (freedom, newsgroups, and mailing lists), and learn what
 you're actually dealing with. You may find the results rewarding.

 ChrisA

 A quick search suggests that he has prior form.

 How many years did he get?  Was it PHP or C++ ? :)

 i hope he has a good spam filter as I am about to sign him up for
 everything :-)

Well he did gave out his private key to the public in an ASCII format.
I wonder what people can do with it? ;-)




 --
 Violence in reality is quite different from theory.
 -- Spock, The Cloud Minders, stardate 5818.4
 --
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23784] Reloading tokenize module leads to error

2015-03-26 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
resolution: out of date - fixed

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



sys.exec_prefix doesn't seem to reflect --exec-prefix path

2015-03-26 Thread Ralph Heinkel
Hi,

on my linux box there is a python version 2.7.5 installed in /usr/local.

Now I want to install the newer version 2.7.9, but in a different directory to 
avoid clashes with the current installation.

What I did was:

./configure --prefix /usr/local/Python-2.7.9 --exec-prefix 
/usr/local/Python-2.7.9
make
make install

Everything looks fine, Python is installed in the proper directory.

BUT: When I run /usr/local/Python-2.7.9/bin/python and do 'print 
sys.exec_prefix' it prints '/usr/local' instead of '/usr/local/Python-2.7.9'.

This has the effect that the old libraries of version 2.7.5 are used instead of 
the 2.7.9 ones.

The docs in https://docs.python.org/2/library/sys.html state that 
sys.exec_prefix will reflect the value given to option --exec-prefix at 
configuration time. Any idea what I did wrong? 

Thanks for your help,

Ralph
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

If an exception was raised in TextIOWrapper.tell() and then restoring state is 
failed, original exception is lost and leaked.

--
components: Extension Modules
messages: 239327
nosy: benjamin.peterson, haypo, pitrou, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: Leak in TextIOWrapper.tell()
type: resource usage
versions: Python 2.7, Python 3.4, Python 3.5

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



Re: test1

2015-03-26 Thread alister
On Thu, 26 Mar 2015 00:36:49 +, Mark Lawrence wrote:

 On 26/03/2015 00:17, MRAB wrote:
 On 2015-03-25 22:36, Chris Angelico wrote:
 On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol
 tiglathsur...@gmail.com wrote:
 Two possibilities:

You are a moderator. If you are a moderator you are welcome to
 delete my tests posts. This is of course improbably because this
 newsgroup is not moderated.

 You misunderstand newsgroups and mailing lists. Posts do not get
 deleted after the event. Even on a web forum, where an administrator
 can delete posts, the information is already out there; the instant
 any one person has seen your post, you've lost control of it. So think
 about what you post - especially when (as in your other thread) it
 contains private information.

 The other possibility is that you are just a guy, who despite the
 fact that my posts cost you nothing, and you are absolutely free to
 ignore them, your life is so dull that that you just must intervene
 and comment on anything you do not comprehend, because appointing
 yourself net cop is about as exciting as it gets.

 It's a free country, I know.  You have every right to engage in
 pathetic speech.

 You also misunderstand freedom. I suggest you explore all three
 concepts (freedom, newsgroups, and mailing lists), and learn what
 you're actually dealing with. You may find the results rewarding.

 ChrisA

 A quick search suggests that he has prior form.
 
 How many years did he get?  Was it PHP or C++ ? :)

i hope he has a good spam filter as I am about to sign him up for 
everything :-)




-- 
Violence in reality is quite different from theory.
-- Spock, The Cloud Minders, stardate 5818.4
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23663] Crash on failure in ctypes on Cygwin

2015-03-26 Thread David Macek

David Macek added the comment:

Yeah, looks like exactly the same issue. Sorry for the duplicate.

--

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



Re: Basic Python V3 Search Tool using RE module

2015-03-26 Thread CHIN Dihedral
 Gregg Dotoli

Are you reminding everyone who had a PC running DOS2.X-3X in 1990. 

It was really a pain at that time 
that a hard disk of an intel-MS based PC was sold hundreds of dollars, and 
another pain was that the buyer had to use the disabled 
dir in DOS after buying a HD.


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Serhiy Storchaka

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


--
keywords: +patch
Added file: http://bugs.python.org/file38699/issue23785.patch

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



[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch chain original exception to the exception raised by 
setstate(saved_state). This matches the behavior of Python implementation.

--
stage:  - patch review

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



Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Frank Millman fr...@chagford.com:

 Here is another python-based sudoku solver -

 http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py

From its docstring -

 A proper Sudoku puzzle must have a unique solution, and it should be
 possible to reach that solution by a sequence of logical deductions
 without trial and error.

I don't think that statement holds water. Trial-and-error is at the
basis of deduction (reductio ad absurdum). The human solver employs it
in their head. The question is, what is the difference between
pen-and-paper and in-your-head for a computer program?

(Question: Are computers good at blindfold chess?)

 To the extent possible, we strive to keep the same ethic in our
 automated solver, by mimicking human rule-based reasoning, rather than
 resorting to brute force backtracking search.

That's cool...

 A neat feature is that, having printed the solution, it then lists
 every step it took in its reasoning process to arrive at the solution.

 It solved Marko's original puzzle and Ian's puzzle in less than a
 second. It could not solve Marko's second one, returning impossible
 immediately.

... but that realization greatly reduces the value of the solver.

I brought up sudoku solving as a real-world example of the usefulness
of exhaustive recursion. The concerns on astronomical execution times
must be considered but at the same time, one should realize things
aren't as bad as they would seem: exhaustion is a practical way to solve
sudoku puzzles and analogous programming challenges.

The compactness of a working sudoku solver should demonstrate something
about (1) the usefulness of recursion and (2) the expressive power of
Python.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-26 Thread Chris Angelico
On Thu, Mar 26, 2015 at 11:26 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Frank Millman fr...@chagford.com:

 Here is another python-based sudoku solver -

 http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py

From its docstring -

 A proper Sudoku puzzle must have a unique solution, and it should be
 possible to reach that solution by a sequence of logical deductions
 without trial and error.

 I don't think that statement holds water. Trial-and-error is at the
 basis of deduction (reductio ad absurdum). The human solver employs it
 in their head. The question is, what is the difference between
 pen-and-paper and in-your-head for a computer program?

Nothing. And solving a Sudoku puzzle - or any other puzzle - should
require no guessing. It should be possible to solve purely by logic.
Same goes for every other kind of puzzle out there; it's highly
unsatisfying to play Minesweeper and get to the end with a block of
four squares in a corner, two mines left, and no way of knowing which
diagonal has the mines and which is clear.

No trial-and-error, thanks.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-26 Thread Ian Kelly
On Mar 26, 2015 6:31 AM, Marko Rauhamaa ma...@pacujo.net wrote:

 Frank Millman fr...@chagford.com:

  Here is another python-based sudoku solver -
 
  http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py
 
 From its docstring -
 
  A proper Sudoku puzzle must have a unique solution, and it should be
  possible to reach that solution by a sequence of logical deductions
  without trial and error.

 I don't think that statement holds water. Trial-and-error is at the
 basis of deduction (reductio ad absurdum). The human solver employs it
 in their head. The question is, what is the difference between
 pen-and-paper and in-your-head for a computer program?

It's an accurate characterization of the sort of puzzles that are typically
presented as sudoku. I don't think that I have used trial and error, in my
head or otherwise, in any sudoku I have ever solved.

  It solved Marko's original puzzle and Ian's puzzle in less than a
  second. It could not solve Marko's second one, returning impossible
  immediately.

Perhaps this is why that puzzle was described as being so difficult: it
required steps that human solvers don't usually take.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: test1

2015-03-26 Thread Tiglath Suriol
On Thursday, March 26, 2015 at 6:41:15 PM UTC-4, Steven D'Aprano wrote:
 On Fri, 27 Mar 2015 07:00 am, BartC wrote:
 [...]
 
 Don't give the troll the attention he craves. He reacted with hostility and
 scorn when we gave him some friendly good advice, don't imagine for a
 second you're going to reason with him. He's admitted that he's been
 trolling for years, so don't bother to engage with him.
 
 The problem with wrestling a pig in the mud is that you get dirty and the
 pig enjoys it.
  
 
 -- 
 Steven

Steven exhorts you not to give me any attention, yet he posts three times to my 
thread. Go figure.

With enemies like this who needs friends...  

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23605] Use the new os.scandir() function in os.walk()

2015-03-26 Thread Ben Hoyt

Ben Hoyt added the comment:

Victor, great work on pushing this out, especially with the modifying the 
directories fix. (And thanks Serhiy for pushing on correctness here.)

Couple of comments/questions about your new os.walk() implementation.

1) The new implementation is more complex. Of course, most of this is necessary 
due to the topdown directory issue. However, one thing I'm not sure about is 
why you create scandir_it manually and use a while True loop, adding complexity 
and making it require two versions of the error handling. Why not a simple for 
entry in scandir(top): ... with a try/except OSError around the whole loop? I 
could well be missing something here though.

2) In this commit http://bugs.python.org/review/23605/diff/14181/Lib/os.py -- 
which is not the final one, I don't quite understand the catch_oserror thing. 
Presumably this turned out to be unnecessary, as it's not in the final version?

3) Really minor thing: in one of the comments, you misspell symbolik. Should 
be symbolic.

--

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



Re: test1

2015-03-26 Thread Tiglath Suriol
On Thursday, March 26, 2015 at 9:55:08 PM UTC-4, Denis McMahon wrote:
 On Thu, 26 Mar 2015 14:06:28 -0700, marcuslom101 wrote:
 
  I posted two test messages containing code.  They are still there, are
  you blind as well as dumb?
 
 The message that you posted at the start of this thread may have 
 contained code, but it wasn't python code, 

Every post you made in this thread is off-topic.  Pot-kettle?  

Seriously folks, is this the best you can do?  

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Tiglath Suriol
On Thursday, March 26, 2015 at 6:36:57 PM UTC-4, Steven D'Aprano wrote:
 On Fri, 27 Mar 2015 02:33 am, Joel Goldstick wrote:
 [...]
 
 Don't give the troll the attention he craves. He has as much told us that he
 is beyond reason -- he's been trolling for years, you don't need to justify
 your actions.
 

I don't lie to you folks.  I told you from the outset that I did come here to 
provoke anyone, and I have asked you to ignore me repeatedly, something trolls 
are not known to do, but since YOU STARTED it, and you want more, I am having 
fun with you, and I can keep it up until the hell freezes, I assure you. 
Because one usually has to pay for a ticket to laugh like this.  

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Rustom Mody
On Friday, March 27, 2015 at 7:26:54 AM UTC+5:30, Chris Angelico wrote:
 On Fri, Mar 27, 2015 at 12:41 PM, Rustom Mody  wrote:
  On a more specific note, its the 1st line:
 
  class filter(object)
 
  which knocks me off.
  If a more restricted type from the ABC was shown which exactly captures all
  the iterator-specific stuff like __iter__, __next__ it would sure help (me)
 
 But there's no point in subclassing for everything. In this case,
 filter doesn't subclass anything but object, so there's no value in
 stating anything else. You want to know if it's iterable? Check for an
 __iter__ method. Etcetera.

Well maybe... I dont the ABC thing very well in python.
[It does seem to be underutilized]

Anyway my point is that in python (after 2.2??) saying something is an object 
is a bit of a tautology -- ie verbiage without information.


Note: We are not talking of the *fact* that something -- in this case filter --
subclasses object, but the output of help(filter)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Tiglath Suriol
On Thursday, March 26, 2015 at 10:24:33 PM UTC-4, Mario Figueiredo wrote:
 On Thu, 26 Mar 2015 18:56:25 -0700 (PDT), 
 
 
 How disappointing, I was expecting something worth opposing.
 
 
 And that's bad? Successfully opposing a troll is like getting a medal
 for winning an argument with Spencer Pratt.
 
 Delusional pricks like you are only worth the 2 or 3 messages I care
 about writing for my own satisfaction. After that you just get as
 boring as the afore-mentioned idiot. Bye-bye!


All brawn no brain Mario lays down his confused rationale for leaving the field 
of battle after a couple of embarrassingly vulgar posts.  

Giving Mario an Internet connection just invites his reach to exceed his grasp. 



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Rustom Mody
On Friday, March 27, 2015 at 7:56:16 AM UTC+5:30, Ian wrote:
 On Thu, Mar 26, 2015 at 7:56 PM, Chris Angelico  wrote:
  On a more specific note, its the 1st line:
 
  class filter(object)
 
  which knocks me off.
  If a more restricted type from the ABC was shown which exactly captures all
  the iterator-specific stuff like __iter__, __next__ it would sure help (me)
 
  But there's no point in subclassing for everything. In this case,
  filter doesn't subclass anything but object, so there's no value in
  stating anything else. You want to know if it's iterable? Check for an
  __iter__ method. Etcetera.
 
 Also, filter is a builtin, while collections.abc.Iterable is in a
 library module written in Python, so there's a bootstrapping problem
 with having the one inherit from the other.

As I said to Chris, I am not talking of the facts but of the docs
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Steven D'Aprano
On Fri, 27 Mar 2015 01:21 pm, Rustom Mody wrote:

 Anyway my point is that in python (after 2.2??) saying something is an
 object is a bit of a tautology -- ie verbiage without information.


Er, it's *always* been a tautology. Every value in Python is an object,
including classes, and that has been always the case.

However, just because it's a tautology doesn't mean it isn't useful to know.
(Tautologies are also known as *facts* and knowing facts is usually a good
thing.) For the majority of programming languages, it is not the case that
all values are objects, and not all people reading the documentation should
be expected to know that this applies to Python.

Besides, object in Python circles is ambiguous. It can also mean:

* the Python type object;

* an instance of the Python type object;

* any non-class instance of any old-style class (Python 2 only) 
  or type (new-style class);

* boxed values in object-oriented languages;

and possibly others as well. Personally, I dislike using object as a synonym
for instance, as it fails to account for classes which are instances. But
other than that, all those meanings are valid and have to be distinguished
from context.





-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue4944] os.fsync() doesn't work as expect in Windows

2015-03-26 Thread eryksun

eryksun added the comment:

Emil,

Your example child process opens the file with only read sharing, which fails 
with a sharing violation if some other process inherits the file handle with 
write access. The `with` block only prevents this in a single-threaded 
environment. When you spawn 10 children, each from a separate thread, there's a 
good chance that one child will inherit a handle that triggers a sharing 
violation in another child.

Using close_fds is a blunt solution since it prevents inheriting all 
inheritable handles. What you really need here has actually already been done 
for you. Just use the file descriptor that mkstemp returns, i.e. use 
os.fdopen(infd, 'wb'). mkstemp opens the file with O_NOINHERIT set in the flags.

--
nosy: +eryksun

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



Re: test1

2015-03-26 Thread Mario Figueiredo
On Thu, 26 Mar 2015 18:56:25 -0700 (PDT), Tiglath Suriol
tiglathsur...@gmail.com wrote:


How disappointing, I was expecting something worth opposing.


And that's bad? Successfully opposing a troll is like getting a medal
for winning an argument with Spencer Pratt.

Delusional pricks like you are only worth the 2 or 3 messages I care
about writing for my own satisfaction. After that you just get as
boring as the afore-mentioned idiot. Bye-bye!
-- 
https://mail.python.org/mailman/listinfo/python-list


Test3

2015-03-26 Thread Tiglath Suriol

/*
 *  Only assholes need reply to this thread.  
 */

var Obj = (function() {
return function() {
var docRoot = '/as-qa23';
this.validateDocRoot = function(val) {
// throw Exception if not OK
};
this.setDocRoot = function(val) {
this.validateDocRoot(val);
docRoot = val;
};
this.getDocRoot = function() {
return docRoot;
};
Object.preventExtensions(this)
};
}());
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:

 You're arguing whether or not in the following line of code:

 spam = abcd efgh
 # implicitly concatenated to abcdefgh at compile time

 the right hand side pair of strings counts as a single token or two? Am I
 right, or am I missing something?

 If that's all it is, why don't you just run the tokenizer over it and
 see what it says?

Now, someone *could* write a tokenizer that took care of string
concatenation on the spot--as long as it dealt with comments as well:

   (abc
   # hello
def)

It would be even possible to write a parser that didn't have a separate
lexical analyzer at all.

Arguing about terminology is pretty useless. Both sides in this fight
are correct, namely:

   * string literal concatenation is part of expression syntax

   * what goes on inside an atom stays inside an atom

For example, this expression is illegal:

   abc (def)


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 7:56 PM, Chris Angelico ros...@gmail.com wrote:
 On a more specific note, its the 1st line:

 class filter(object)

 which knocks me off.
 If a more restricted type from the ABC was shown which exactly captures all
 the iterator-specific stuff like __iter__, __next__ it would sure help (me)

 But there's no point in subclassing for everything. In this case,
 filter doesn't subclass anything but object, so there's no value in
 stating anything else. You want to know if it's iterable? Check for an
 __iter__ method. Etcetera.

Also, filter is a builtin, while collections.abc.Iterable is in a
library module written in Python, so there's a bootstrapping problem
with having the one inherit from the other.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com:

 On Thu, Mar 26, 2015 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote:
 In fact, the trial-and-error technique is used in automated theorem
 proving:

   Lean provers are generally implemented in Prolog, and make proficient
   use of the backtracking engine and logic variables of that language.

   URL: http://en.wikipedia.org/wiki/Lean_theorem_prover

 Sure, but what has this to do with the statement that *sudoku* should
 not require trial and error to solve?

Trial-and-error was presented in opposition to logical deduction, while
really trial-and-error *is* logical deduction.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Tiglath Suriol
On Thursday, March 26, 2015 at 11:34:11 AM UTC-4, Joel Goldstick wrote:
 On Thu, Mar 26, 2015 at 11:25 AM, Tiglath Suriol
  wrote:
  On Thursday, March 26, 2015 at 9:53:48 AM UTC-4, Joel Goldstick wrote:
  Your first message was not python related.  Your subsequent messages
  were rude.  You've never been here before it seems.  This is an
  interesting group, open to all with interest in python.  How do you
  fit in?  Not
 
  On Wed, Mar 25, 2015 at 9:34 PM, Tiglath Suriol  wrote:
   On Wednesday, March 25, 2015 at 7:59:34 PM UTC-4, Steven D'Aprano wrote:
   On Thu, 26 Mar 2015 10:43 am, Tiglath Suriol wrote:
  
I've dealt with people like you in newsgroups for a long time
  
   So many years, so little learning. It's arseholes like you who make it 
   so
   important to invent a way to stab people through the internet. Just go
   away, you're not wanted here.
  
  
   I may stay a while just to poke you in the eye a little longer.  I am 
   beginning to enjoy this.  People entering a battle of wits unarmed.  
   It's a joy to watch.
  
  
   You talk as if I wanted you to want me.  Pure delusion.  I posted at 
   nobody, as I am free to do, and idiots come out of the woodwork as if I 
   had committed some infraction.
  
   And you even want to stab me.  Sterling.  Who raised you. wolves?
  
  
  
  
  
   --
   Steven
  
   --
   https://mail.python.org/mailman/listinfo/python-list
 
 
 
  --
  Joel Goldstick
  http://joelgoldstick.com
 
  Rather...
 
  I came here because I can and may. but I did no provoke anyone.
 
  Then the Central Scrutinizer chimed in followed by his Seven Dwarves and 
  his bitches.  Now you, in which group do you fit?
 
  Had you all minded your business I wouldn't be here.  Saving yourselves all 
  those inane plonks, and even more inane retorts.
 
  Now be sincere, you write at me because this is like gawking at an accident 
  on the road, it's a disturbance in your otherwise Pythonic, catatonic day.
 
  I did not intend to, but since you appeared, I don't mind kicking your 
  asses for laughs. So please write more.
 
  --
  https://mail.python.org/mailman/listinfo/python-list
 
 You came here to be on display since you have some sort of warped
 sense of self.  Show your mother what you write online.  Maybe she can
 get you help
 

Look at the facts, Harpo.  

I posted two test messages containing code.  

I did not address anyone, I did not ask anything, I made no comment. Said 
nothing about me or anyone.  

Posts are still there. See them.  

All large groups have the type of lame people who like those on the road cause 
a jam to look at some disturbance.  Same here, it was just code, idiots. But 
you could not let it go.  Had to poke your long noses in it.  Now that you've 
found little pleasure in your endevour, you are plonking and whining like stuck 
pigs.  Serves you right.  

You are free to ignore any post you object to. You also have the power to 
killfile anyone, so if you are still here stinking my thread is because either 
you are as thick as a brick, or you want a pissing contest.  

Which one is it?  Bring it on or buzz off, but for fuck's sake stop whining.
  




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Python V3 Search Tool using RE module

2015-03-26 Thread Dave Angel

On 03/26/2015 01:11 PM, Gregg Dotoli wrote:

On Wednesday, March 25, 2015 at 3:43:38 PM UTC-4, Gregg Dotoli wrote:

This basic script will help to find
evidence of CryptoWall on a slave drive. Although it is
just a string, more complex regex patterns can be
replaced with the string. It is incredible how fast Python is and
how easy it has helped in quickly assessing a pool of slave drives.
I'm improving it as we speak.


Thanks for your help and patience. I'm new with Python.


import os
import re
# From the Root
topdir = .

# Regex Pattern
pattern=DECRYPT_I
regexp=re.compile(pattern)
for dirpath,dirnames, files in os.walk(topdir):
 for name in files:
 result=regexp.search(name)
 print(os.path.join(dirpath,name))
 print (result)





Gregg Dotoli


I posted this because I thought it may be of help to others. This does grep 
through all the files and is very fast because the regex is compiled in Python 
, rather than sitting in some directory as an external command.
That is where the optimization comes in.

Let's close this thread.




It greps through all the filenames, but there's no open() call or 
equivalent there at all.  it does not look inside a single file.


We can stop posting to the thread, but that won't fix the bug in the code.

--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Thomas 'PointedEars' Lahn
Dave Angel wrote:

[Fixed quotation]

 On 03/26/2015 01:09 AM, Ian Kelly wrote:
 Thomas 'PointedEars' Lahn wrote:
 https://docs.python.org/3/reference/lexical_analysis.html#string- 
 literal-concatenation

 What the grammar that you quoted from shows is that STRING+ is an
 expression. The individual STRINGs of a STRING+ are not expressions,
 except to the extent that they can be parsed in isolation as a
 STRING+. By the same token, a STRING+ is a single string literal, not
 an aggregate of several.
 
 That's the way I also read the BNF.

Then I am afraid you need to refresh your knowledge of formal grammars.

 But something I cannot find in that chapter of the reference is the
 definition of STRING+

You *definitely* need to refresh your knowledge of formal grammars.

“STRING+” in this flavor of _E_BNF is – rather obviously – equivalent to

  multiple-string ::= STRING STRING*
  STRING  ::= '' no-unescaped-doublequote* ''
  | ' no-unescaped-singlequote* '
  | '' no-triple-doublequote* ''
  | ''' no-triple-singlequote* '''

in BNF and

  multiple-string = STRING *STRING
  STRING  = '' *no-unescaped-doublequote ''
  / ' *no-unescaped-singlequote ''
  / '' *no-unescaped-triple-doublequote ''
  / ''' *no-unescaped-triple-singlequote '''

in ABNF.  I suspect that in this flavor of EBNF the definition of STRING 
looks similar to the following:

  STRING: ('' no_unescaped_doublequote* ''
 | ' no_unescaped_singlequote* '
 | '' no_unescaped_triple_doublequote* ''
 | ''' no_unescaped_triple_singlequote* ''')

Definition of the still undefined goal symbols is left as an exercise to the 
reader.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21085] compile error Python3.3 on Cygwin

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

Could you please use a define like SIGINFO_HAS_SI_BAND?

Something like:

#if defined(HAVE_SIGINFO)  !defined(__CYGWIN__)
   /* Issue #21085: In Cygwin, siginfo_t does not have si_band field. */
#  define SIGINFO_HAS_SI_BAND
#endif

And please generate patches not the git format. Otherwise, Rietveld is unable 
to generated the review link.

--

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



[issue23771] Timeouts on x86 Ubuntu Shared 3.x buildbot

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

A new failure test_subprocess.test_double_close_on_error:

http://buildbot.python.org/all/builders/x86%20Ubuntu%20Shared%203.x/builds/11411/steps/test/logs/stdio
---
Timeout (1:00:00)!
Thread 0x55aafdc0 (most recent call first):
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/subprocess.py, line 
1407 in _execute_child
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/subprocess.py, line 
855 in __init__
  File 
/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_subprocess.py, 
line 1074 in test_double_close_on_error
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/case.py, 
line 577 in run
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/case.py, 
line 625 in __call__
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, 
line 122 in run
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, 
line 84 in __call__
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, 
line 122 in run
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, 
line 84 in __call__
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/runner.py, 
line 176 in run
  File 
/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/__init__.py, 
line 1773 in _run_suite
  File 
/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/__init__.py, 
line 1807 in run_unittest
  File 
/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_subprocess.py, 
line 2532 in test_main
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, 
line 1284 in runtest_inner
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, 
line 967 in runtest
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, 
line 763 in main
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, 
line 1568 in main_in_temp_cwd
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/__main__.py, 
line 3 in module
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/runpy.py, line 85 
in _run_code
  File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/runpy.py, line 170 
in _run_module_as_main
make: *** [buildbottest] Error 1
---

--

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



Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote:

   multiple-string = STRING *STRING
 […]
 in ABNF.

JFTR: ABNF allows for

  multiple-string = 1*STRING

to be equivalent to the above.

http://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_Form pp.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Peter

Peter added the comment:

I went and recompiled with:
$ ./configure --prefix=/usr/local --enable-shared 
--with-hash-algorithm=siphash24

But this crashed as well.

test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python 
error: Bus error

Current thread 0x0001 (most recent call first):
  File /usr/local/src/Python-3.4.3/Lib/test/test_hash.py, line 89 in 
test_unaligned_buffers
  File /usr/local/src/Python-3.4.3/Lib/unittest/case.py, line 577 in run
  File /usr/local/src/Python-3.4.3/Lib/unittest/case.py, line 625 in __call__
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 122 in run
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 84 in __call__
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 122 in run
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 84 in __call__
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 122 in run
  File /usr/local/src/Python-3.4.3/Lib/unittest/suite.py, line 84 in __call__
  File /usr/local/src/Python-3.4.3/Lib/unittest/runner.py, line 168 in run
  File /usr/local/src/Python-3.4.3/Lib/test/support/__init__.py, line 1769 in 
_run_suite
  File /usr/local/src/Python-3.4.3/Lib/test/support/__init__.py, line 1803 in 
run_unittest
  File /usr/local/src/Python-3.4.3/Lib/test/regrtest.py, line 1279 in 
test_runner
  File /usr/local/src/Python-3.4.3/Lib/test/regrtest.py, line 1280 in 
runtest_inner
  File /usr/local/src/Python-3.4.3/Lib/test/regrtest.py, line 978 in runtest
  File /usr/local/src/Python-3.4.3/Lib/test/regrtest.py, line 763 in main
  File /usr/local/src/Python-3.4.3/Lib/test/regrtest.py, line 1564 in 
main_in_temp_cwd
  File /usr/local/src/Python-3.4.3/Lib/test/__main__.py, line 3 in module
  File /usr/local/src/Python-3.4.3/Lib/runpy.py, line 85 in _run_code
  File /usr/local/src/Python-3.4.3/Lib/runpy.py, line 170 in 
_run_module_as_main
Bus Error (core dumped)


test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xff25d3d8 in siphash24 (src=0x1d2809, src_sz=optimized out) at 
Python/pyhash.c:387
387 PY_UINT64_T mi = _le64toh(*in);
(gdb) bt
#0  0xff25d3d8 in siphash24 (src=0x1d2809, src_sz=optimized out) at 
Python/pyhash.c:387
#1  0xff25dfa0 in _Py_HashBytes (src=0x1d2809, len=127) at Python/pyhash.c:186
#2  0xff1a7ce4 in memory_hash (self=0xfdfc5dc0) at Objects/memoryobject.c:2793
#3  0xff1afa40 in PyObject_Hash (v=0xfdfc5dc0) at Objects/object.c:757
#4  0xff22b6fc in builtin_hash (self=0xfee23600, v=0xfdfc5dc0) at 
Python/bltinmodule.c:1269
#5  0xff236a70 in call_function (oparg=optimized out, pp_stack=0xffbfcd64) at 
Python/ceval.c:4224
#6  PyEval_EvalFrameEx (f=optimized out, throwflag=optimized out) at 
Python/ceval.c:2838
#7  0xff237790 in fast_function (nk=optimized out, na=optimized out, n=1, 
pp_stack=0xffbfce5c,
func=optimized out) at Python/ceval.c:4334


(gdb) list
382 PY_UINT64_T t;
383 PY_UINT8_T *pt;
384 PY_UINT8_T *m;
385
386 while (src_sz = 8) {
387 PY_UINT64_T mi = _le64toh(*in);
388 in += 1;
389 src_sz -= 8;
390 v3 ^= mi;
391 DOUBLE_ROUND(v0,v1,v2,v3);

--

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



Re: Basic Python V3 Search Tool using RE module

2015-03-26 Thread Gregg Dotoli
On Wednesday, March 25, 2015 at 3:43:38 PM UTC-4, Gregg Dotoli wrote:
 This basic script will help to find 
 evidence of CryptoWall on a slave drive. Although it is
 just a string, more complex regex patterns can be 
 replaced with the string. It is incredible how fast Python is and
 how easy it has helped in quickly assessing a pool of slave drives.
 I'm improving it as we speak.
 
 
 Thanks for your help and patience. I'm new with Python.
 
 
 import os
 import re
 # From the Root
 topdir = .
 
 # Regex Pattern
 pattern=DECRYPT_I
 regexp=re.compile(pattern)
 for dirpath,dirnames, files in os.walk(topdir):
 for name in files:
 result=regexp.search(name)
 print(os.path.join(dirpath,name))
 print (result)
 
 
 
 
 
 Gregg Dotoli

I posted this because I thought it may be of help to others. This does grep 
through all the files and is very fast because the regex is compiled in Python 
, rather than sitting in some directory as an external command.
That is where the optimization comes in.

Let's close this thread.



Gregg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote:
 Ian Kelly ian.g.ke...@gmail.com:

 On Thu, Mar 26, 2015 at 8:23 AM, Marko Rauhamaa ma...@pacujo.net wrote:
 That's trial and error, aka, reductio ad absurdum.

 Okay, I've probably used single-lookahead trial and error in my
 reasoning at some point. But the example you give is equivalent to the
 deductive process That can't be a 5, so I remove it as a candidate.
 The only place left for a 5 is here, so I remove the 2 as a candidate
 and fill in the 5.

 In fact, the trial-and-error technique is used in automated theorem
 proving:

   Lean provers are generally implemented in Prolog, and make proficient
   use of the backtracking engine and logic variables of that language.

   URL: http://en.wikipedia.org/wiki/Lean_theorem_prover

Sure, but what has this to do with the statement that *sudoku* should
not require trial and error to solve?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21085] compile error Python3.3 on Cygwin

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

 In that case, May I edit configure script to generate the HAVE_* defines?
 I'd like to add a statement to check the si_band to configure.ac.

Does Cygwin use configure? If yes, go for configure.

You can copy/paste my recent change for dirent.d_type field.

 I see.  I use the mercurial repository from next time.

Are you using git or hg? If you use hg, just change the config to not use
git format. If you use git, don't worry, I can review without the review
button.

--

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



Re: Fwd: test1

2015-03-26 Thread BartC

On 26/03/2015 15:38, Tiglath Suriol wrote:


I did not spam anyone.  I posted to an open public newsgroup.  Just some code, 
nothing offensive or even directed to anyone.  Then people started to get cute, 
and now that returned fire is a bucket a drop they complaints like bitches on 
the rag.  Not surprised, but not SPAM either.  If anyone pull a newsgroup into 
his email that's his doing, not mine.


There are 100,000 different public newsgroups for a reason: they are all 
about different subjects.


Your post had nothing to do with Python that I could see.

To post test messages, try alt.test. Otherwise the newsgroup would get 
swamped if everyone posted irrelevant random stuff.


BTW why /did/ you choose this newsgroup?

--
Bartc


--
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Thomas 'PointedEars' Lahn
Ian Kelly wrote:

 On Thu, Mar 26, 2015 at 12:29 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 10:45 AM, Thomas 'PointedEars' Lahn
 No, in the used flavour of EBNF the unquoted “+” following a goal symbol
 clearly means the occurrence of *at least one* of the immediately
 preceding symbol, meaning either one *or more than one*.

 It means one or more *tokens*, not one or more literals.
 
 Although reading the documentation, it seems that it also conflates
 string literals with tokens,

There is nothing to conflate here.  String literals *are* tokens.

 so on that I'll have to concede the point.

Too late, the rebuttal is already underway :-p

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Emile van Sebille

On 3/25/2015 12:49 PM, Tiglath Suriol wrote:

On Tuesday, March 24, 2015 at 11:04:48 PM UTC-4, Chris Angelico wrote:

On Wed, Mar 25, 2015 at 1:47 PM, Tiglath Suriol  wrote:



PLONK



--
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Thomas 'PointedEars' Lahn
Ian Kelly wrote:

 […] Thomas 'PointedEars' Lahn […] wrote:
 Chris Angelico wrote:
 […] Thomas 'PointedEars' Lahn […] wrote:
 Implicit concatenation is part of the syntax, not part of the
 expression evaluator.
 Reads like nonsense to me.
 What do you mean?
 As I showed, string literals and consecutive tokens of string literals
 (“STRING+”) so as to do implicit concatenation *are* expressions of the
 Python grammar.  Expressions are *part of* the syntax of a programming
 language.

 Perhaps you mean that the time when implicit concatenation is evaluated
 (compile time) differs from the time when other expressions are evaluated
 (runtime).  But a) whether that is true depends on the implementation and
 b) there can be no doubt that either expression needs to be evaluated. 
 So whatever you mean by “expression evaluator” has to be able to do those
 things.

 Which makes the statement above read like nonsense to me.
 
 What the grammar that you quoted from shows is that STRING+ is an
 expression. The individual STRINGs of a STRING+ are not expressions,
 except to the extent that they can be parsed in isolation as a
 STRING+.

How did you get that idea?  STRING+ means one or more consecutive STRING 
tokens (ignoring whitespace in-between), which means one or more consecutive 
string literals.  A (single) string literal definitely is an expression as 
it can be produced with the “expr” goal symbol of the Python grammar (given 
there in a flavor of EBNF).

 By the same token, a STRING+ is a single string literal, not
 an aggregate of several.

No, in the used flavour of EBNF the unquoted “+” following a goal symbol 
clearly means the occurrence of *at least one* of the immediately preceding 
symbol, meaning either one *or more than one*.

http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form pp.

 Ancillary data point:
 
  help(ast.literal_eval)
 Safely evaluate an expression node or a string containing a Python
 expression.  The string or node provided may only consist of the 
 following Python literal structures: strings, bytes, numbers, tuples, 
 lists, dicts, sets, booleans, and None.
  ast.literal_eval('foo bar')
 'foobar'
 
 So the ast.literal_eval also treats this as one literal expression.

What do you mean?

ast.literal_eval() sees a single string value resulting from the evaluation 
of one string literal, by the Python compiler, that contains the 
representation of two consecutive string literals:

  'foo bar'

It then does exactly what the Python compiler would do in such a case: parse 
this as if it were one string literal (the “implicit concatenation” I am 
talking about).

  foo bar ≡ foobar

This was not debated.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 12:29 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 10:45 AM, Thomas 'PointedEars' Lahn
 No, in the used flavour of EBNF the unquoted “+” following a goal symbol
 clearly means the occurrence of *at least one* of the immediately preceding
 symbol, meaning either one *or more than one*.

 It means one or more *tokens*, not one or more literals.

Although reading the documentation, it seems that it also conflates
string literals with tokens, so on that I'll have to concede the
point.

https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Thomas 'PointedEars' Lahn
Ian Kelly wrote:

 […] Thomas 'PointedEars' Lahn […] wrote:
 Ian Kelly wrote:
 What the grammar that you quoted from shows is that STRING+ is an
 expression. The individual STRINGs of a STRING+ are not expressions,
 except to the extent that they can be parsed in isolation as a
 STRING+.
 How did you get that idea?  STRING+ means one or more consecutive STRING
 tokens (ignoring whitespace in-between), which means one or more
 consecutive string literals.  A (single) string literal definitely is an 
 expression as it can be produced with the “expr” goal symbol of the 
 Python grammar (given there in a flavor of EBNF).
 
 Yes, that's what I was referring to in my parenthetical except... above.

Your “except” is contradictory to the rest of what you said, at best.

 What I mean is that if you construct a parse tree of foo bar using
 that grammar, it looks like this:
 
  expr
|
 STRING+
  /   \
 STRING  STRING
 […]
 
 There is only one expr node, and it contains both STRING tokens.

Prove it.

But be warned: Neither would prove that a string literal is not an 
expression.  Because you did not consider the most simple variant of an AST 
(or subtree) according to this grammar:

expr
 |
   STRING

Again, “STRING+” does _not_ mean “STRING STRING STRING*”; it means “STRING 
STRING*”.  The second and following STRINGs are *optional*.

 […] in the used flavour of EBNF the unquoted “+” following a goal symbol
 clearly means the occurrence of *at least one* of the immediately
 preceding symbol, meaning either one *or more than one*.
 
 It means one or more *tokens*, not one or more literals.

Utter nonsense.  Have you ever written a parser?  (I have.)  A literal *is* 
a token.  Whether two consecutive tokens end up as the same *node* in an AST 
is a *different* issue (that, again, was _not_ debated).
 
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21085] compile error Python3.3 on Cygwin

2015-03-26 Thread Masayuki Yamamoto

Masayuki Yamamoto added the comment:

Victor,

In that case, May I edit configure script to generate the HAVE_* defines?
I'd like to add a statement to check the si_band to configure.ac.

 And please generate patches not the git format. Otherwise, Rietveld is unable 
 to generated the review link.
I see.  I use the mercurial repository from next time.

--

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



[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Siphash24 implementation is not designed to work on platforms that require 
aligned access. But I'm surprised that fnv implementation crashes. I don't see 
anything wrong. May be gcc needs some special options to produce correct 
binaries on this platform?

--
nosy: +serhiy.storchaka

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



Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 10:45 AM, Thomas 'PointedEars' Lahn
pointede...@web.de wrote:
 Ian Kelly wrote:
 What the grammar that you quoted from shows is that STRING+ is an
 expression. The individual STRINGs of a STRING+ are not expressions,
 except to the extent that they can be parsed in isolation as a
 STRING+.

 How did you get that idea?  STRING+ means one or more consecutive STRING
 tokens (ignoring whitespace in-between), which means one or more consecutive
 string literals.  A (single) string literal definitely is an expression as
 it can be produced with the “expr” goal symbol of the Python grammar (given
 there in a flavor of EBNF).

Yes, that's what I was referring to in my parenthetical except... above.

What I mean is that if you construct a parse tree of foo bar using
that grammar, it looks like this:

 expr
   |
STRING+
 /   \
STRING  STRING

Not like this:

expr
 |
   STRING+
/  \
 expr  expr
  |  |
STRING  STRING

There is only one expr node, and it contains both STRING tokens.

 By the same token, a STRING+ is a single string literal, not
 an aggregate of several.

 No, in the used flavour of EBNF the unquoted “+” following a goal symbol
 clearly means the occurrence of *at least one* of the immediately preceding
 symbol, meaning either one *or more than one*.

It means one or more *tokens*, not one or more literals.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot Uninstall 3.4

2015-03-26 Thread Ben Finney
T Younger tlyt...@gmail.com writes:

 I have 3.4.1 (8/14) and replaced it with 3.4.2 (12/14)
 Neither of these uninstalled or I do not believe even had the option.

That's not so much a question about Python; it is rather a question of
how you install and uninstall applications on your operating system.
There's not enough information in your message to know what's wrong.

What did you use to install each of these? Does whatever did the
installation record un-install information?

-- 
 \ “To label any subject unsuitable for comedy is to admit |
  `\   defeat.” —Peter Sellers |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23290] Faster set copying

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

Is msg234811 the result of set_faster_copy_3.patch? If yes, I see no reason to 
not apply the patch: the patch is short and looks always fast, and sometimes 
*much* faster.

I just leaved a small comment on the review.

--
nosy: +haypo

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



Re: Cannot Uninstall 3.4

2015-03-26 Thread Mario Figueiredo
On Thu, 26 Mar 2015 18:52:41 -0500, T Younger tlyt...@gmail.com
wrote:

I have 3.4.1 (8/14) and replaced it with 3.4.2 (12/14)
Neither of these uninstalled or I do not believe even had the option.

I now wanted to update to 3.4.3 and the uninstall fails, provided the
message that the installer is missing a program then backs off the changes.

I loaded 3.5.0a2 and then uninstalled it OK.

How do I get to 3.4.3 please?


What's your system?

There isn't usually any need to uninstall in order to upgrade minor
releases. You just install over the previous one, since Python34 will
still remain the main folder/directory.
-- 
https://mail.python.org/mailman/listinfo/python-list


Save session Selenium PhantomJS

2015-03-26 Thread Juan C.
Objective: Save the browser session/cookies to share them in multiples
script execution.

I currently have this working using ChromeDriver:

chrome_options = Options()
chrome_options.add_argument(user-data-dir= + os.path.dirname(sys.argv[0]))
browser = webdriver.Chrome(chrome_options=chrome_options)

This code tells Chrome to use a specific path, in my case the script path,
as data folder where it stores everything, and NOT use the default
approach where everything is temporary and deleted when the script exits.

This way, I can login in the site I need once and exit the script. If I
execute the script later everything is already saved and I don't have to
login anymore.

I need this approach because the site has a security measure where they
send a key to my email everytime I login in a new PC.


The issue: Now I need to use PhantomJS. I already tried this code:

cookie_path = os.path.join(os.getcwd(), 'cookie.txt')
driver = webdriver.WebDriver(service_args=['--cookies-file=cookies.txt'])

But it doesn't work. I looked at the PhantomJS doc and on Google but didn't
find anything. I hope someone knows better than me and could give me a
hand here.

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23611] Pickle nested names with protocols 4

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

 It is used in multiprocessing and this is not configurable.

Oh, it would be nice to switch to version 4 by default, or make it
configurable. I read that the version 4 is faster.

--

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



[issue23529] Limit decompressed data when reading from LZMAFile and BZ2File

2015-03-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Is it still work-in-progress or are you looking for a review?

--

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



[issue23529] Limit decompressed data when reading from LZMAFile and BZ2File

2015-03-26 Thread Nikolaus Rath

Nikolaus Rath added the comment:

I believe Martin's patch (v8) is ready for a core committer review. At least I 
can't find anything to criticize anymore :-).

--

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



[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Peter

New submission from Peter:

I compiled Python 3.4.3 on Solaris 11, and when I ran the regression test, I 
get a core dump when the hash() function was being used. I went through the bug 
database looking for something similar but couldn't find anything.

Tests like:
test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python 
error: Bus error

Current thread 0x0001 (most recent call first):
  File /usr/local/lib/python3.4/test/test_hash.py, line 89 in 
test_unaligned_buffers
  File /usr/local/lib/python3.4/unittest/case.py, line 577 in run
  File /usr/local/lib/python3.4/unittest/case.py, line 625 in __call__
  File /usr/local/lib/python3.4/unittest/suite.py, line 122 in run
  File /usr/local/lib/python3.4/unittest/suite.py, line 84 in __call__
  File /usr/local/lib/python3.4/unittest/suite.py, line 122 in run
  File /usr/local/lib/python3.4/unittest/suite.py, line 84 in __call__
  File /usr/local/lib/python3.4/unittest/suite.py, line 122 in run
  File /usr/local/lib/python3.4/unittest/suite.py, line 84 in __call__
  File /usr/local/lib/python3.4/unittest/runner.py, line 168 in run
  File /usr/local/lib/python3.4/test/support/__init__.py, line 1769 in 
_run_suite
  File /usr/local/lib/python3.4/test/support/__init__.py, line 1803 in 
run_unittest
  File /usr/local/lib/python3.4/test/regrtest.py, line 1279 in test_runner
  File /usr/local/lib/python3.4/test/regrtest.py, line 1280 in runtest_inner
  File /usr/local/lib/python3.4/test/regrtest.py, line 978 in runtest
  File /usr/local/lib/python3.4/test/regrtest.py, line 763 in main
  File /usr/local/lib/python3.4/test/regrtest.py, line 1564 in 
main_in_temp_cwd
  File /usr/local/lib/python3.4/test/__main__.py, line 3 in module
  File /usr/local/lib/python3.4/runpy.py, line 85 in _run_code
  File /usr/local/lib/python3.4/runpy.py, line 170 in _run_module_as_main
Bus Error (core dumped)


and


test_hash_equality (test.datetimetester.TestTime_Fast) ... Fatal Python error: 
Bus error

Current thread 0x0001 (most recent call first):
  File /usr/local/lib/python3.4/test/datetimetester.py, line 2155 in 
test_hash_equality
  File /usr/local/lib/python3.4/unittest/case.py, line 577 in run
  File /usr/local/lib/python3.4/unittest/case.py, line 625 in __call__
  File /usr/local/lib/python3.4/unittest/suite.py, line 122 in run
  File /usr/local/lib/python3.4/unittest/suite.py, line 84 in __call__
  File /usr/local/lib/python3.4/unittest/suite.py, line 122 in run
  File /usr/local/lib/python3.4/unittest/suite.py, line 84 in __call__
  File /usr/local/lib/python3.4/unittest/runner.py, line 168 in run
  File /usr/local/lib/python3.4/test/support/__init__.py, line 1769 in 
_run_suite
  File /usr/local/lib/python3.4/test/support/__init__.py, line 1803 in 
run_unittest
  File /usr/local/lib/python3.4/test/test_datetime.py, line 45 in test_main
  File /usr/local/lib/python3.4/test/regrtest.py, line 1280 in runtest_inner
  File /usr/local/lib/python3.4/test/regrtest.py, line 978 in runtest
  File /usr/local/lib/python3.4/test/regrtest.py, line 763 in main
  File /usr/local/lib/python3.4/test/regrtest.py, line 1564 in 
main_in_temp_cwd
  File /usr/local/lib/python3.4/test/__main__.py, line 3 in module
  File /usr/local/lib/python3.4/runpy.py, line 85 in _run_code
  File /usr/local/lib/python3.4/runpy.py, line 170 in _run_module_as_main
Bus Error (core dumped)



I then ran the same test through gdb:
$ gdb /usr/local/bin/python3.4
GNU gdb (GDB) 7.8.1
snip
(gdb) run -m test -v test_hash
Starting program: /usr/local/bin/python3.4 -m test -v test_hash
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
== CPython 3.4.3 (default, Mar 25 2015, 17:35:25) [GCC 4.6.2]
==   Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
==   hash algorithm: fnv 32bit
==   /tmp/test_python_12329
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_
site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, 
hash_randomization=1, isolated=0)
[1/1] test_hash
test_empty_string (test.test_hash.BytesHashRandomizationTests) ... ok
test_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_long_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_null_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.DatetimeDateTests) ... ok
test_randomized_hash (test.test_hash.DatetimeDatetimeTests) ... FAIL
test_randomized_hash (test.test_hash.DatetimeTimeTests) ... FAIL
test_hashes (test.test_hash.HashBuiltinsTestCase) ... ok
test_hash_distribution (test.test_hash.HashDistributionTestCase) ... ok
test_coerced_floats (test.test_hash.HashEqualityTestCase) ... ok
test_coerced_integers (test.test_hash.HashEqualityTestCase) ... ok
test_numeric_literals (test.test_hash.HashEqualityTestCase) ... ok
test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ...
Program 

[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Serhiy Storchaka

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


--
nosy: +christian.heimes, jcea
versions: +Python 3.5

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



Re: Fwd: test1

2015-03-26 Thread Ian Kelly
On Mar 26, 2015 7:35 AM, Igor Korot ikoro...@gmail.com wrote:

  On Thu, Mar 26, 2015 at 9:01 AM, alister
 alister.nospam.w...@ntlworld.com wrote:
  i hope he has a good spam filter as I am about to sign him up for
  everything :-)

 Well he did gave out his private key to the public in an ASCII format.
 I wonder what people can do with it? ;-)

Spamming someone as a response to being spammed is reasonable, in an
eye-for-an-eye kind of way (though a bit childish). Hacking their site is
not.

Besides, it would be a lot more work for you to do anything untoward with
it than it would be for him to just change it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Joel Goldstick
Your first message was not python related.  Your subsequent messages
were rude.  You've never been here before it seems.  This is an
interesting group, open to all with interest in python.  How do you
fit in?  Not

On Wed, Mar 25, 2015 at 9:34 PM, Tiglath Suriol tiglathsur...@gmail.com wrote:
 On Wednesday, March 25, 2015 at 7:59:34 PM UTC-4, Steven D'Aprano wrote:
 On Thu, 26 Mar 2015 10:43 am, Tiglath Suriol wrote:

  I've dealt with people like you in newsgroups for a long time

 So many years, so little learning. It's arseholes like you who make it so
 important to invent a way to stab people through the internet. Just go
 away, you're not wanted here.


 I may stay a while just to poke you in the eye a little longer.  I am 
 beginning to enjoy this.  People entering a battle of wits unarmed.  It's a 
 joy to watch.


 You talk as if I wanted you to want me.  Pure delusion.  I posted at nobody, 
 as I am free to do, and idiots come out of the woodwork as if I had committed 
 some infraction.

 And you even want to stab me.  Sterling.  Who raised you. wolves?





 --
 Steven

 --
 https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

lgtm with a test

--

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



Re: Fwd: test1

2015-03-26 Thread Joel Goldstick
Apparently Tiglath is a troll:  see this:
http://www.science-bbs.com/121-math/6b7f8c793e31402e.htm

On Thu, Mar 26, 2015 at 9:51 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Mar 26, 2015 7:35 AM, Igor Korot ikoro...@gmail.com wrote:

  On Thu, Mar 26, 2015 at 9:01 AM, alister
 alister.nospam.w...@ntlworld.com wrote:
  i hope he has a good spam filter as I am about to sign him up for
  everything :-)

 Well he did gave out his private key to the public in an ASCII format.
 I wonder what people can do with it? ;-)

 Spamming someone as a response to being spammed is reasonable, in an
 eye-for-an-eye kind of way (though a bit childish). Hacking their site is
 not.

 Besides, it would be a lot more work for you to do anything untoward with it
 than it would be for him to just change it.


 --
 https://mail.python.org/mailman/listinfo/python-list




-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It would be not easy to reproduce without special broken decoder.

--

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



[issue23785] Leak in TextIOWrapper.tell()

2015-03-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

How did you notice it, btw?

--

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



[issue23676] Add support of UnicodeTranslateError in standard error handlers

2015-03-26 Thread STINNER Victor

STINNER Victor added the comment:

I'm sorry, I don't understand this issue. Could you please elaborate the use 
case? Why do you want to support more error handlers? str.translate() calls 
_PyUnicode_TranslateCharmap() with errors=ignore, it's not possible to choose 
the error handler.

Many codecs are implemented in Python and some of them are implemented with 
charmap. Does this issue enhance the codecs implemented with charmap?

a\udc80.encode(latin9, surrogatepass) raises UnicodeEncodeError with and 
without the patch, b\x81.decode(cp1252, surrogatepass) raises 
UnicodeDecodeError with and without the patch.

Hum, I'm not sure that codecs.charmap_build() is related str.translate().

--
nosy: +haypo

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



Re: sys.exec_prefix doesn't seem to reflect --exec-prefix path

2015-03-26 Thread Ned Deily
In article 548dcac1-fa00-4fc1-81d1-ccae28caf...@googlegroups.com,
 Ralph Heinkel ralph.hein...@web.de wrote:
 on my linux box there is a python version 2.7.5 installed in /usr/local.
 
 Now I want to install the newer version 2.7.9, but in a different directory 
 to avoid clashes with the current installation.
 
 What I did was:
 
 ./configure --prefix /usr/local/Python-2.7.9 --exec-prefix 
 /usr/local/Python-2.7.9
 make
 make install

Configure arguments need to be specified with '='.  Try instead:

./configure --prefix=/usr/local/Python-2.7.9

And --exec-prefix isn't needed in this case as it defaults to the value 
of --prefix.

-- 
 Ned Deily,
 n...@acm.org

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Peter

Peter added the comment:

That's not a valid option on SPARC, (see 
https://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html ) the flag is only 
available on ARM it seems.

--

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



Re: Best way to calculate fraction part of x?

2015-03-26 Thread Russell Owen

On 3/24/15 6:39 PM, Jason Swails wrote:



On Mon, Mar 23, 2015 at 8:38 PM, Emile van Sebille em...@fenx.com
mailto:em...@fenx.com wrote:

On 3/23/2015 5:52 AM, Steven D'Aprano wrote:

Are there any other, possibly better, ways to calculate the
fractional part
of a number?


float ((%6.3f % x)[-4:])


​In general you lose a lot of precision this way...​


I suggest modf in the math library:

math.modf(x)
Return the fractional and integer parts of x. Both results carry the 
sign of x and are floats.




--
https://mail.python.org/mailman/listinfo/python-list


[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Peter

Peter added the comment:

I've compiled Python 3.3.6 using the same options (./configure 
--prefix=/usr/local --enable-shared) and build system and that passes almost 
all the tests (test_uuid fails for an ignorable reason).

Specifically test_hash passes fully:

$ LD_LIBRARY_PATH=/usr/local/src/Python-3.3.6 ./python -m test -v test_hash
== CPython 3.3.6 (default, Mar 26 2015, 15:35:36) [GCC 4.6.2]
==   Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
==   /usr/local/src/Python-3.3.6/build/test_python_4539
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)
[1/1] test_hash
test_empty_string (test.test_hash.BytesHashRandomizationTests) ... ok
test_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_null_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.BytesHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.DatetimeDateTests) ... ok
test_randomized_hash (test.test_hash.DatetimeDatetimeTests) ... ok
test_randomized_hash (test.test_hash.DatetimeTimeTests) ... ok
test_hashes (test.test_hash.HashBuiltinsTestCase) ... ok
test_coerced_floats (test.test_hash.HashEqualityTestCase) ... ok
test_coerced_integers (test.test_hash.HashEqualityTestCase) ... ok
test_numeric_literals (test.test_hash.HashEqualityTestCase) ... ok
test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... ok
test_default_hash (test.test_hash.HashInheritanceTestCase) ... ok
test_error_hash (test.test_hash.HashInheritanceTestCase) ... ok
test_fixed_hash (test.test_hash.HashInheritanceTestCase) ... ok
test_hashable (test.test_hash.HashInheritanceTestCase) ... ok
test_not_hashable (test.test_hash.HashInheritanceTestCase) ... ok
test_empty_string (test.test_hash.MemoryviewHashRandomizationTests) ... ok
test_fixed_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
test_null_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
test_empty_string (test.test_hash.StrHashRandomizationTests) ... ok
test_fixed_hash (test.test_hash.StrHashRandomizationTests) ... ok
test_null_hash (test.test_hash.StrHashRandomizationTests) ... ok
test_randomized_hash (test.test_hash.StrHashRandomizationTests) ... ok

--
Ran 25 tests in 1.356s

OK
1 test OK.


So any ideas what I should look for? Or perhaps it would be helpful if I posted 
config.log, etc.

--

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



Re: test1

2015-03-26 Thread Denis McMahon
On Thu, 26 Mar 2015 10:00:56 -0700, Tiglath Suriol wrote:

 I posted two test messages containing code.

No, you excreted a pile of steaming excrement and have continued to do 
so. Your original post in this thread had no relevance to the newsgroup 
or the gated mailing list, it was purely internet vandalism, and your 
ongoing posts are simply trolling.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best way to calculate fraction part of x?

2015-03-26 Thread Oscar Benjamin
On 23 March 2015 at 12:52, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I have a numeric value, possibly a float, Decimal or (improper) Fraction,
 and I want the fractional part. E.g. fract(2.5) should give 0.5.

 Here are two ways to do it:

 py x = 2.5
 py x % 1
 0.5
 py x - int(x)
 0.5

 x % 1 is significantly faster, but has the disadvantage of giving the
 complement of the fraction if x is negative:

 py x = -2.75
 py x % 1
 0.25

The other version gives -0.75 in this case so I guess that's what you want.

 Are there any other, possibly better, ways to calculate the fractional part
 of a number?

What do you mean by better? Is it just faster?

To modify the % version so that it's equivalent you can do:

 x = -2.75
 (x % 1) - (x  0)
-0.75

I'm not sure if that's faster than x - int(x) though. Obviously it
depends which numeric type you're primarily interested in.


Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: test1

2015-03-26 Thread marcuslom101
On Thursday, March 26, 2015 at 4:01:08 PM UTC-4, BartC wrote:
 On 26/03/2015 15:38, Tiglath Suriol wrote:
 
  I did not spam anyone.  I posted to an open public newsgroup.  Just some 
  code, nothing offensive or even directed to anyone.  Then people started to 
  get cute, and now that returned fire is a bucket a drop they complaints 
  like bitches on the rag.  Not surprised, but not SPAM either.  If anyone 
  pull a newsgroup into his email that's his doing, not mine.
 
 There are 100,000 different public newsgroups for a reason: they are all 
 about different subjects.
 
 Your post had nothing to do with Python that I could see.


A polite post at last. How refreshing.  

That would be two off-topic posts I submitted.  All the replies to it were also 
off-topic, so it can't possibly be such a big crime.  


 
 To post test messages, try alt.test. Otherwise the newsgroup would get 
 swamped if everyone posted irrelevant random stuff.

Say that too to the imbeciles who jumped from the woodwork and made any 
swamping I may have caused much worst.  

The reaction has been far worse than my action.  This stems from regular 
posters of a newsgroup developing a sense of entitlement and turf, which is 
purely imaginary.  This is a public place and everyone has the tools to ignore 
posts and posters.  They just wanted to play and mock and got burned.  


 
 BTW why /did/ you choose this newsgroup?
 

I just needed to save some code and there was no email at hand, I use this 
because it's a group I am familiar with, alt.test sounds like a better option.  

Thanks


 -- 
 Bartc

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

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



Re: Best way to calculate fraction part of x?

2015-03-26 Thread Emile van Sebille

On 3/24/2015 6:39 PM, Jason Swails wrote:



On Mon, Mar 23, 2015 at 8:38 PM, Emile van Sebille em...@fenx.com


snip


float ((%6.3f % x)[-4:])


​In general you lose a lot of precision this way...​



Even more if you use %6.1 -- but feel free to flavor to taste.   :)

Emile



--
https://mail.python.org/mailman/listinfo/python-list


Re: test1

2015-03-26 Thread Mario Figueiredo
On Thu, 26 Mar 2015 14:06:28 -0700 (PDT), marcuslom...@gmail.com
wrote:


I posted two test messages containing code.  They are still there,
 are you blind as well as dumb? 

Your post is also off-topic, so what are you whining about, girl?  

You can ignore my posts almost effortlessly, the fact that you
prefer to inveigh in your rant means that you want to be part of
this.  I'll be happy to oblige, bozo.  Make my day.  


Hush now, little baby troll. Don't get all teary on us. Calm down.
Just a little while ago you were saying you didn't care about what
people said.

So don't care about what people say.

BTW, you are as stupid as you are an ignorant little trapped troll.
You purportedly spammed this place and now we are having fun telling
you all about it. Boo hoo!

Now, remember what you said...
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23786] test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

2015-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes, 3.3 uses less efficient implementation.

Try to compile Python with gcc option -mno-unaligned-access.

--
nosy: +mark.dickinson

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



Re: test1

2015-03-26 Thread Tim Chase
On 2015-03-26 08:33, Tiglath Suriol wrote:
  Mark Lawrence  
 
 I don't remember addressing his guy,  HE addressed me FIRST, as all
 of you did,

Hmmm...To what then has he been replying?  *You* posted/broadcast the
FIRST message which addressed every member of the list.  If you
don't want to address every member of a list, try not posting. Or at
least expect replies.

 now you complaint you don't like my replies.

Mostly it's your uncivil tone that people seem to be complaining
about.  Reading over the messages in the thread, it's mostly *you*
complaining about replies.  And you that keeps fanning the flame.

 I came here because I can and may.

And folks here replied.  Because they can and may.

And you're not kidding anybody: your bravado and insults against a
plurality of respected community members only amplifies your own
appearance of folly.

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >