[RELEASED] Python 3.2.6, Python 3.3.6

2014-10-12 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I'm happy to announce
the release of Python 3.2.6 and 3.3.6.  Both are security-fix releases,
which are provided source-only on python.org.

The list of security-related issues fixed in the releases is given in
the changelogs:

https://hg.python.org/cpython/raw-file/v3.2.6/Misc/NEWS
https://hg.python.org/cpython/raw-file/v3.3.6/Misc/NEWS

To download the releases visit one of:

https://www.python.org/downloads/release/python-326/
https://www.python.org/downloads/release/python-336/

These are production versions, please report any bugs to

 http://bugs.python.org/

Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and contributors)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlQ6L/cACgkQN9GcIYhpnLBxIwCeLqjXeIOxGA2vkjbkN5Ic6j2u
7WcAoKgFaB4drMX5ZOVUJ4VLyNTcfycN
=KLlw
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[RELEASED] Python 3.2.6, Python 3.3.6

2014-10-12 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I'm happy to announce
the release of Python 3.2.6 and 3.3.6.  Both are security-fix releases,
which are provided source-only on python.org.

The list of security-related issues fixed in the releases is given in
the changelogs:

https://hg.python.org/cpython/raw-file/v3.2.6/Misc/NEWS
https://hg.python.org/cpython/raw-file/v3.3.6/Misc/NEWS

To download the releases visit one of:

https://www.python.org/downloads/release/python-326/
https://www.python.org/downloads/release/python-336/

These are production versions, please report any bugs to

 http://bugs.python.org/

Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and contributors)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlQ6L/cACgkQN9GcIYhpnLBxIwCeLqjXeIOxGA2vkjbkN5Ic6j2u
7WcAoKgFaB4drMX5ZOVUJ4VLyNTcfycN
=KLlw
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parse bad xml file

2014-10-12 Thread Rustom Mody
On Friday, October 10, 2014 6:03:58 PM UTC+5:30, David Jobes wrote:
 On Friday, October 10, 2014 8:21:17 AM UTC-4, Peter Otten wrote:

Elementtree XMl snipped

 That did it, thank you, and in a lot fewer lines of code than i had, i was 
 trying to use strings and regex. i will read up more on the xml.etree stuff.

Those who parse xml/html with re's should read this --

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

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


TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-12 Thread roro codeath
How to implement it in my class?

class Str(str):
def __init__(self, *args, **kwargs):
pass

Str('smth', kwarg='a')

# How to implement in my class

class C:
   def __init__(self):
   pass

class C2(C):
def __init__(self, *args, **kwargs):
pass
C2(kwarg='a')
-- 
https://mail.python.org/mailman/listinfo/python-list


what is the easiest way to install multiple Python versions?

2014-10-12 Thread Albert-Jan Roskam
Hi,

(sorry for cross-posting)

A few days ago I needed to check whether some Python code ran with Python 2.6. 
What is the easiest way to install another Python version along side the 
default Python version? My own computer is Debian Linux 64 bit, but a 
platform-independent solution would be best.

Possible solutions that I am aware of

-make altinstall *). This is what I tried (see below), but not all modules 
could be built. I gave up because I was in a hurry
-Pythonbrew. This project is dead
-Deadsnakes
-Anaconda
-Tox? I only know this is as a cross-version/implementation test runner
-Vagrant. This is what I eventually did, and this was very simple. I ran Ubuntu 
10.0.4 LTS, which uses Python 2.6, and used Vagrant SSH to run and check my 
code in Python 2.6 (and I replaced a dict comprehension with a list 
comprehension, for example)
- ...

What is the recommended way? I don't expect/hope that I'd ever need something 
lower than Python 2.5

Thank you.

Albert-Jan


*) Make altinstall
sudo apt-get install libsqlite3-dev libbz2-dev libgdbm-dev libncurses5-dev 
tk-dev zlib1g-dev
wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz
tar -zxvf Python-2.6.8.tgz
cd Python-2.6.8/
./configure --prefix=/usr/local
make  # see 'failed stuff' below
sudo make altinstall
mkvirtualenv -p /usr/local/bin/python2.6 python26  # ImportError: No module 
named zlib


# Failed stuff
Failed to find the necessary bits to build these modules:
_bsddb_curses_curses_panel
_hashlib  _sqlite3  _ssl
bsddb185  bz2dbm
dlgdbm  imageop
linuxaudiodev  ossaudiodevreadline
sunaudiodevzlib





~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a 

fresh water system, and public health, what have the Romans ever done for us?

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


Re: Flask and Django

2014-10-12 Thread Juan Christian
Anyone?

On Fri, Oct 10, 2014 at 7:22 PM, Juan Christian juan0christ...@gmail.com
wrote:

 So, I'm already familiar with Flask and I fell comfortable using it, but I
 see that no one uses it in real business, everywhere I look regarding
 jobs and web dev, people always talk about Django, no one mentions Flask,
 no one uses Flask.

 I'm coding a personal tool using Flask but I feel the need to convert it
 to Django because no ones seems to give attention to Flask, but no matter
 what, I don't like, I don't fully understand Django, there are tons of
 conventions, code generations and and too much red tape.

 Maybe that's because I feel the Django doc a bit confuse, I tried reading
 (and practicing!) tutorials, official doc, books, and so on, but I can't
 quite understand the whole thing.

 Is Flask really underestimated? Can you guys mention big name companies
 or people using it? Does it have real value in real world business?

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


Re: TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-12 Thread Rustom Mody
Whats the problem??
Seems to work (python 2.7.8)

[Ive added a line so that that you can see]

class C:
   def __init__(self):
   pass

class C2(C):
def __init__(self, *args, **kwargs):
self.dic = kwargs
pass
x = C2(kwarg='a')
y = C2(kwarg='a', kwarg2=8)



 x.dic
{'kwarg': 'a'}
 y.dic
{'kwarg': 'a', 'kwarg2': 8}
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Django

2014-10-12 Thread Chris Angelico
On Sat, Oct 11, 2014 at 9:22 AM, Juan Christian
juan0christ...@gmail.com wrote:
 So, I'm already familiar with Flask and I fell comfortable using it, but I
 see that no one uses it in real business, everywhere I look regarding jobs
 and web dev, people always talk about Django, no one mentions Flask, no one
 uses Flask.

I can't really say about job postings, but presumably you've done the
searches and found that to be the case. But there are plenty of jobs
around that don't specifically name the technologies you have to use.
If you're asked to create a web site from nothing, it doesn't much
matter what you use, as long as you get the job done.

The other thing to note is that job postings and resumes form a
feedback loop. Why bother mentioning Flask on your resume, if no
employers ever ask about it? Why bother looking for Flask programmers,
if nobody ever mentions having experience with it?

My personal recommendation: Stick to Flask. It's a good system, and
there's no reason to run away from it. (That said, I've yet to use
Django, and I've used Flask for exactly one web site, which is why I
didn't respond to you when you first posted.) Learn Django if you feel
you need to, but don't avoid Flask just because nobody ever asks you
about it for a job posting.

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


Re: what is the easiest way to install multiple Python versions?

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 12:33 AM, Albert-Jan Roskam
fo...@yahoo.com.dmarc.invalid wrote:
 *) Make altinstall
 sudo apt-get install libsqlite3-dev libbz2-dev libgdbm-dev libncurses5-dev 
 tk-dev zlib1g-dev
 wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz
 tar -zxvf Python-2.6.8.tgz
 cd Python-2.6.8/
 ./configure --prefix=/usr/local
 make  # see 'failed stuff' below
 sudo make altinstall
 mkvirtualenv -p /usr/local/bin/python2.6 python26  # ImportError: No module 
 named zlib


 # Failed stuff
 Failed to find the necessary bits to build these modules:
 _bsddb_curses_curses_panel
 _hashlib  _sqlite3  _ssl
 bsddb185  bz2dbm
 dlgdbm  imageop
 linuxaudiodev  ossaudiodevreadline
 sunaudiodevzlib

Generally, this is the method I would recommend. For a start, run this:

sudo apt-get build-dep python

This is in place of your explicit apt-get install command; Debian
keeps track of the dev packages needed to rebuild a given program, and
will go fetch them for you.

After that, just look at exactly what packages you're still lacking.
You may well find that you don't have all the dependencies for all
Python modules, as some of them might not be included in a basic
apt-get install python installation; the solution is a bit more
apt-get build-dep work, or some manual hunting down of dev packages
(which may well be easier in some situations).

But what version of Debian are you after, and why are you trying to
build a 2.6.8 from source? On Debian Wheezy, getting hold of Python
2.6 should be as easy as:

$ sudo apt-get install python2.6

I believe Squeeze ships 2.6 as its standard system Python, so it's
even easier. Are you on the unreleased Jessie? And why do you even
need 2.6 as opposed to 2.7?

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


what is wrong with this script and how do I get the value in a php script

2014-10-12 Thread martijnperdaan
what is wrong with this script and how do I get the value Rij1 and Rij2 and 
Rij3 and Rij4 and Rij5 and Rij6 in a php script

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

GPIO.setup(17, GPIO.IN)
GPIO.setup(18, GPIO.IN)
GPIO.setup(21, GPIO.IN)
GPIO.setup(22, GPIO.IN)
GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)

Rij1 = 0
Rij2 = 0
Rij3 = 0
Rij4 = 0
Rij5 = 0
Rij6 = 0


while True:
PRij1 = GPIO.input(17)
PRij2 = GPIO.input(18)
PRij3 = GPIO.input(21)
PRij4 = GPIO.input(22)
PRij5 = GPIO.input(23)
PRij6 = GPIO.input(24)

if (PRij1 == False):
Rij1 = Rij1 + 1
   while PRij1 == False:
PRij1 = GPIO.input(17)

if (PRij2 == False):
Rij2 = Rij2 + 1
   while PRij2 == False:
PRij2 = GPIO.input(18)

if (PRij3 == False):
Rij3 = Rij3 + 1
   while PRij3 == False:
PRij3 = GPIO.input(21)

if (PRij4 == False):
Rij4 = Rij4 + 1
   while PRij4 == False:
PRij4 = GPIO.input(22)

if (PRij5 == False):
Rij5 = Rij5 + 1
   while PRij5 == False:
PRij5 = GPIO.input(23)

if (PRij6 == False):
Rij6 = Rij6 + 1
   while PRij6 == False:
PRij6 = GPIO.input(24)

Totaal = Rij1 + Rij2 + Rij3 + Rij4 + Rij5 + Rij6
print Totaal
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what is the easiest way to install multiple Python versions?

2014-10-12 Thread Gayathri J
I have been using Anaconda's (Continnum) conda installation for system
installation (python 2.7) and for python 3

conda lets us maintain diferent environments with different python and
different combinations of other packages like numpy etc...

sure not to disappoint!


On 10/12/14, Albert-Jan Roskam fo...@yahoo.com.dmarc.invalid wrote:
 Hi,

 (sorry for cross-posting)

 A few days ago I needed to check whether some Python code ran with Python
 2.6. What is the easiest way to install another Python version along side
 the default Python version? My own computer is Debian Linux 64 bit, but a
 platform-independent solution would be best.

 Possible solutions that I am aware of

 -make altinstall *). This is what I tried (see below), but not all modules
 could be built. I gave up because I was in a hurry
 -Pythonbrew. This project is dead
 -Deadsnakes
 -Anaconda
 -Tox? I only know this is as a cross-version/implementation test runner
 -Vagrant. This is what I eventually did, and this was very simple. I ran
 Ubuntu 10.0.4 LTS, which uses Python 2.6, and used Vagrant SSH to run and
 check my code in Python 2.6 (and I replaced a dict comprehension with a list
 comprehension, for example)
 - ...

 What is the recommended way? I don't expect/hope that I'd ever need
 something lower than Python 2.5

 Thank you.

 Albert-Jan


 *) Make altinstall
 sudo apt-get install libsqlite3-dev libbz2-dev libgdbm-dev libncurses5-dev
 tk-dev zlib1g-dev
 wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz
 tar -zxvf Python-2.6.8.tgz
 cd Python-2.6.8/
 ./configure --prefix=/usr/local
 make  # see 'failed stuff' below
 sudo make altinstall
 mkvirtualenv -p /usr/local/bin/python2.6 python26  # ImportError: No module
 named zlib


 # Failed stuff
 Failed to find the necessary bits to build these modules:
 _bsddb_curses_curses_panel
 _hashlib  _sqlite3  _ssl
 bsddb185  bz2dbm
 dlgdbm  imageop
 linuxaudiodev  ossaudiodevreadline
 sunaudiodevzlib





 ~~

 All right, but apart from the sanitation, the medicine, education, wine,
 public order, irrigation, roads, a

 fresh water system, and public health, what have the Romans ever done for
 us?

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

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


Re: what is wrong with this script and how do I get the value in a php script

2014-10-12 Thread Peter Pearson
On Sun, 12 Oct 2014 07:24:52 -0700 (PDT), martijnperd...@gmail.com wrote:
 what is wrong with this script and how do I get the value Rij1 and 
 Rij2 and Rij3 and Rij4 and Rij5 and Rij6 in a php script

 import RPi.GPIO as GPIO
 GPIO.setmode(GPIO.BCM)

 GPIO.setup(17, GPIO.IN)
 GPIO.setup(18, GPIO.IN)
 GPIO.setup(21, GPIO.IN)
 GPIO.setup(22, GPIO.IN)
 GPIO.setup(23, GPIO.IN)
 GPIO.setup(24, GPIO.IN)

 Rij1 = 0
 Rij2 = 0
 Rij3 = 0
 Rij4 = 0
 Rij5 = 0
 Rij6 = 0


 while True:
 PRij1 = GPIO.input(17)
   PRij2 = GPIO.input(18)
   PRij3 = GPIO.input(21)
   PRij4 = GPIO.input(22)
   PRij5 = GPIO.input(23)
   PRij6 = GPIO.input(24)

 if (PRij1 == False):
   Rij1 = Rij1 + 1
while PRij1 == False:
 PRij1 = GPIO.input(17)
[snip]

I regret that I can't solve your problem, but perhaps I can move
the conversation in a useful direction.

If this is a question about RPi.GPIO, it would be good to phrase it
as the simplest possible question about RPi.GPIO.  If it's *not* a
question about RPi.GPIO, it would be useful to replace the references
to RPi.GPIO with some artificial substitute, so that people who don't
have RPi.GPIO on their systems can contribute to the discussion.  For
example, I don't know what type of object is returned by GPIO.input.
Your code appears to assume that it's True or False, but I don't know
whether that's a valid assumption.

When asking why something doesn't work, one greatly improves one's
chances of getting a prompt and useful answer if one reveals precisely
(1) what one desires, and (2) what one gets.

Finally, the code you posted is indented in a way that is not legal Python,
leaving people to guess at what you intended to post.

And finally finally, why do you call this a PHP script?  This is a
Python newsgroup.

-- 
To email me, substitute nowhere-runbox, invalid-com.
-- 
https://mail.python.org/mailman/listinfo/python-list


while loop - multiple condition

2014-10-12 Thread Shiva
Why is the second part of while condition not being checked?

while ans.lower() != 'yes' or ans.lower()[0] != 'y':
 ans = input('Do you like python?')


My intention is if either of the conditions are true the loop should break.
But the condition after 'or' doesn't seem to evaluate.

Thanks,
Shiva.

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


Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:08 AM, Shiva
shivaji...@yahoo.com.dmarc.invalid wrote:
 Why is the second part of while condition not being checked?

 while ans.lower() != 'yes' or ans.lower()[0] != 'y':
  ans = input('Do you like python?')


 My intention is if either of the conditions are true the loop should break.
 But the condition after 'or' doesn't seem to evaluate.

The loop will continue while either part is true - that's what or
means. Is that what you intended it to be doing?

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


Re: Butterflow installation on windows

2014-10-12 Thread Mark Lawrence

On 11/10/2014 16:20, Virgil Stokes wrote:

The butterflow package (https://pypi.python.org/pypi/butterflow/0.1.4a1)
has recently been released. I would like to know if anyone has been able
to install it on a windows platform.


Short answer no.

Long answer follows.

c:\Users\Mark\PythonIssuespip install -U --pre butterflow
Downloading/unpacking butterflow
  Downloading butterflow-0.1.4a1.tar.gz
  Running setup.py 
(path:C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow\setup.py) 
egg_info for package butterflow

Traceback (most recent call last):
  File string, line 17, in module
  File 
C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow\setup.py, 
line 287, in module

py_includes = pkg_config_res('--cflags', 'python2')
  File 
C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow\setup.py, 
line 205, in pkg_config_res

env=get_extra_envs()).stdout.read()
  File C:\Python34\lib\subprocess.py, line 858, in __init__
restore_signals, start_new_session)
  File C:\Python34\lib\subprocess.py, line , in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file 
specified

Complete output from command python setup.py egg_info:
Traceback (most recent call last):

  File string, line 17, in module

  File 
C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow\setup.py, 
line 287, in module


py_includes = pkg_config_res('--cflags', 'python2')

  File 
C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow\setup.py, 
line 205, in pkg_config_res


env=get_extra_envs()).stdout.read()

  File C:\Python34\lib\subprocess.py, line 858, in __init__

restore_signals, start_new_session)

  File C:\Python34\lib\subprocess.py, line , in _execute_child

startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified


Cleaning up...
Command python setup.py egg_info failed with error code 1 in 
C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\butterflow

Storing debug log for failure in C:\Users\Mark\pip\pip.log

Quoting from 
http://pip.readthedocs.org/en/latest/reference/pip_install.html#options 
for the --pre flag Include pre-release and development versions. By 
default, pip only finds stable versions.


Looking at the output above and at the URL you quote I doubt that it'll 
work for me as it seems to be Python 2 only.  The URL also lists a load 
of dependancies and I've no idea whether or not you could get them for 
Windows or not.  There's only one way to find out, so would you like to 
give it a go and let us know how you get on?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: while loop - multiple condition

2014-10-12 Thread Shiva

 The loop will continue while either part is true - that's what or
 means. Is that what you intended it to be doing?
 
 ChrisA
 


Yes..however, the second part of the or condition doesn't get evaluated.
So if I enter a 'y' - I expect the second part to evaluate and the loop to
break - but that doesn't seem to happen.

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


Re: while loop - multiple condition

2014-10-12 Thread Roy Smith
In article mailman.14792.1413133694.18130.python-l...@python.org,
 Shiva shivaji...@yahoo.com wrote:

 Why is the second part of while condition not being checked?
 
 while ans.lower() != 'yes' or ans.lower()[0] != 'y':
  ans = input('Do you like python?')
 
 
 My intention is if either of the conditions are true the loop should break.
 But the condition after 'or' doesn't seem to evaluate.

A general rule of programming (be it Python or any other language) is to 
break up complicated code into smaller pieces which can be understood 
and tested in isolation.  Your 'while' condition is kind of hairy.  
There's a couple of complicated expressions, a logical conjuction, and 
two different negated comparisons.  That's a lot to understand all at 
once.

I would factor that out into a little function:

---
def is_yes(answer):
  if answer.lower() == 'yes':
return True
  if answer.lower()[0] == 'y':
return True
  return False

while is_yes(ans):
  ans = input('Do you like python?')
---

Now, you can play around with your is_yes() function in an interactive 
session and see what it returns for various inputs, in isolation from 
the rest of your program:

print is_yes('y')
print is_yes('yes')
print is_yes('no')
print is_yes('you bet your sweet bippy')
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:21 AM, Shiva
shivaji...@yahoo.com.dmarc.invalid wrote:
 The loop will continue while either part is true - that's what or
 means. Is that what you intended it to be doing?

 ChrisA



 Yes..however, the second part of the or condition doesn't get evaluated.
 So if I enter a 'y' - I expect the second part to evaluate and the loop to
 break - but that doesn't seem to happen.

Break it down into separate parts and have a look at what's happening.

while ans.lower() != 'yes' or ans.lower()[0] != 'y':
ans = input('Do you like python?')
print(ans.lower() = {!r}; first cond = {!r}, second cond {!r},
disjunction {!r}.format(
ans.lower(), (ans.lower() != 'yes'), (ans.lower()[0] != 'y'),
(ans.lower() != 'yes' or ans.lower()[0] != 'y')
))

The while loop will continue so long as the disjunction is True. See
what it's actually doing.

This is fundamental Boolean logic, a basic skill of programming.
You're going to need to master this. Look at the different pieces, and
get your head around what the 'or' operator actually does.

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


Re: while loop - multiple condition

2014-10-12 Thread Shiva
Bit confusing to use in While loop - Should have used the 'and' condition
instead of OR- then it works fine.
for OR both condition need to be false to produce a false output and break
the loop.
More of SET operations.

Thanks,
Shiva

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


Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:59 AM, Shiva
shivaji...@yahoo.com.dmarc.invalid wrote:
 Bit confusing to use in While loop - Should have used the 'and' condition
 instead of OR- then it works fine.
 for OR both condition need to be false to produce a false output and break
 the loop.

Correct, what you're looking for here is indeed an 'and' (also called
a conjunction, as opposed to the disjunction of 'or'). Both operators
are important; and you need to understand what they do so you know
when to use each.

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


Re: what is wrong with this script and how do I get the value in a php script

2014-10-12 Thread Denis McMahon
On Sun, 12 Oct 2014 07:24:52 -0700, martijnperdaan wrote:

 what is wrong with this script and how do I get the value Rij1 and Rij2
 and Rij3 and Rij4 and Rij5 and Rij6 in a php script

I can see several pythonic errors in your script, however as for what is 
wrong, I see no indication from you of what you expect it to do, what 
output you expect, what error messages you get when you try and run it 
etc.

Perhaps a better subject would have been how to read gpio on raspberry 
pi

It also helps if you can reduce your code example to the minimum needed 
to demonstrate the error. In this case, I would suggest that once you can 
read one input correctly, you should be able to expand that code to read 
all inputs.

The code below might help (uses 2.x style print):

import RPi.GPIO as GPIO

GPIO.setmode(mode)
GPIO.setup(17, GPIO.IN)

if GPIO.input(17) == GPIO.HIGH:
print True
else:
print False

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


Re: Toggle

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 5:38 AM, Tony the Tiger tony@tiger.invalid wrote:
 colour = 'red' if colour == 'blue' else 'blue'

 I call that a subtle bug that most likely will jump up and bite your
 behind when you least expect it.

More generally, I'd say that this is solving a (very) slightly
different problem: it's providing a toggle with default feature,
where the part after the else is the default. If you don't want a
default, that's a bug. I've known times when that default makes life a
lot easier, in which case it'd be a feature.

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


Re: TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-12 Thread Ian Kelly
On Sun, Oct 12, 2014 at 6:55 AM, roro codeath rorocode...@gmail.com wrote:
 How to implement it in my class?

 class Str(str):
 def __init__(self, *args, **kwargs):
 pass

 Str('smth', kwarg='a')

The error is coming from the __new__ method. Because str is an
immutable type, you should override the __new__ method, not __init__.
Example:

class Str(str):
def __new__(cls, *args, **kwargs):
return super().__new__(cls, args[0])

 Str('smth', kwarg='a')
'smth'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: while loop - multiple condition

2014-10-12 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Mon, Oct 13, 2014 at 4:59 AM, Shiva
 shivaji...@yahoo.com.dmarc.invalid wrote:
 Bit confusing to use in While loop - Should have used the 'and' condition
 instead of OR- then it works fine.
 for OR both condition need to be false to produce a false output and break
 the loop.

 Correct, what you're looking for here is indeed an 'and' (also called
 a conjunction, as opposed to the disjunction of 'or'). Both operators
 are important; and you need to understand what they do so you know
 when to use each.

The corrected version

while ans.lower() != 'yes' and ans.lower()[0] != 'y':
 ans = input('Do you like python?')

is equivalent with

while ans.lower()[0] != 'y':
 ans = input('Do you like python?')


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


Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 6:16 AM, Marko Rauhamaa ma...@pacujo.net wrote:
 The corrected version

 while ans.lower() != 'yes' and ans.lower()[0] != 'y':
  ans = input('Do you like python?')

 is equivalent with

 while ans.lower()[0] != 'y':

It's true that the first part is redundant, but trimming that out
wouldn't have taught the OP about boolean logic :)

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


Re: while loop - multiple condition

2014-10-12 Thread Denis McMahon
On Sun, 12 Oct 2014 17:08:00 +, Shiva wrote:

 while ans.lower() != 'yes' or ans.lower()[0] != 'y':

while ans.lower() is not equal to yes
   or ans.lower()[0] is not equal to y

the loop will continue to run

Note that if ans.lower() == 'y', then the first clause ( ans.lower() != 
'yes' ) is true, so the loop will continue to run, ignoring the result of 
the second clause ( ans.lower()[0] != 'y' ), This will also be the case 
if you reverse the order of the clauses.

It seems that you need a better understanding of combinatorial logic, 
perhaps http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/
index.html#booleantheorems will help.

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


How to install and run a script?

2014-10-12 Thread Ryan Shuell
I'm an absolute noob to Python, although I have been programming in several 
other languages for over 10 years.

I'm trying to install and run some scripts, and I'm not having much success.

I followed the steps at this site.
https://docs.python.org/2/install/

I have Python 2.7.6 Shell.

If I type this:
python setup.py install

I get this:
SyntaxError: invalid syntax


If I try this:
setup.py beautifulsoup

I get this:
SyntaxError: invalid syntax


If I got to File  Open . . . . navigate to a folder and open the setup.py file 
and hit F5 . . . . it looks like it runs, but I can't tell what it does for 
sure, and then nothing works after that.For instance, I downloaded 
something called 'Flask'.  I put that folder in my Python27 folder, and typed 
'pip install Flask' and I keep getting errors.  

Any idea how to run a simple program???
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install and run a script?

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 7:17 AM, Ryan Shuell ryanshu...@gmail.com wrote:
 I'm an absolute noob to Python, although I have been programming in several 
 other languages for over 10 years.

 I'm trying to install and run some scripts, and I'm not having much success.

 I followed the steps at this site.
 https://docs.python.org/2/install/

 I have Python 2.7.6 Shell.

 If I type this:
 python setup.py install

 I get this:
 SyntaxError: invalid syntax

Hi!

The commands you're looking at need to be run from your regular shell;
I'm guessing you may be on Windows, so that would be the command
prompt (cmd.exe). But rather than playing with setup.py directly, you
should now be able to use pip, which is also run from the command
line:

C:\pip install flask
C:\\python27\Scripts\pip install flask

The first version works if you've added the appropriate directories to
your PATH, the second is where the executable is actually found. I
have several Pythons installed, so I didn't let it put itself into
PATH; chances are you can take the easy route.

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


Fwd: How to install and run a script?

2014-10-12 Thread Abhiram


Begin forwarded message:

 From: Ryan Shuell ryanshu...@gmail.com
 Subject: How to install and run a script?
 Date: 13 October 2014 1:47:58 am IST
 To: python-list@python.org
 
 I'm an absolute noob to Python, although I have been programming in several 
 other languages for over 10 years.
 
 I'm trying to install and run some scripts, and I'm not having much success.
 
 I followed the steps at this site.
 https://docs.python.org/2/install/
 
 I have Python 2.7.6 Shell.
 
 If I type this:
 python setup.py install
 
 I get this:
 SyntaxError: invalid syntax
 

Have you completed installation?
If you type “Python” in Cmd, or “Python” in terminal, do you get the Python 
prompt “” ?
My guess is that your Python installation’s executable isn’t in the Windows / 
Linux $PATH variable. 
Give us more details so we can help you out further. :)

Thanks
Abhiram
“Py,Py,Py your boat. Gently down the IOstream-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install and run a script?

2014-10-12 Thread Mark Lawrence

On 12/10/2014 21:17, Ryan Shuell wrote:

I'm an absolute noob to Python, although I have been programming in several 
other languages for over 10 years.

I'm trying to install and run some scripts, and I'm not having much success.

I followed the steps at this site.
https://docs.python.org/2/install/


You're looking at the wrong docs.  Having said that I'd just grab pip, 
see http://pip.readthedocs.org/en/latest/installing.html


Once it's successfully installed just

pip install beautifulsoup

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: while loop - multiple condition

2014-10-12 Thread Tim Chase
On 2014-10-12 22:16, Marko Rauhamaa wrote:
 is equivalent with
 
 while ans.lower()[0] != 'y':
  ans = input('Do you like python?')

And still better improved with

  while ans[:1].lower() != 'y':
ans = input('Do you like python?')

in the event that len(ans)==0 (a situation which will crash the
various current examples).

It also only expends the effort to lowercase 0-or-1 characters,
rather than lowercasing an entire string just to throw away
everything except the first character.

-tkc



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


Re: while loop - multiple condition

2014-10-12 Thread Steven D'Aprano
Tim Chase wrote:

 On 2014-10-12 22:16, Marko Rauhamaa wrote:
 is equivalent with
 
 while ans.lower()[0] != 'y':
  ans = input('Do you like python?')
 
 And still better improved with
 
   while ans[:1].lower() != 'y':
 ans = input('Do you like python?')


The intention is to loop forever until the victim breaks down and accepts
that they like Python, by entering yes or y. I'm pretty sure that
entering yellow or you've got to be kidding should not break the loop.

When you have multiple clauses in the condition, it's easier to reason about
them if you write the clauses as positive statements rather than negative
statements, that is, something is true rather than something is not
true, and then use `not` to reverse it if you want to loop *until* the
overall condition is true.

When checking for equality against multiple values, instead of:

x == a or x == b or x == c

it is usually easier to use `in`:

x in (a, b, c)


So we have:

# loop so long as the victim answers yes or y
while ans.lower() in ('yes', 'y'):
ans = input('Do you like python? Well, do you?')

# loop until the victim answers yes or y
while not (ans.lower() in ('yes', 'y')):
ans = input('Do you like python? Well, do you?')


both of which work fine if the user stays mum by entering the empty string.

You can also write:

while ans.lower() not in ('yes', 'y'):
ans = input('Do you like python? Well, do you?')


if you prefer. In my opinion, that's the most readable version of all.

One last note: if you are using Python 3.3 or better, you can support
international text better by using the casefold() method rather than
lower(). In this case, it won't make a difference, but the technically
correct method for doing case-insensitive comparisons is to casefold both
strings rather than lower- or upper-case them.


-- 
Steven

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


Re: TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-12 Thread Terry Reedy

On 10/12/2014 2:45 PM, Ian Kelly wrote:

On Sun, Oct 12, 2014 at 6:55 AM, roro codeath rorocode...@gmail.com wrote:

How to implement it in my class?

class Str(str):
 def __init__(self, *args, **kwargs):
 pass

Str('smth', kwarg='a')


The error is coming from the __new__ method. Because str is an
immutable type, you should override the __new__ method, not __init__.


or, if one is mere adding a method, do not add __new__ either.


Example:

class Str(str):
 def __new__(cls, *args, **kwargs):
 return super().__new__(cls, args[0])


Str('smth', kwarg='a')

'smth'




--
Terry Jan Reedy

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


Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 11:43 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 ONE: Python uses short circuit evaluation: for an OR, the second 
 clause
 is only looked at if the first clause is FALSE (for an AND, the first
 clause has to be TRUE before the second is evaluated).

Short-circuiting doesn't actually matter here, incidentally. It could
be eagerly evaluated and nothing would be different.

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


Re: what is the easiest way to install multiple Python versions?

2014-10-12 Thread Terry Reedy

On 10/12/2014 9:33 AM, Albert-Jan Roskam wrote:


A few days ago I needed to check whether some Python code ran with
Python 2.6. What is the easiest way to install another Python version
along side the default Python version? My own computer is Debian
Linux 64 bit, but a platform-independent solution would be best.


Installation is platform dependent.  On Windows, the answer would simply 
be 'get the PSF x.y installer and run it'.


--
Terry Jan Reedy

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


Re: How to install and run a script?

2014-10-12 Thread ryguy7272
On Sunday, October 12, 2014 4:18:19 PM UTC-4, ryguy7272 wrote:
 I'm an absolute noob to Python, although I have been programming in several 
 other languages for over 10 years.
 
 
 
 I'm trying to install and run some scripts, and I'm not having much success.
 
 
 
 I followed the steps at this site.
 
 https://docs.python.org/2/install/
 
 
 
 I have Python 2.7.6 Shell.
 
 
 
 If I type this:
 
 python setup.py install
 
 
 
 I get this:
 
 SyntaxError: invalid syntax
 
 
 
 
 
 If I try this:
 
 setup.py beautifulsoup
 
 
 
 I get this:
 
 SyntaxError: invalid syntax
 
 
 
 
 
 If I got to File  Open . . . . navigate to a folder and open the setup.py 
 file and hit F5 . . . . it looks like it runs, but I can't tell what it does 
 for sure, and then nothing works after that.For instance, I downloaded 
 something called 'Flask'.  I put that folder in my Python27 folder, and typed 
 'pip install Flask' and I keep getting errors.  
 
 
 
 Any idea how to run a simple program???


Ah!!!  I didn't know I needed to run it from the command prompt!  Ok, not 
it makes sense, and everything works.

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


Re: what is the easiest way to install multiple Python versions?

2014-10-12 Thread Rustom Mody
On Sunday, October 12, 2014 7:06:14 PM UTC+5:30, Albert-Jan Roskam wrote:
 Hi,
 
 A few days ago I needed to check whether some Python code ran with Python 
 2.6. What is the easiest way to install another Python version along side the 
 default Python version? My own computer is Debian Linux 64 bit, but a 
 platform-independent solution would be best.
 
 
 
 Possible solutions that I am aware of
 
 
 
 -make altinstall *). This is what I tried (see below), but not all modules 
 could be built. I gave up because I was in a hurry
 
 -Pythonbrew. This project is dead
 
 -Deadsnakes
 
 -Anaconda
 
 -Tox? I only know this is as a cross-version/implementation test runner
 
 -Vagrant. This is what I eventually did, and this was very simple. I ran 
 Ubuntu 10.0.4 LTS, which uses Python 2.6, and used Vagrant SSH to run and 
 check my code in Python 2.6 (and I replaced a dict comprehension with a list 
 comprehension, for example)

Hearing a bit about docker nowadays.

Here's why its supposedly better than a VM:
https://www.docker.com/whatisdocker/

Downsides?? No idea!
-- 
https://mail.python.org/mailman/listinfo/python-list


problem with pytz

2014-10-12 Thread ryguy7272
I just tried running the code from here.
http://www.thealgoengineer.com/2014/download_sp500_data/

I got this error.
Traceback (most recent call last):
  File C:/Python27/stock_data.py, line 4, in module
import pytz
ImportError: No module named pytz

So, I got here and download the files.
https://pypi.python.org/pypi/pytz/#downloads

I run this:
python setup.py install

I get this error.
python: can't open file 'setup.py': [Errno 2] No such file or directory

I tried this:
easy_install --upgrade pytz


Now, that seems like it downloaded and installed.  So, I re-run the program, 
and I get the same error I had initially.  
Traceback (most recent call last):
  File C:/Python27/stock_data.py, line 4, in module
import pytz
ImportError: No module named pytz


I don't get it.  I go to the path 'C:\Python27\pytz' and the folder is right 
there!  It's right there!  It's a little frustrating because all my problems 
seem to be exactly the same, which is running scripts that should run 
easily...bu nothing actually runs.  What else do I need to do to make this 
thing work?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with pytz

2014-10-12 Thread Mark Lawrence

On 13/10/2014 03:55, ryguy7272 wrote:

I just tried running the code from here.
http://www.thealgoengineer.com/2014/download_sp500_data/

I got this error.
Traceback (most recent call last):
   File C:/Python27/stock_data.py, line 4, in module


Please don't put your code here, what happens when you upgrade your 
Python version?



 import pytz
ImportError: No module named pytz

So, I got here and download the files.
https://pypi.python.org/pypi/pytz/#downloads

I run this:
python setup.py install

I get this error.
python: can't open file 'setup.py': [Errno 2] No such file or directory

I tried this:
easy_install --upgrade pytz


Now, that seems like it downloaded and installed.  So, I re-run the program, 
and I get the same error I had initially.
Traceback (most recent call last):
   File C:/Python27/stock_data.py, line 4, in module
 import pytz
ImportError: No module named pytz


I don't get it.  I go to the path 'C:\Python27\pytz' and the folder is right 
there!  It's right there!  It's a little frustrating because all my problems 
seem to be exactly the same, which is running scripts that should run 
easily...bu nothing actually runs.  What else do I need to do to make this 
thing work?



It should be in c:\python27\lib\site-packages.  It's also far easier to 
use pip to install code.  It's already available as an option with 3.4 
and I think will be automatically included with 3.5


Finally it looks as if you're using googlegroups.  If that is the case 
would you please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing 
double line spacing and single line paragraphs.  Better yet access this 
list via https://mail.python.org/mailman/listinfo/python-list, thanks.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


[issue22609] Constructors of some mapping classes don't accept `self` keyword argument

2014-10-12 Thread Raymond Hettinger

Raymond Hettinger added the comment:

After some thought, I think we have to fix this.

I'll go through the patch in careful detail this weekend.

Ethan, if you would like to help, it would be great to have a third pair of 
eyes looking at the patch to make sure it correct it every detail.

--
priority: low - normal

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-10-12 Thread Ned Deily

Ned Deily added the comment:

A comment on Vinay's comment: and this cannot be obtained from sys.executable 
because that is pointing to a framework executable.  That *was* true prior to 
3.3 and is still true at the moment for 2.7.x but it is not true for 3.3+.  
Ronald's change (b79d276041a8) in Issue15307 for venv framework support changed 
the stub launcher to no longer do a realpath() on the executable name which 
means that sys.executable contains the path to the Python stub launcher whether 
or not in a venv:

$ ls -l /usr/local/bin/python2.7
lrwxr-xr-x  1 root  admin  71 Jul  3 01:21 /usr/local/bin/python2.7 - 
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
$ /usr/local/bin/python2.7 -c 'import sys;print(sys.executable)'
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

$ ls -l /usr/local/bin/python3.4
lrwxr-xr-x  1 root  wheel  71 Oct  6 16:53 /usr/local/bin/python3.4 - 
../../../Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
$ /usr/local/bin/python3.4 -c 'import sys;print(sys.executable)'
/usr/local/bin/python3.4

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 922526816b25 by Georg Brandl in branch '3.4':
Closes #22568: fix UTIME_TO_* macros in posixmodule for rare cases.
https://hg.python.org/cpython/rev/922526816b25

New changeset 0b2c7ea86d96 by Georg Brandl in branch 'default':
#22568: merge with 3.4
https://hg.python.org/cpython/rev/0b2c7ea86d96

--
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue22609] Constructors of some mapping classes don't accept `self` keyword argument

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I thought that more verbose but straightforward code would be more acceptable. 
Well, here is smaller and clever patch. Tests are the same.

--
Added file: http://bugs.python.org/file36886/collections_pos_only_params2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22609
___diff -r f592a4073672 Lib/collections/__init__.py
--- a/Lib/collections/__init__.py   Sat Oct 11 01:43:35 2014 -0500
+++ b/Lib/collections/__init__.py   Sat Oct 11 22:30:05 2014 +0300
@@ -16,6 +16,19 @@ from _weakref import proxy as _proxy
 from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
 from reprlib import recursive_repr as _recursive_repr
 
+def _wrap_dict_update(wrapped):
+# Can't use functools.wraps due to circular import
+def wrapper(*args, **kwds):
+if kwds:
+wrapped(*args, kwds=kwds)
+else:
+wrapped(*args)
+for attr in ('__module__', '__name__', '__qualname__', '__doc__',
+ '__annotations__'):
+setattr(wrapper, attr, getattr(wrapped, attr))
+del attr
+return wrapper
+
 

 ### OrderedDict
 

@@ -55,14 +68,13 @@ class OrderedDict(dict):
 # Individual links are kept alive by the hard reference in self.__map.
 # Those hard references disappear when a key is deleted from an 
OrderedDict.
 
-def __init__(self, *args, **kwds):
+@_wrap_dict_update
+def __init__(self, *args, kwds={}):
 '''Initialize an ordered dictionary.  The signature is the same as
 regular dictionaries, but keyword arguments are not recommended because
 their insertion order is arbitrary.
 
 '''
-if len(args)  1:
-raise TypeError('expected at most 1 arguments, got %d' % len(args))
 try:
 self.__root
 except AttributeError:
@@ -479,7 +491,8 @@ class Counter(dict):
 #   http://code.activestate.com/recipes/259174/
 #   Knuth, TAOCP Vol. II section 4.6.3
 
-def __init__(self, iterable=None, **kwds):
+@_wrap_dict_update
+def __init__(self, iterable=None, *, kwds={}):
 '''Create a new, empty Counter object.  And if given, count elements
 from an input iterable.  Or, initialize the count from another mapping
 of elements to their counts.
@@ -542,7 +555,8 @@ class Counter(dict):
 raise NotImplementedError(
 'Counter.fromkeys() is undefined.  Use Counter(iterable) instead.')
 
-def update(self, iterable=None, **kwds):
+@_wrap_dict_update
+def update(self, iterable=None, *, kwds=None):
 '''Like dict.update() but add counts instead of replacing them.
 
 Source can be an iterable, a dictionary, or another Counter instance.
@@ -575,7 +589,8 @@ class Counter(dict):
 if kwds:
 self.update(kwds)
 
-def subtract(self, iterable=None, **kwds):
+@_wrap_dict_update
+def subtract(self, iterable=None, *, kwds=None):
 '''Like dict.update() but subtracts counts instead of replacing them.
 Counts can be reduced below zero.  Both the inputs and outputs are
 allowed to contain zero and negative counts.
@@ -898,12 +913,13 @@ class ChainMap(MutableMapping):
 class UserDict(MutableMapping):
 
 # Start by filling-out the abstract methods
-def __init__(self, dict=None, **kwargs):
+@_wrap_dict_update
+def __init__(self, dict=None, *, kwds=None):
 self.data = {}
 if dict is not None:
 self.update(dict)
-if len(kwargs):
-self.update(kwargs)
+if kwds:
+self.update(kwds)
 def __len__(self): return len(self.data)
 def __getitem__(self, key):
 if key in self.data:
diff -r f592a4073672 Lib/test/test_collections.py
--- a/Lib/test/test_collections.py  Sat Oct 11 01:43:35 2014 -0500
+++ b/Lib/test/test_collections.py  Sat Oct 11 22:30:05 2014 +0300
@@ -1137,6 +1137,28 @@ class TestCounter(unittest.TestCase):
 self.assertEqual(c.setdefault('e', 5), 5)
 self.assertEqual(c['e'], 5)
 
+def test_init(self):
+self.assertEqual(list(Counter(self=42).items()), [('self', 42)])
+self.assertEqual(list(Counter(iterable=42).items()), [('iterable', 
42)])
+self.assertEqual(list(Counter(iterable=None).items()), [('iterable', 
None)])
+self.assertRaises(TypeError, Counter, 42)
+self.assertRaises(TypeError, Counter, (), ())
+self.assertRaises(TypeError, Counter.__init__)
+
+def test_update(self):
+c = Counter()
+c.update(self=42)
+self.assertEqual(list(c.items()), [('self', 42)])
+c = Counter()
+c.update(iterable=42)
+

[issue16040] nntplib: unlimited readline() from connection

2014-10-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 985bda4edf9d by Georg Brandl in branch '3.2':
#16040: fix unlimited read from connection in nntplib.
https://hg.python.org/cpython/rev/985bda4edf9d

--

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



[issue22571] Remove import * recommendations and examples in doc?

2014-10-12 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Many of these (such as collections, collections.abc, decimal, and itertools) 
use import * as part of the doctest setup and are not part of the generated 
page shown to users.

Also, I don't think you should be aggressive about removing the other example 
that are visible users.   The import * construct is part of the language and 
will be encountered occasionally.

For similar reasons, the decimal module was specifically designed for be easily 
usable with import * because of the numerous exceptions and rounding flags 
and constants.

There are also some examples such the one in cmd.rst that I put there 
on-purpose.  Changing it would distract from the focus of the example.

With respect to Tkinter (and other gui toolkits as well), I believe that 
import * is a standard or common practice, in part because there are so many 
widget names names and widget options.  Changing the example might make it more 
pep8-ish but would result in a good deal of clutter that isn't the normal 
practice.


  Should we finish the job?  Or leave the issue to
 individual chapter authors?

I vote for leaving any changes to the chapter authors who are in a better 
position to know that they were trying to communicate or who were just setting 
up the doctests.   As discussed above some of the import * are there for a 
reason.

We really need to start thinking of PEP 8 as something we do to our own code 
rather than something that gets inflicted on other people's code.

--
assignee: docs@python - rhettinger
nosy: +rhettinger

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



[issue22616] Allow connecting AST nodes with corresponding source ranges

2014-10-12 Thread Aivar Annamaa

New submission from Aivar Annamaa:

Currently lineno and col_offset attributes in AST nodes have confusing roles. 
According to documentation they indicate the starting position of node's source 
text but according to recent developments (#16795) they seem to indicate a 
position most suitable to use in error messages related to that node (rather 
narrow goal IMO).

Another problem is that currently the AST nodes don't contain any information 
about the end position of corresponding source text. Therefore it's very 
difficult to relate nodes with source. One could want to do this for example in 
advanced graphical debuggers (https://bitbucket.org/plas/thonny)

I propose adding new attributes to AST nodes which indicate the corresponding 
source range. If you want to keep nodes lightweight by default, then you could 
also introduce a flag in ast.parse for getting these attributes.

The range could be given either in token indices or in character positions (or 
both). This probably needs more discussion. (I would vote against pointers to 
UTF-8 bytes, as is the case with col_offset currently.)

--
components: Interpreter Core
messages: 229124
nosy: Aivar.Annamaa
priority: normal
severity: normal
status: open
title: Allow connecting AST nodes with corresponding source ranges
type: enhancement
versions: Python 3.5

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



[issue22614] Idle: problem in PyShellEditorWindow.color_breakpoint_text

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 In msg228954, Serhiy reported a new problem, which I an transferring to this
 new issue, with 2.7 and 3.4 but not 3.5.

I now can reproduce the issue on 3.5 too. But with Lib/test/test_decimal.py, 
not Lib/decimal.py. The difference between 3.4 and 3.5 is that Lib/decimal.py 
is large in 3.4, but it is tiny in 3.5.

I can easy reproduce this issue because my netbook is too slow. When I wait 
some time, and then close editor window, there is no traceback. This time is 
needed to colorize sources in editor window. May be you will reproduce this 
issue when open very large Python file and then quickly close editor window. If 
you have no such file, just concatenate large file with itself many times:

cp 
Lib/test/test_decimal.py+Lib/test/test_decimal.py+Lib/test/test_decimal.py+Lib/test/test_decimal.py+Lib/test/test_decimal.py
 testfile.py

 What system? I do not reproduce on Win 7 with an Oct 9 build.

I believe you will reproduce with enough large file.

 When?  If the command line worked for 2.7 in Jan and fails now, when did it
 start failing?  If the command worked for 3.4 after the Feb patches and
 fails now, same question.

At least with 3.4.0 I don't see this traceback. May it is hidden by the 'can't 
invoke bind command' error.

 How? You did not state, but in a later message implied that the file opened
 in the editor and the problem only happened when you closed, as with the
 January report.  However, the traceback says that the problem occurred
 during initialization.  According to Find in Files, the only call to
 color_breakpoint_text is that one __init__ call.  I therefore do not
 understand your msg228957 comment The code runs up to self.text.update()
 in restore_file_breaks() and runs further only after windows closing.

Sorry for my ugly English. I meant that the interpreter enters in 
self.text.update(), then hangs inside it and exits from it only when the 
windows is closed. I added print's before and after this statement and the 
print after the statement was not executed until I had closed the window.

--

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-10-12 Thread Vinay Sajip

Vinay Sajip added the comment:

 Ronald's change ... changed the stub launcher to no longer do a realpath() on 
 the executable name
 which means that sys.executable contains the path to the Python stub launcher 
 whether or not in a venv

Ronald's change doesn't do a realpath() on the executable name itself, but it 
*does* do a realpath() on the executable's directory. This seems to be what's 
causing the problem in Homebrew builds: there are two levels of symlink at play.

/usr/local/bin/python3.4 - /usr/local/opt/python3/bin/python3.4 - 
/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/bin/python3.4

Because of the realpath(), the wrong stub launcher (from Homebrew's 
perspective) gets pointed to by the environment variable. At least, if my 
understanding is correct.

https://github.com/pypa/pip/issues/2031#issuecomment-56294599

--

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



[issue22616] Allow connecting AST nodes with corresponding source ranges

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

If it needs some discussion, perhaps it should be raised on python-ideas first. 
 My reading of #16795 (granted I only skimmed it) was that improving the error 
messages was a *side effect* of making the position information more accurate 
(in the context of static analysis tools).

Also, unless you intend to work on a patch this isn't likely to go anywhere :)

--
nosy: +r.david.murray

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



[issue21603] IDLE SaveAs drops the extension in the prompted filename

2014-10-12 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 Can you say which version of Tk was in use 
 (it should be in the About IDLE display) and on what platform?

I am using ActiveTcl8.5.15.1 and a latest Python for Macs taken from the 
python.org download page.  I'm running OS X 10.9.5.

--

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-10-12 Thread Tim Smith

Tim Smith added the comment:

We would like to refer to python3 as /usr/local/opt/python3/bin/python3, where 
/usr/local/opt/python3 is a symlink to ../Cellar/python3/3.4.2, and 
/usr/local/Cellar/python3/3.4.2/bin/python3 is a symlink to 
/usr/local/Cellar/python3/3.4.2/Frameworks/Python.framework/Versions/3.4/bin/python3,
 which is the stub launcher for 
/usr/local/Cellar/python3/3.4.2/Frameworks/Python.framework/Versions/3.4/Python.

--

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



[issue15363] Idle/tkinter ~x.py 'save as' fails. closes idle

2014-10-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

According to the tcl/tk manual, tcl does ~ expansion on non-'old' Windows.  
However, I cannot tell in what context that could be useful.  Trying to save to 
'~/x.py' fails. The filename is not valid.  This might be because there is no 
HOME since Windows sometimes uses USERPROFILE instead.  But it seems that any 
name with a path separator is invalid.  At least on Windows, one must specify 
the directory my moving to it in the directory part of the dialog.

If dirname (passed to tk_getSaveFile as initialdir) is not  after the split 
of self.filename (and I believe it never is), it seems to me possibly a bug 
that tk_getSaveFile looks for a leading ~ for base (passed as initialfile).  
But we cannot affect that.  Serhiy, your suggesting to check self.filename 
(full name) instead of base would be correct if tk did not check base after it 
is split off.  But it does, buggy or not.  The full name of the project file 
that failed was something like F:/python/~templete.py.

Martin and Serhiy.  If I understand correctly, you are both suggesting that 
'~x.py' should become './~x.py' instead of '\~x.py'.  This seems to work 
equally well.  It seems that after ~ processing, the basename gets changed back 
to and displayed as '~x.py' and saving as such works.

You also suggest that at least your version of the escaping should not be 
limited to Windows.  It seems like this might help, and should not hurt, but I 
would like the latter tested on Linux before I commit.  Attached is my patch 
with both changes.

--
stage: needs patch - patch review
Added file: http://bugs.python.org/file36887/@tilde.patch

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



[issue21603] IDLE SaveAs drops the extension in the prompted filename

2014-10-12 Thread Ned Deily

Ned Deily added the comment:

Thanks, Raymond.  Upon further investigation, I think you are running into a 
user-wide behavior of OS X rather than specifically a Tk or IDLE issue.  By 
tradition and by default, OS X tries to hide file extensions in file Open or 
Save dialogs; this dates back to the days of Classic Mac OS when there was no 
concept of file extensions.  There is a (non-obvious) user preference in the OS 
X Finder's preferences (Finder - Preferences - Advanced - Show all filename 
extensions) that appears to control whether extensions are displayed by default 
in standard Open and Save dialogs in all applications, not just the Finder.  
(This is with OS X 10.9.x; I believe recent earlier systems behave similarly 
although the details might be slightly different).  When the preference is 
unchecked (the default), then in Save As dialogs (in IDLE and other apps) a 
Hide Extension option box appears in the lower-left corner of the Save As 
popup window and, if enabled, the extension is not displayed as pa
 rt of the file name.  Unchecking the Hide Extension box causes the extension 
to appear.  If the Finder Show all filename extensions advanced preference is 
checked, then the Hide Extension box does not appear on the Save As popup 
and the extension is always displayed.  I always have the Show all filename 
extensions preference checked so I forgot it was there and its effect on all 
file dialogs.  My guess is that you will want to have it enabled as well and 
then you should always see extensions.

Note that for the initial Save of a file in IDLE (as opposed to a Save As), 
Python 3.4 supplies a default extension of .py which is displayed regardless 
of the Finder preference setting; but Python 2.7 up through the current 2.7.8 
does not supply the default.  That changes in 2.7.9 as Terry has recently 
backported the 3.x change to 2.7 (Issue4832, although the commit message for 
the backport appears in Issue3832 due to a typo).

--

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



[issue22614] Idle: problem in PyShellEditorWindow.color_breakpoint_text

2014-10-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Makes sense now. Large file relative to machine speed + quick close click = 
close (at least to point of destruction of self.text) before initialization is 
complete.  Hence continued initialization fails. Yes, when closing crashed in 
Multicall, would not see initialization after close error.

Switch to .update_idletasks ignores close event, hence initialization gets to 
complete without error.  Do we want to do that?  I think not.  If one tries to 
edit gigabyte file, idle/tk will probably hang and one very well might want 
close event handled.  We could instead wrap test.tag_config with try: except 
AttributeError.  Original authors assumed this would never happen, but its 
occurrence seems like a rare but legitimate possibility that should be allowed 
for.

After sleeping, I will try to reproduce on my fast machine using Windows copy 
command.  3k EditorWindow.py is colorized too fast.

--
versions: +Python 3.5

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



[issue3832] add force_shared Library option to create shared lib even with use_stub=False

2014-10-12 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
Removed message: http://bugs.python.org/msg228637

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



[issue4832] IDLE does not supply a default ext of .py on Windows or OS X for new file saves

2014-10-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Misdirected push message copied here.
New changeset 69cdf71bda12 by Terry Jan Reedy in branch '2.7':
Issue #3832: backport 677a9326b4d4 to 2.7 (and delete some obsolete code).
https://hg.python.org/cpython/rev/69cdf71bda12

--

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



[issue15363] Idle/tkinter ~x.py 'save as' fails. closes idle

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Interesting, that save as ./~x.py works when the ~x.py file exists and 
doesn't work (press the Save button has no any effect at all, even doesn't 
close a dialog) when it does not exist on Linux.

--

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



[issue15363] Idle/tkinter ~x.py 'save as' fails. closes idle

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I meant save as ~x.py, without the ./ prefix.

--

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



[issue21603] IDLE: Document SaveAs extension display on Mac

2014-10-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

(I moved the commit message)

I am assuming that Ned is correct.  I think we should start documenting system 
peculiarities like this.  I changed the title and will leave this open for this 
purpose.

--
title: IDLE SaveAs drops the extension in the prompted filename - IDLE: 
Document SaveAs extension display on Mac

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



[issue22614] Idle: problem in PyShellEditorWindow.color_breakpoint_text

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which should fix this issue. The same solution already is used 
in restore_file_breaks().

--
keywords: +patch
Added file: http://bugs.python.org/file36888/issue22614.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22614
___diff -r 55d50b544a3d Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.pySun Oct 12 09:53:12 2014 +0200
+++ b/Lib/idlelib/PyShell.pySun Oct 12 13:32:30 2014 +0300
@@ -151,6 +151,9 @@ class PyShellEditorWindow(EditorWindow):
 
 def color_breakpoint_text(self, color=True):
 Turn colorizing of breakpoint text on or off
+if self.io is None:
+# can happen if IDLE closes due to the .update() call
+return
 if color:
 theme = idleConf.GetOption('main','Theme','name')
 cfg = idleConf.GetHighlight(theme, break)
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22616] Allow connecting AST nodes with corresponding source ranges

2014-10-12 Thread Edward K. Ream

Edward K. Ream added the comment:

I urge the Python development team to fix this and the related bugs given in 
the Post Script. The lack of an easy way of associating ast nodes with text 
ranges in the original sources is arguably the biggest hole in the Python api.

These bugs have immediate, severe, practical consequences for any tool that 
attempts to regularize (pep 8) or beautify Python code.

Consider the code for PythonTidy:
http://lacusveris.com/PythonTidy/PythonTidy-1.23.python

Every version has had bugs in this area arising from difficult workarounds to 
the hole in the API.  The entire Comments class is a horror directly related to 
these issues.

Consider Aivar's workaround to these bugs:
https://bitbucket.org/plas/thonny/src/8cdaa41aca7a5cc0b31618b6f1631d360c488196/src/ast_utils.py?at=default
See the docstring for def fix_ast_problems.  This is an absurdly difficult 
solution to what should be a trivial problem.

It's impossible to build reliable software using such heroic hacks.  The 
additional bugs listed below further complicate a nightmarish task.

In short, these bugs are *not* minor little nits.  They are preventing the 
development of reliable source-code tools.

Edward K. Ream

P.S. Here are the related bugs:

http://bugs.python.org/issue10769
Allow connecting AST nodes with corresponding source ranges

http://bugs.python.org/issue21295
Python 3.4 gives wrong col_offset for Call nodes returned from ast.parse

http://bugs.python.org/issue18374
ast.parse gives wrong position (col_offset) for some BinOp-s

http://bugs.python.org/issue16806
col_offset is -1 and lineno is wrong for multiline string expressions

EKR

--
nosy: +Edward.K..Ream

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



[issue21986] Idle: disable pickleability of user code objects

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It would be good to add a test of rpc.dumps().

Current code copies copyreg.dispatch_table at the moment of rpc import. But it 
can be changed later and these change will not affect private copy. For example 
the re module adds pickleability of compiled regex patterns. I think the use 
of ChainMap is more safe solution.

--

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



[issue11664] Add patch method to unittest.TestCase

2014-10-12 Thread Julian Berman

Julian Berman added the comment:

My opinion is already here re: patch vs patch.object, so I won't repeat it, but 
@Michael, if you really want .patch, are you open to adding .patch_object as 
well?

(Regardless, thanks for working on this Julien.)

--

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



[issue19232] Speed up _decimal import

2014-10-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 75b5617b8dfc by Stefan Krah in branch 'default':
Issue #19232: Fix sys.modules lookup (--without-threads)
https://hg.python.org/cpython/rev/75b5617b8dfc

--

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



[issue22617] Jobs Opportunities in France/Canada

2014-10-12 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
resolution:  - not a bug
status: open - closed

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



[issue22617] spam

2014-10-12 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
title: Jobs Opportunities in France/Canada - spam

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



[issue22617] spam

2014-10-12 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
Removed message: http://bugs.python.org/msg229142

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



[issue5700] io.FileIO calls flush() after file closed

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yet one related bug is that flush() isn't called at all if the file was opened 
with closefd=False.

 import io, os
 class MyIO(io.FileIO):
... def flush(self):
... print('closed:', self.closed)
... 
 fd = os.open('test.out', os.O_WRONLY|os.O_CREAT)
 f = MyIO(fd, 'wb', closefd=False)
 f.close()

The proposed simple patch fixes both bugs.

--
assignee:  - serhiy.storchaka
components: +IO
stage:  - patch review
type:  - behavior
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file36889/fileio_flush_closed.patch

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



[issue22618] urllib.parse.parse_qsl different results after urllib.parse.unquote

2014-10-12 Thread Alex Vaystikh

New submission from Alex Vaystikh:

parsing query-string before and after cleaning with urllib.parse.unquote can 
have very different results: 
http://nbviewer.ipython.org/gist/bornio/e112e6d8d04dfed898c8

Perhaps it should be better documented, or make the method more idempotent?

--
components: Library (Lib)
messages: 229144
nosy: Alex.Vaystikh, orsenthil
priority: normal
severity: normal
status: open
title: urllib.parse.parse_qsl different results after urllib.parse.unquote
versions: Python 3.4

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



[issue22618] urllib.parse.parse_qsl different results after urllib.parse.unquote

2014-10-12 Thread Alex Vaystikh

Changes by Alex Vaystikh alex.vaystikh+pyt...@gmail.com:


--
type:  - behavior

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



[issue22586] urljoin allow_fragments doesn't work

2014-10-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9eed2e7fa764 by Georg Brandl in branch '3.4':
Closes #22586: clarify meaning of allow_fragments in urlparse.
https://hg.python.org/cpython/rev/9eed2e7fa764

New changeset c2eda29a8ccb by Georg Brandl in branch '2.7':
Closes #22586: clarify meaning of allow_fragments in urlparse.
https://hg.python.org/cpython/rev/c2eda29a8ccb

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue22526] file iteration SystemError for huge lines (2GiB+)

2014-10-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset be600ea4ad13 by Serhiy Storchaka in branch '2.7':
Fixed and optimized a test of issue #22526.
https://hg.python.org/cpython/rev/be600ea4ad13

--

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



[issue18873] Encoding detected in non-comment lines

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I haven't fixed all bugs in handling encoding cookie yet (there are separate 
issues). Well, this issue can be closed, I'll open new issue about the PEP when 
will be needed. The PEP should be corrected because it affects how other Python 
implementations and other tools handle this.

--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue10769] ast: provide more useful range information

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

If there was a python-ideas or python-dev thread that resulted in consensus 
approval of this change, can someone post a link to it?

--
nosy: +r.david.murray

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



[issue10769] ast: provide more useful range information

2014-10-12 Thread Sven Brauch

Sven Brauch added the comment:

Hi,

Mailing list thread: 
https://mail.python.org/pipermail/python-dev/2012-December/123320.html
Discussion on the patch: http://bugs.python.org/issue16795

Greetings,
Sven

--

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



[issue21842] Fix IDLE in unicodeless build

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Most tests which detects no-unicode build, assume that the unicode doesn't 
exist. It can be confused to introduce faked public (non-underscored) name.

--

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If there are no objections, I'll commit the patch soon.

--

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



[issue13664] UnicodeEncodeError in gzip when filename contains non-ascii

2014-10-12 Thread Serhiy Storchaka

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


--
assignee:  - serhiy.storchaka

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



[issue22616] Allow connecting AST nodes with corresponding source ranges

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

The python develop team is a group of volunteers.  What you need to do to 
move this forward is to work on patches (or polishing patches, in the case of 
issue 16806) for open issues for which there has been no objection, and build a 
consensus for fixing the issues for which there has been objection.

Based on the issue 10769 discussion, it sounds like it would be worthwhile to 
go to python-ideas and advocate for the position that the ast parser should be 
enhanced for the kind of use cases you are talking about.  It is possible a PEP 
would be required, but it is also fairly likely that one will not be.

Personally I'm in favor of supporting such use cases, but I'm not involved in 
maintaining any of the relevant code nor do I have an interest in getting 
involved at this time.

--

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread Charles-François Natali

Charles-François Natali added the comment:

My only comment would be to use subprocess instead of os.popen().

--

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is different issue and can be applied only to 3.5.

--

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



[issue13664] UnicodeEncodeError in gzip when filename contains non-ascii

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I there are no objections I'll commit the patch soon.

--

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



[issue22618] urllib.parse.parse_qsl different results after urllib.parse.unquote

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

Isn't it obvious that you have to parse before you unquote?  That's the purpose 
of quoting, after all.  I suppose that is one of those beginner mind things 
that is obvious only because I'm an experienced programmer...and that there are 
web servers that do it wrong. 

The docs could definitely use some improvement, since they don't mention that 
parse_qs automatically unquotes the values...it is implicit in the fact that 
urlencode with doseq=true is the inverse, and it encodes them, but it should be 
made explicit.

You also might want to take note of the 'keep_blank_values' attribute, which 
could also use a doc improvement (it isn't obvious from the text what 'blank 
values' are):

 parse_qs('a=1b=2b=1a%3Donly_appears_after_unquote', 
 keep_blank_values=True)
{'a': ['1'], 'b': ['2', '1'], 'a=only_appears_after_unquote': ['']}

--
assignee:  - docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python, r.david.murray
versions: +Python 2.7, Python 3.5

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



[issue22618] urllib.parse.parse_qsl different results after urllib.parse.unquote

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

Eh, that Isn't it obvious comment was uncalled for.  Of course it isn't 
obvious, especially when the docs are unclear.

--

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



[issue10769] ast: provide more useful range information

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

OK, so that patch was committed.  Does that mean this one can be close?  (I'm 
not familiar with the code in question.)

--

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



[issue7665] test_urllib2 and test_ntpath fail if path contains \

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Oh-oh, I didn't attached my patch and cleared my working space.

--

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread Charles-François Natali

Charles-François Natali added the comment:

Why is that a different issue?
The code you *add in this patch* uses os.popen, why not use subprocess instead?

Furthermore, the code catches OSError when calling popen(), but
popen() doesn't raise an exception.

--

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



[issue7665] test_urllib2 and test_ntpath fail if path contains \

2014-10-12 Thread STINNER Victor

STINNER Victor added the comment:

 Oh-oh, I didn't attached my patch and cleared my working space.

Too bad. I did the same mistake yesterday :-/

--

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread STINNER Victor

STINNER Victor added the comment:

FYI os.popen() now calls subprocess... So it's safe to call directly subprocess.

--
nosy: +haypo

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread STINNER Victor

STINNER Victor added the comment:

+cmd = 'LC_ALL=C %s %s 2/dev/null' % (executable, '-ia')

It's safer to use the subprocess module instead of using a shell (see the 
recent Shellshock story) to change the environment variables and to redirect 
stderr. subprocess now has a convinient subprocess.DEVNULL. So it's something 
like:

env = os.environ.copy()
env['LC_ALL'] = 'C'
process = subprocess.Popen([executable, '-ia'], stderr=subprocess.DEVNULL)
...

--

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



[issue22616] Allow connecting AST nodes with corresponding source ranges

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

OK, reading the followon links just added to issue issue 10769, it seems clear 
you don't need to advocate for the idea of supporting external tools, there 
seems to be consensus agreement for that.  So now it is down to specific 
proposals and patches.  And reviews of patches, those are equally important :)

--

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



[issue10769] ast: provide more useful range information

2014-10-12 Thread Sven Brauch

Sven Brauch added the comment:

Yes, this issue can be closed.

--
resolution:  - fixed
status: open - closed

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



[issue7665] test_urllib2 and test_ntpath fail if path contains \

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is an attempt to reproduce my patch.

--
Added file: http://bugs.python.org/file36890/issue7665.patch

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



[issue22526] file iteration SystemError for huge lines (2GiB+)

2014-10-12 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
resolution:  - fixed
status: open - closed

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



[issue22619] Possible implementation of negative limit for traceback functions

2014-10-12 Thread Dmitry Kazakov

New submission from Dmitry Kazakov:

This is the possible patch for this proposal: 
https://mail.python.org/pipermail/python-ideas/2014-October/029826.html.

--
components: Library (Lib)
messages: 229167
nosy: vlth
priority: normal
severity: normal
status: open
title: Possible implementation of negative limit for traceback functions
type: enhancement
versions: Python 3.5

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



[issue22619] Possible implementation of negative limit for traceback functions

2014-10-12 Thread Dmitry Kazakov

Dmitry Kazakov added the comment:

def _extract_tb_or_stack_iter(curr, limit, extractor):
# Distinguish frames from tracebacks (need to import types)
if limit is None:
limit = getattr(sys, 'tracebacklimit', None)
elif limit  0 and isinstance(curr, types.TracebackType):
seq = list(_extract_tb_or_stack_iter(curr, None, extractor))
yield from seq[limit:]
else:
pass

--

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



[issue22618] urllib.parse.parse_qsl different results after urllib.parse.unquote

2014-10-12 Thread Alex Vaystikh

Alex Vaystikh added the comment:

It is much clearer after your insight:
- I wasn't aware that 'parse_qs' unquotes values. That's most helpful!
- I had no idea what 'keep_blank_values' were before your example, but now it 
couldn't be more obvious. I know that adding that example to docs would've 
helped me a lot! Maybe others?

Thank you for the help!

--

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



[issue10769] ast: provide more useful range information

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

Thanks.

--
stage: needs patch - resolved

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



[issue6478] time.tzset does not reset _strptime's locale time cache

2014-10-12 Thread R. David Murray

R. David Murray added the comment:

Berker: the patch doesn't apply cleanly any more.  Also, about the 
test_bad_timezone modification...what about the previous check that the tzname 
wasn't in UTC/GMT?  Isn't that still needed?  Or perhaps better yet, an 
additional @run_with_tz decorator?  (Note that I don't really *understand* this 
code, so I may be totally off base here... :)

--
nosy: +r.david.murray
stage: commit review - needs patch

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



[issue17293] uuid.getnode() MAC address on AIX

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 The code you *add in this patch* uses os.popen, why not use subprocess 
 instead?

Added code is just modified copy of existing code.

 Furthermore, the code catches OSError when calling popen(), but
popen() doesn't raise an exception.

It can raise an exception in rare cases. The manual of pipe mentions this. The 
code of posix_popen() contains error handling.

 FYI os.popen() now calls subprocess...

Not in 2.7.

 It's safer to use the subprocess module instead of using a shell (see the 
 recent Shellshock story) to change the environment variables and to redirect 
 stderr.

May be, but this is different issue, which is not related to this issue. If 
os.popen should be replaced with subprocess, it should be done even without 
applying the patch of this issue. Please open new issue.

However the recent Shellshock story affects only users of platforms which use 
bash or zsh as system shell (are there any?).

 subprocess now has a convinient subprocess.DEVNULL.

Not in 2.7.

--

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



  1   2   >