[issue32439] Clean up the code for compiling comparison expressions

2017-12-29 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 02b9ef27752ff4873c592ac3afe7e3410f715984 by Serhiy Storchaka in 
branch 'master':
bpo-32439: Clean up the code for compiling comparison expressions. (#5029)
https://github.com/python/cpython/commit/02b9ef27752ff4873c592ac3afe7e3410f715984


--

___
Python tracker 

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



[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread kandhan

kandhan  added the comment:

"round brackets instead of square brackets" sounds better.

Its simple and direct and doesn't require any extra operations other than the 
required one.

--

___
Python tracker 

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



[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

In British, Australian, New Zealander, and Indian English (and sometimes 
Canada), at least, "bracket" on its own typically means round brackets () and 
is rarely if ever used for square brackets [] or curly brackets {} without the 
adjective.

See for example 
https://english.stackexchange.com/questions/168762/brackets-vs-parenthesis for 
a discussion.

Consequently, the phrase "parentheses instead of brackets" reads to us as 
"parentheses instead of parentheses" would to Americans. In other words, weird 
and requiring a moment (or three) of thought to translate.

I support the suggested change to "parentheses instead of square brackets" -- 
it should read more naturally to people in the British Commonwealth and (I 
hope) shouldn't look too strange to Americans.

My personal preference would be for "round brackets instead of square 
brackets", but I guess that will be a battle I have no hope of winning *wink*

--
nosy: +steven.daprano

___
Python tracker 

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



[issue23749] asyncio missing wrap_socket (starttls)

2017-12-29 Thread Yury Selivanov

Change by Yury Selivanov :


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

___
Python tracker 

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



[issue23749] asyncio missing wrap_socket (starttls)

2017-12-29 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset f111b3dcb414093a4efb9d74b69925e535ddc470 by Yury Selivanov in 
branch 'master':
bpo-23749: Implement loop.start_tls() (#5039)
https://github.com/python/cpython/commit/f111b3dcb414093a4efb9d74b69925e535ddc470


--

___
Python tracker 

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



[issue32453] shutil.rmtree can have O(n^2) performance on large dirs

2017-12-29 Thread Niklas Hambüchen

New submission from Niklas Hambüchen :

See http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=24412edeaf556a 
for the explanation and equivalent fix in coreutils.

The gist ist that deleting entries in inode order can improve deletion 
performance dramatically.

To obtain inode numbers and sort by them, one needs to `getdents()` all the 
entries ahead of time, but rmtree() already gets all dirents ahead of the 
deletion. https://bugs.python.org/issue28564 recently improved shutil.rmtree() 
performance by using scandir(), but nevertheless the returned generator is 
list()ed, so we already have all necessary informtaion in memory and would just 
have to perform an O(n) integer sort.

I propose we check if the improvements made to `rm -r` in coreutils should be 
ported to shutil.rmtree().

--
components: Library (Lib)
messages: 309217
nosy: nh2
priority: normal
severity: normal
status: open
title: shutil.rmtree can have O(n^2) performance on large dirs
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue28564] shutil.rmtree is inefficient due to listdir() instead of scandir()

2017-12-29 Thread Niklas Hambüchen

Niklas Hambüchen  added the comment:

I've filed https://bugs.python.org/issue32453, which is about O(n^2) deletion 
behaviour for large directories.

--
nosy: +nh2

___
Python tracker 

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



[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread kandhan

kandhan  added the comment:

In the above comment,

Line 1 is the URL where it needs improvement

Line 2 and 3 are the actual content in the page that needs improvement

Line 4 is the proposed solution

--

___
Python tracker 

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



[issue32452] Brackets and Parentheses used in an ambiguous way

2017-12-29 Thread kandhan

New submission from kandhan :

https://docs.python.org/3/tutorial/classes.html

9.10. Generator Expressions

Some simple generators can be coded succinctly as expressions using a syntax 
similar to list comprehensions but with "parentheses instead of brackets"

Since parentheses comes under brackets, brackets could be changed to "Square 
Brackets"

--
assignee: docs@python
components: Documentation
messages: 309216
nosy: docs@python, kandhan
priority: normal
severity: normal
status: open
title: Brackets and Parentheses used in an ambiguous way
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue31975] Add a default filter for DeprecationWarning in __main__

2017-12-29 Thread Nick Coghlan

Change by Nick Coghlan :


--
keywords: +patch
pull_requests: +4929
stage: needs patch -> patch review

___
Python tracker 

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



Re: Goto (Posting On Python-List Prohibited)

2017-12-29 Thread Rustom Mody
On Saturday, December 30, 2017 at 8:35:27 AM UTC+5:30, Lawrence D’Oliveiro 
wrote:
> On Saturday, December 30, 2017 at 12:12:23 PM UTC+13, bartc wrote:
> > Looking at 14 million lines of Linux kernel sources, which are in C, 
> > over 100,000 of them use 'goto'. About one every 120 lines.
> 
> That kind of thing leads to spaghetti code.
> 
> Here  is an example I like to bring 
> up: writing a Python extension module in C. As you know, this requires a lot 
> of careful memory management to cope with errors and avoid either memory 
> leaks or double-frees. The coding convention I came up with looks like this:
> 
> ... initialize pointers to allocated storage to NULL ...
> do /*once*/
>   {
> ... processing ...
> allocate some storage;
> if (error)
> break;
> ... more processing ...
> allocate more storage;
> if (error)
> break;
> ... even more processing ...
>   }
> while (false);
> ... free allocated storage ...
> 
> Basically, it becomes possible to satisfy yourself, by inspection, that every 
> possible control path through the above code will pass once, and only once, 
> through the storage deallocation.
> 
> Things get slightly more complicated where allocation has to happen in a 
> loop. Actually, that’s where the interesting cases happen. My technique can 
> be adapted to cope elegantly with this, too--see the code.

Bizarre how religions proliferate…
I wonder how many people who quote Dijkstra have read "goto statement considered
harmful". 
And that short letter was negative, aka "Don’t use goto!”

The more positive answer to the question: “Ok so then how to program?”
was "Structured Programming"
I am ready to bet that an even tinier percentage has ever seen that tome

And if one really got the gist of structuredness:
mapping an automaton with
state = label
transition = goto
is really the most clean structured mapping

One can do almost as well with a switch and (case) labels

You can make a virtue of the fact that python has neither
I call it blind religious genuflecting

BTW there can be quite good reasons for not putting¹ goto into a language
especially interpreted ones is that gotos tend to make semantics non 
compositional:

ie Say S₁ S₂ are two statements in the source language composed together into
a larger source statement S₁ □ S₂ which translates into T₁ ▽ T₂
Egs of S₁ □ S₂ could be ifthenelse sequencing etc
T₁ ▽ T₂ could be assembly code for S₁ followed by code for S₂ (for a compiler)
Or action of S₁ followed by action of S₂ (for interpreter)

Now if S₁ , S₂ has gotos jumping into each other this 
"homomorphic tree transforming model" becomes messed up

However in the face of exceptions² that are quite close to gotos I dont
think this logic would apply

Finally I would like to quote my teacher of programming who made a statement
that altered my next 30 years of programming life:

“What the goto does to control structure, the assignment does to data structure”

¹ The most important decisions for a language designer are what to leave out —
Nicklaus Wirth

² The original objectives of the language (Ada) included reliability,
readability of programs, formality of language definition, and even
simplicity. Gradually these objectives have been sacrificed in favor
of power, supposedly achieved by a plethora of features and notational
conventions, many of them unnecessary and some of them, like exception
handling, even dangerous
C.A.R. Hoare Turing lecture: 
https://amturing.acm.org/award_winners/hoare_4622167.cfm
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32451] python -m venv activation issue when using cygwin on windows

2017-12-29 Thread Kevin

New submission from Kevin :

attempts from within cygwin:

1. The Posix way:

$ python -m venv taco
$ cd taco
$ source bin/activate
-bash: $'\r': command not found
-bash: Scripts/activate: line 4: syntax error near unexpected token `$'{\r''
'bash: Scripts/activate: line 4: `deactivate () {

2. The windows way:

$ python -m venv taco
$ cd taco
$ /full/path/to/venv/taco/scripts/activate.bat
$


3. the only solution from cygwin (still not 100% functional):

$ python -m venv taco
$ cd taco
$ cd Scripts
$ cmd
C:\taco\Scripts\> activate.bat

(taco) C:\taco\Scripts\>




HOWEVER. when running "pip freeze" in number 3 it returns the system packages 
despite the "include-system-site-packages = False" in pyvenv.cfg 
When #3 is run inside command prompt "pip freeze" returns nothing correctly.


Come on guys, please don't make me use command prompt or powershell.

--
messages: 309215
nosy: Kevin
priority: normal
severity: normal
status: open
title: python -m venv activation issue when using cygwin on windows
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue31975] Add a default filter for DeprecationWarning in __main__

2017-12-29 Thread Nick Coghlan

Change by Nick Coghlan :


--
assignee:  -> ncoghlan

___
Python tracker 

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



[issue10381] Add timezone support to datetime C API

2017-12-29 Thread Nick Coghlan

Nick Coghlan  added the comment:

Would it be possible to deprecate (or at least stop enhancing) the current 
datetime C API and add a new capsule based one instead?

We're trying to get extension module authors to *stop* relying on C level 
globals, since it causes problems with:

- memory usage analysis
- interpreter reinitialisation
- module reloading
- subinterpreters

Unfortunately, the current design of the datetime C API *requires* the use of C 
level global state.

--
nosy: +ncoghlan

___
Python tracker 

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



[issue30449] Improve __slots__ datamodel documentation

2017-12-29 Thread mpb

mpb  added the comment:

Can __slots__ be assigned a string?  If so, what are the consequences?  I find 
the current docs lack clarity.  For example from the docs for 3.7.0a3:

https://docs.python.org/3.7/reference/datamodel.html#slots

>  3.3.2.4. __slots__
>
>  [snip]
>
>  object.__slots__
>This class variable can be assigned a string,
>iterable, or sequence of strings [snip]

However, "3.3.2.4.1. Notes on using __slots__" does not discuss what happens 
when a string is assigned to __slots__.

The "notes" section does discuss assigning a "sequence of strings" to __slots__.

The "notes" section also says: "Any non-string iterable may be assigned to 
__slots__."

Based on quick experimentation, it appears that the string must be a single 
identifier.  I get a TypeError if I try to assign "foo bar" to __slots__.  The 
consequence of a string appears to be that only a single slot is created.  It 
would be nice if this was stated clearly in the docs.

The docs for 2.7 seem similar to version 3.7.0a3.  So maybe all versions of the 
docs could be improved regarding the specifics of what happens when you assign 
a string to __slots__.

--
nosy: +mpb

___
Python tracker 

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



[issue32450] non-descriptive variable name

2017-12-29 Thread Yuri Kanivetsky

New submission from Yuri Kanivetsky :

Not a big issue, really. At some point the code switches from "ndots" name:

https://github.com/python/cpython/blob/v3.7.0a3/Python/ast.c#L3385

to "level" name:

https://github.com/python/cpython/blob/v3.7.0a3/Python/Python-ast.c#L1671

Be it "ndots" everywhere, it could save me some time.

--
messages: 309212
nosy: Yuri Kanivetsky
priority: normal
severity: normal
status: open
title: non-descriptive variable name
type: enhancement
versions: Python 3.7

___
Python tracker 

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



Goto

2017-12-29 Thread Mikhail V
MRAB wrote:


> It's OK for code that's close to the metal, but in high-level code? No.
> Python has managed for >25 years without it, and I've yet to see a
> convincing use-case.

"convincing" is a broad term I think, especially for syntax proposals ;)

I think often one wish to use it just to avoid "if" blocks in
obvious situations - no need to setup flags and  indent/unindent code blocks.

Apart from that, I personally would prefer it in such typical code:

if a :
a()
goto "end"
if b :
b()
goto "end"
if c :
c()
goto "end"
"end"

I know I can do it with "elif", but "elif" is just not my cup of tea.
For this case goto provides symmetrical and explicit look, which I value a lot.


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


How to create a python extension module from a shared library?

2017-12-29 Thread Etienne Robillard

Hi all,

I would like to extend uWSGI by creating a CPython extension module for 
the libuwsgi.so shared library included in the distribution.


My goal is to use this automatically generated CPython module for 
extending uWSGI.


I have summarized my current approach here:

https://mail.python.org/pipermail/tutor/2017-December/112475.html

So far, I have tried to use CFFI and pycparser to generate the Python 
bindings, however CFFI and pycparser doesn't handle C directives like 
#include and #define.


I also attempted using clang to preprocess the "uwsgi.h" header found in 
the uWSGI distro with pycparser.parse_file() to generate a AST, however 
the generated AST object seems incorrect.


Is there any way to reflect a shared library into a CPython module?

I know that using "nm -D libuwsgi.so" I can get a list of available 
functions for this module. However, I have very little experience with 
ctypes and CFFI.


Do I need to modify CFFI to allow it to parse a C header with libclang?

I'm guessing CFFI/clang or ctypes should allow me to reflect the shared 
library, but I'm not sure about which method is the most appropriate.



What do you think?

Sincerely,

Etienne

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Nick Coghlan

Nick Coghlan  added the comment:

Another point in favour of the JSR approach is that it should make it
easier for tools like coverage.py to continue mapping opcode coverage to
line coverage.

I also like Serhiy's proposed strategy of separating the initial
introduction of the compiler based exception handling from the subsequent
simplification of the exception handling opcodes.

--

___
Python tracker 

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



Re: Goto (Posting On Python-List Prohibited)

2017-12-29 Thread MRAB

On 2017-12-29 23:12, bartc wrote:

On 29/12/2017 21:55, Lawrence D’Oliveiro wrote:

On Saturday, December 30, 2017 at 9:03:50 AM UTC+13, bartc wrote:

Why most newer, higher level languages don't, I don't know. Perhaps
because the people who design them want to make programming harder?


I don’t use gotos in C code. Why should it be “harder” in a higher-level 
language?



Good for you.

Looking at 14 million lines of Linux kernel sources, which are in C,
over 100,000 of them use 'goto'. About one every 120 lines.

My own low level sources use about one goto every 400 lines. It's hardly
a lot. If one is used, it's because it was handy to use it, until such
time as it can be replaced with proper logic. But such logic will
usually be more convoluted.

BTW, looking at 220,000 lines of CPython sources, in C (an old
distribution I had to hand), there are 2600 gotos, about one every 85
lines. And those are the ones are directly visible as gotos, and not
hidden behind macros.

I understand that on Linux, the CPython dispatcher makes use of label
pointers, using 'goto *opcode_targets[*next_instr++]' to do a faster
byte-code dispatch than using switch.

You I guess would have written it without that, and we'd all have to
suffer 10% slower speed (or whatever) for your principles. That's
assuming you could have got rid of the other 2600 gotos as well.

I too use goto in C code, principally to go to clean-up code after 
checking the result of a call.


In Python, on the other hand, I have automatic garbage collection, 
exceptions, etc.


It's OK for code that's close to the metal, but in high-level code? No.

Python has managed for >25 years without it, and I've yet to see a 
convincing use-case.

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


[issue32426] Tkinter.ttk Widget does not define wich option exists to set the cursor

2017-12-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

The tkinter docs currently omit much, but refer one to, among other places, 
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html, which has a page 
with images and names.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/cursors.html

--
nosy: +serhiy.storchaka, terry.reedy

___
Python tracker 

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



[issue32421] Keeping an exception in cache can segfault the interpreter

2017-12-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Yonathon, when replying by email, please delete the quoted message, except 
possibly for a specific line,  as it is redundant noise when posted on the web 
page.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue32420] LookupError : unknown encoding : [0x7FF092395AD0] ANOMALY

2017-12-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Since there is no evident CPython bug, I am closing this.  If CPython gets a 
bogus encoding for the std streams, it cannot output a normal traceback on 
sys.stderr.

>From StackOverflow: "TensorFlow is an open source library for machine learning 
>and machine intelligence. It is developed by Google and became open source in 
>November 2015."  It obviously has a python binding as there are numerous 
>questions tagged with both.

I searched SO for "[tensorflow] ANOMALY" and the 29 hits were about anomaly 
detection, as in detecting credit card fraud.  Suspecting that the error is not 
tensorflow specific, I searched "[anaconda] ANOMALY" and got the following, 
which reports a nearly identical error message, but with scikit-learn.
https://stackoverflow.com/questions/42732377/how-to-install-scikit-0-19-dev-version-in-anaconda
The advice was to reinstall after rechecking instructions.

--
nosy: +terry.reedy
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4928
stage:  -> patch review

___
Python tracker 

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



Re: Goto (Posting On Python-List Prohibited)

2017-12-29 Thread Skip Montanaro
Looking at 14 million lines of Linux kernel sources, which are in C, over
100,000 of them use 'goto'. About one every 120 lines.


Isn't C's goto statement restricted to the current function? I imagine
setjmp and longjmp calls might be more insidious.

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


[issue28134] socket.socket(fileno=fd) does not work as documented

2017-12-29 Thread Christian Heimes

Christian Heimes  added the comment:

Yuri,

* The patch is purely about Python's view of the socket. The actual behavior of 
the OS socket fd is not influenced by socket.socket()'s family, type and 
protocol. However the especially the family is critical for Python because a 
lot of socket code uses the family to decide how to format its address or the 
peer address.

* On some platforms and/or for some socket types, it is not possible to get the 
address family or type unless connect() or bind() have been called. On Linux it 
seems to work for both new sockets and bound/connected sockets. On Windows it 
never works for a fresh socket.

* It looks like Windows doesn't have protocol dedicated and always uses 0 as 
protocols.

* Using the wrong type is less of an issue. Using the wrong family is really 
really bad, see https://bugs.python.org/issue28134#msg285972.

* I don't care much about validating the values. I'm concerned to have correct 
values by default. Validation can be implemented in a separate PR. In that case 
we want to add socket.closefd(fd: int). On Windows os.close() can't be used for 
socket fds.

--

___
Python tracker 

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



[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread Yahya Abou Imran

Yahya Abou Imran  added the comment:

And I just saw that Raymon Hettinger made it inherting from Sized:

https://github.com/python/cpython/blame/master/Lib/_collections_abc.py#L694

So I we were to ahve his opinion on this...

--

___
Python tracker 

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



Re: Goto (Posting On Python-List Prohibited)

2017-12-29 Thread bartc

On 29/12/2017 21:55, Lawrence D’Oliveiro wrote:

On Saturday, December 30, 2017 at 9:03:50 AM UTC+13, bartc wrote:

Why most newer, higher level languages don't, I don't know. Perhaps
because the people who design them want to make programming harder?


I don’t use gotos in C code. Why should it be “harder” in a higher-level 
language?



Good for you.

Looking at 14 million lines of Linux kernel sources, which are in C, 
over 100,000 of them use 'goto'. About one every 120 lines.


My own low level sources use about one goto every 400 lines. It's hardly 
a lot. If one is used, it's because it was handy to use it, until such 
time as it can be replaced with proper logic. But such logic will 
usually be more convoluted.


BTW, looking at 220,000 lines of CPython sources, in C (an old 
distribution I had to hand), there are 2600 gotos, about one every 85 
lines. And those are the ones are directly visible as gotos, and not 
hidden behind macros.


I understand that on Linux, the CPython dispatcher makes use of label 
pointers, using 'goto *opcode_targets[*next_instr++]' to do a faster 
byte-code dispatch than using switch.


You I guess would have written it without that, and we'd all have to 
suffer 10% slower speed (or whatever) for your principles. That's 
assuming you could have got rid of the other 2600 gotos as well.


--
bartc

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


[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread Yahya Abou Imran

Yahya Abou Imran  added the comment:

https://mail.python.org/pipermail/python-ideas/2017-December/048489.html

Guido is waiting for objection on this...

I have absolutly no idea why this decision was made.

These tests 
(ttps://github.com/python/cpython/blame/master/Lib/test/test_collections.py#L794):

non_col_iterables = [_test_gen(), iter(b''), iter(bytearray()),
 (x for x in []), dict().values()]
for x in non_col_iterables:
self.assertNotIsInstance(x, Collection)

were written by Guido himself.

--

___
Python tracker 

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



Re: Goto

2017-12-29 Thread bartc

On 29/12/2017 21:56, Stefan Ram wrote:

Chris Angelico  writes:

On Sat, Dec 30, 2017 at 8:03 AM, D'Arcy Cain  wrote:

On 12/29/2017 02:25 PM, Chris Angelico wrote:

PHP also added goto to a later version.

Ahh, great choice of example. "It's okay - PHP does it."

I thought that that was a reason to not do it.

Often, yeah. Hence my comment that "hey, PHP has goto" is an excellent
choice of example.


   I already wrote this before, recently, in some newsgroup (here?):

   Knuth's algorithm's often use "goto"'s. When translating them into
   another language, it is helpful to be able to translate them as
   direct as possible. Having to change the algorithm in one's head
   to avoid "goto" while converting it to Python seems to be a
   source of errors.

   When a language has a "goto", one can then translate Knuth's
   algorithms more literally. One then can add tests. And /then/
   one can refactor step-by-step to an algorithm without "goto".




That sort of argument will never wash here:

"/I/ can write code without ever using 'goto'. So nobody else should 
ever need to use it either".


Forget about automatic code translators, automatic parser generators, 
automatic state machine translators, plus a host of other uses which 
goto could simplify.


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


[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

Well, it would be a backward compatibility problem at a minimum.

Obviously things were designed this way.  Have you found out why?  Is there a 
consensus on python-ideas that this should be changed?  If so, please link to 
the thread.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread Yahya Abou Imran

Yahya Abou Imran  added the comment:

Quoting my own post on python-ideas:

After I generate an UML diagram from collections.abc, I found very strange that 
MappingView inherit from Sized instead of Collection (new in python 3.6).

Yes, MappingView only define __len__ and not __iter__ and __contains__, but all 
of its subclasses define them (KeysView, ValuesView and ItemViews).

I tried to run the tests in test/test_collections.py after making this change 
and on only one fail :

Traceback (most recent call last):
  File "/usr/lib/python3.6/test/test_collections.py", line 789, in 
test_Collection
self.assertNotIsInstance(x, Collection)
AssertionError: dict_values([]) is an instance of 

Wich is absolutely wrong, since in reality a dict_values instance has the 
behaviour of a Collection:

>>> vals = {1:'a', 2: 'b'}.values()
>>> 'a' in vals
True
>>> 'c' in vals
False
>>> len(vals)
2
>>> for val in vals:
... print(val)
...
a
b

The only lack is that it doesn't define a __contains__ method:

>>> '__contains__' in vals
False

It uses __iter__ to find the presence of the value.

But, hey: we have register() for this cases! In fact, when MappingView inherit 
from Collection, dict_values is considered as a subclass of Collection since 
it's in the register of ValuesView, causing the above bug...
So, the test have to be changed, and dict_values must be placed in the samples 
that pass the test, and not in the ones that fail it.

Here is a patch file for this.

The only problem in this is that the MappingView won't be instatiable anymore 
because of the lack of __contains__ and __iter__.

But since - if my understanding is correct - it's just an "utilty" super class 
for three other views (so is Collection for Set, Mapping and Sequence), it's 
not a big deal IMHO.

--
keywords: +patch
Added file: https://bugs.python.org/file47354/mypatch.patch

___
Python tracker 

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



[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I consider PR 5006 as just a first step. I had two goals:

1) Fix all regressions in PR 2827. First at all the regression in the f_lineno 
setter.

2) Simplify the patch. This is critically important for getting the review. 
And it decreases the chance of regressions. All changes not directly related 
to the main goal (declared in the title of this issue) were removed. Other 
nice improvements can be made in separate PRs.

Maybe finally we will came to the duplication of the code. But this will 
require making other small steps which can have their own value.

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2017-12-29 Thread Ilya Kulakov

Ilya Kulakov  added the comment:

cancel will work in my case, but it's somewhat limited.

In other hand it's probably a job of a testing library to provide an utility 
function.

--

___
Python tracker 

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



[issue32449] MappingView must inherit from Collection instead of Sized

2017-12-29 Thread Yahya Abou Imran

New submission from Yahya Abou Imran :

Quoting my own post on python-ideas:

After I generate an UML diagram from collections.abc, I found very strange that 
MappingView inherit from Sized instead of Collection (new in python 3.6).

Yes, MappingView only define __len__ and not __iter__ and __contains__, but all 
of its subclasses define them (KeysView, ValuesView and ItemViews).

I tried to run the tests in test/test_collections.py after making this change 
and on only one fail :

Traceback (most recent call last):
  File "/usr/lib/python3.6/test/test_collections.py", line 789, in 
test_Collection
self.assertNotIsInstance(x, Collection)
AssertionError: dict_values([]) is an instance of 

Wich is absolutely wrong, since in reality a dict_values instance has the 
behaviour of a Collection:

>>> vals = {1:'a', 2: 'b'}.values()
>>> 'a' in vals
True
>>> 'c' in vals
False
>>> len(vals)
2
>>> for val in vals:
... print(val)
...
a
b

The only lack is that it doesn't define a __contains__ method:

>>> '__contains__' in vals
False

It uses __iter__ to find the presence of the value.

But, hey: we have register() for this cases! In fact, when MappingView inherit 
from Collection, dict_values is considered as a subclass of Collection since 
it's in the register of ValuesView, causing the above bug...
So, the test have to be changed, and dict_values must be placed in the samples 
that pass the test, and not in the ones that fail it.

--
messages: 309200
nosy: yahya-abou-im...@protonmail.com
priority: normal
severity: normal
status: open
title: MappingView must inherit from Collection instead of Sized
type: enhancement
versions: Python 3.6, Python 3.7

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2017-12-29 Thread Yury Selivanov

Yury Selivanov  added the comment:

> My use case was outside control of otherwise unconditionally blocking task 
> (for tests only). What replacement (if any) would you suggest?


Use Task.cancel() or use a Queue to communicate with the task.  Your test code 
was working, but ultimately was creating an unexpected (and not officially 
documented/supported) situation for the task.

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2017-12-29 Thread Ilya Kulakov

Ilya Kulakov  added the comment:

Andrew, Yury

I test my lib against dev versions of Python and recently got an error in one 
of the tests due to the deprecation.

I do not argue the reason behind removing this methods, but Task.set_exception 
was working for me in tests: 
https://github.com/Kentzo/async_app/blob/250ee7a05d2af8035806ce1d86f57d0f00283db0/tests/test_utils.py#L73-L91

My use case was outside control of otherwise unconditionally blocking task (for 
tests only). What replacement (if any) would you suggest?

--
nosy: +Ilya.Kulakov

___
Python tracker 

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



Re: Goto

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 8:03 AM, D'Arcy Cain  wrote:
> On 12/29/2017 02:25 PM, Chris Angelico wrote:
>>> PHP also added goto to a later version.
>>
>> Ahh, great choice of example. "It's okay - PHP does it."
>
> I thought that that was a reason to not do it.

Often, yeah. Hence my comment that "hey, PHP has goto" is an excellent
choice of example.

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


[issue32441] os.dup2 should return the new fd

2017-12-29 Thread Benjamin Peterson

Benjamin Peterson  added the comment:


New changeset bbdb17d19bb1d5443ca4417254e014ad64c04540 by Benjamin Peterson in 
branch 'master':
return the new file descriptor from os.dup2 (closes bpo-32441) (#5041)
https://github.com/python/cpython/commit/bbdb17d19bb1d5443ca4417254e014ad64c04540


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

___
Python tracker 

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



Re: Goto

2017-12-29 Thread D'Arcy Cain
On 12/29/2017 02:25 PM, Chris Angelico wrote:
>> PHP also added goto to a later version.
> 
> Ahh, great choice of example. "It's okay - PHP does it."

I thought that that was a reason to not do it.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32443] Add Linux's signalfd() to the signal module

2017-12-29 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

My reading of the Linux signalfd man page may be optimistic. :)

Regardless, it'd be nice to have it available in the stdlib so it could be used 
if deemed useful.  I expect this to only ever be added by someone making use of 
it in another stdlib module.

As for what multiprocessing.forkserver does, the old manual signal handler and 
pipe trick is a reasonably well known one.  But a forkserver is not safe to be 
started when threads exist.  (unlike subprocess)

Signals are process global state, no thread compatible library can rightfully 
take ownership of a one.

--
priority: normal -> low

___
Python tracker 

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



[issue32447] IDLE shell won't open on Mac OS 10.13.1

2017-12-29 Thread Ned Deily

Ned Deily  added the comment:

Those messages at the top of your terminal sessions are pretty suspicious, e.g. 
"Permission denied" and "No such file or directory".  They suggest a home 
directory ownership or permissions issue which you should investigate.  But 
definitely try running IDLE from the terminal window as Terry suggests.  If 
nothing else, you may see more informative error messages.

--

___
Python tracker 

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



Re: Goto

2017-12-29 Thread bartc

On 29/12/2017 20:25, Chris Angelico wrote:

On Sat, Dec 30, 2017 at 7:03 AM, bartc  wrote:

On 29/12/2017 18:55, MarkA wrote:


On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:


How to use goto in python?

---
This email has been checked for viruses by AVG.
http://www.avg.com



Rather than ask how to use an unavailable statement (GOTO), why not
investigate why no modern languages use it?



Golang uses goto.

Lua didn't have goto but then added it.

PHP also added goto to a later version.


Ahh, great choice of example. "It's okay - PHP does it."


I don't know PHP, but I guess it has all the usual features that people 
can use to eliminate goto (ie. the ability to add extra, more convoluted 
code).


So presumably adding it had a net benefit.

Notice I said Lua and Golang also have it.

Adding it to a language doesn't mean people are obliged to use it.

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


[issue32447] IDLE shell won't open on Mac OS 10.13.1

2017-12-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

IDLE uses Python's tcl/tk interface module, called 'tkinter'.  Tcl is a 
separate language and tk is its graphical user interface.  This is most likely 
the problem.  Did you follow the advice at
https://www.python.org/download/mac/tcltk/
to install tcl/tk 8.5.18?  Make sure you read the whole page.

To test better, run 'import tkinter' at Python's interactive '>>>' prompt.  Any 
error message?  If that works, run 'python3.6 -m idlelib' and/or 'python -m 
idlelib.idle' at the terminal '...$' prompt.  Does that display an error 
message?

--
components: +Installation, macOS
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue18035] telnetlib incorrectly assumes that select.error has an errno attribute

2017-12-29 Thread Gregory P. Smith

Change by Gregory P. Smith :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue18035] telnetlib incorrectly assumes that select.error has an errno attribute

2017-12-29 Thread Gregory P. Smith

Gregory P. Smith  added the comment:


New changeset 3ceaed0dce81fd881bbaf2dbdbe827d9681887da by Gregory P. Smith 
(Segev Finer) in branch '2.7':
bpo-18035: telnetlib: select.error doesn't have an errno attribute (#5044)
https://github.com/python/cpython/commit/3ceaed0dce81fd881bbaf2dbdbe827d9681887da


--

___
Python tracker 

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



Re: Goto

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 7:03 AM, bartc  wrote:
> On 29/12/2017 18:55, MarkA wrote:
>>
>> On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:
>>
>>> How to use goto in python?
>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> http://www.avg.com
>>
>>
>> Rather than ask how to use an unavailable statement (GOTO), why not
>> investigate why no modern languages use it?
>
>
> Golang uses goto.
>
> Lua didn't have goto but then added it.
>
> PHP also added goto to a later version.

Ahh, great choice of example. "It's okay - PHP does it."

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


Re: Goto

2017-12-29 Thread bartc

On 29/12/2017 18:55, MarkA wrote:

On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:


How to use goto in python?

---
This email has been checked for viruses by AVG.
http://www.avg.com


Rather than ask how to use an unavailable statement (GOTO), why not
investigate why no modern languages use it?


Golang uses goto.

Lua didn't have goto but then added it.

PHP also added goto to a later version.

That's the extent of my one minutes' research; I guess a few other 
newish languages might use it (plus any I create myself, and pile of 
older languages).


Why most newer, higher level languages don't, I don't know. Perhaps 
because the people who design them want to make programming harder? Or 
they are adept at doing without it, and expect everyone else to be 
equally so?


Nothing wrong with goto when you have a throwaway program to finish and 
an approaching deadline.


Overuse of goto in real applications would be a problem, but that's the 
same with any feature. In Python, you can define F as function, but then 
reassign any other arbitrary value to F, at any point in a program, at 
any time, and as many times as you like. That makes goto seem almost 
benign! (Except that Python would probably let you assign to labels...)


--
bartc

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


[issue32448] subscriptable

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

At the point at which that error is raised, Python doesn't know the name of the 
attribute, nor is attribute access the only place where that particular error 
report is triggered (it's in a generic subscript-this-object call).  So I doubt 
doing this would be practical.

As for Foo.organizer.blah[0], it has to be blah that is None, since 
'.organizer' is an attribute access and not a subscript operation.  The more 
difficult case is something like getattr(someobject, somevar)[0], where you 
can't tell what somevar contains just from the traceback.  Which is why some 
value-added systems also dump the locals from the frame in the traceback.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue32221] Converting ipv6 address to string representation using getnameinfo() is wrong.

2017-12-29 Thread Yury Selivanov

Yury Selivanov  added the comment:

> So, PR is ready. Please review.

I understand, however I still don't have time for it at the moment. If another 
core dev wants to take initiative, please by all means do.

I can/will take another look at this after January 15.

--

___
Python tracker 

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



[issue32221] Converting ipv6 address to string representation using getnameinfo() is wrong.

2017-12-29 Thread Марк Коренберг

Марк Коренберг  added the comment:

So, PR is ready. Please review.

--

___
Python tracker 

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



Re: PyWin32 installer question

2017-12-29 Thread Terry Reedy

On 12/29/2017 11:38 AM, Paul Moore wrote:

On 29 December 2017 at 16:04, Skip Montanaro  wrote:

Thanks. I'll shoot Thomas Heller an email...



Actually, make that Christopher Toth. Seems he's the current maintainer.


If you get no joy there, then in a week or two, when I next get access
to a system with a Python 2.x build environment on it, I can see if I
can do a 64-bit build for you. Ping me if that would be a help.


I have not followed this thread, but there may be no need to.
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Christopher Gohlke, at UC Irvine, provides Windows cpxx wheels for about 
300 packages, for 2.7, 3.4, 3.5, 3.6, 3.7, in win32 and win_amd64 
versions (as applicable).   PyWin32-221 is included, with all combinations.


--
Terry Jan Reedy

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


[issue32428] dataclasses: make it an error to have initialized non-fields in a dataclass

2017-12-29 Thread Guido van Rossum

Guido van Rossum  added the comment:

I liked the original design better, where things without annotations would
just be ignored. What changed?

On Dec 27, 2017 5:19 PM, "Ivan Levkivskyi"  wrote:

>
> Ivan Levkivskyi  added the comment:
>
> > I'm not sure I understand the distinction.
>
> Initially I thought about only flagging code like this:
>
> @dataclass
> class C:
> x = field()
>
> But not this:
>
> @dataclass
> class C:
> x = 42
>
> Now I think we should probably flag both as errors.
>
> > How do we only pick out `y` and probably `prop`, and ignore the rest,
> without being overly fragile to new things being added? I guess ignoring
> dunders and things in `__annotations__`. Is that close enough?
>
> We had a similar problem while developing Protocol class (PEP 544).
> Currently we just a have a whitelist of names that are skipped:
>
> '__abstractmethods__', '__annotations__', '__weakref__', '__dict__',
> '__slots__', '__doc__', '__module__'
>
> (plus some internal typing API names)
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue32427] Rename and expose dataclasses._MISSING

2017-12-29 Thread Eric V. Smith

Change by Eric V. Smith :


--
resolution:  -> fixed
stage: patch review -> resolved
type:  -> behavior

___
Python tracker 

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



[issue32427] Rename and expose dataclasses._MISSING

2017-12-29 Thread Eric V. Smith

Eric V. Smith  added the comment:


New changeset 03220fdb26c0b6a50ce5ed1fdfbf232094b66db6 by Eric V. Smith in 
branch 'master':
bpo-32427: Expose dataclasses.MISSING object. (#5045)
https://github.com/python/cpython/commit/03220fdb26c0b6a50ce5ed1fdfbf232094b66db6


--

___
Python tracker 

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



[issue32448] subscriptable

2017-12-29 Thread Alexander Mohr

New submission from Alexander Mohr :

Currently subscriting a attribute that's None reports the following:
>>> class Foo: pass
>>> Foo.organizer = None
>>> Foo.organizer['start']
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not subscriptable

What would be nice is if it were to report the name of the attribute that is 
not subscriptable as it would greatly help in the logs, something like:

Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object of attribute 'organizer' is not subscriptable

just a thought.  Otherwise one would need to sprinkle their code with asserts, 
especially if it's a compound statement like:
Foo.organizer.blah[0], you wouldn't know which attribute wasn't None

--
components: Interpreter Core
messages: 309187
nosy: thehesiod
priority: normal
severity: normal
status: open
title: subscriptable
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue12706] timeout sentinel in ftplib and poplib documentation

2017-12-29 Thread Marcel Widjaja

Marcel Widjaja  added the comment:

Greg, I wonder if you are planning to submit a PR for your patch? If not, I'm 
plan to take your patch, make some minor adjustment and submit a PR.

--
nosy: +mawidjaj

___
Python tracker 

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



Re: Goto

2017-12-29 Thread MarkA
On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:

> How to use goto in python?
> 
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com

Rather than ask how to use an unavailable statement (GOTO), why not 
investigate why no modern languages use it?

-- 
MarkA

You can safely assume that you have created God in your own image when it 
turns out that God hates all the same people you do.  -- Anne Lamott
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 4:13 AM, bartc  wrote:
> If you want to translate code from one language to another, and the source
> language uses gotos, or uses control structures not available in the target
> language, then gotos would be very useful in the latter.
>

As has already been said in this thread, a competent FORTRAN
programmer can write FORTRAN code in any language. But if you want to
actually write Python code, instead of writing FORTRAN code that gets
run through a Python interpreter, you have to grok the Python way of
doing things. You can't do that by mechanically transforming source
code into the syntax of a different language.

People who try to tell you that all programming languages are
identical, just with different syntax, are doing you a disservice.
Lisp is not Python is not REXX is not C is not DeScribe Macro
Language. (Especially the latter. Do NOT try to write C code in DML.
It'll look ugly. Trust me.)

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


[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Neil Schemenauer

Neil Schemenauer  added the comment:

I apologize if my extra PR is causing confusion.  My original intention was to 
merely forward port Antoine changes so they could compile with the 'master' 
version of Python.  Over time I have made some fixes to it.  I have kept it 
open because I'm not sure which approach is better (JSR or duplication).

I did a quick test on the .pyc code size increase.  It is actually tiny for the 
Python code in Lib/.

PR 5006: 21259894 bytes
PR 4682: 21263081 bytes (+0.015%)

Running Serhiy's microbenchmarks:

for i in a:
try: pass
finally: pass

PR 4682: Mean +- std dev: 11.0 us +- 0.1 us
PR 5006: Mean +- std dev: 10.9 us +- 0.6 us


for i in a:
try: continue
finally: pass

PR 4682: Mean +- std dev: 9.46 us +- 0.85 us
PR 5006: Mean +- std dev: 14.3 us +- 0.3 us


for i in a:
while True:
try: break
finally: pass

PR 4682: Mean +- std dev: 9.20 us +- 0.09 us
PR 5006: Mean +- std dev: 14.3 us +- 0.6 us

--

___
Python tracker 

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



[issue32424] Synchronize copy methods between Python and C implementations of xml.etree.ElementTree.Element

2017-12-29 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

There is an existing test for copying. No new tests are needed. Just add a case 
for the copy() method in test_copy.

Special __deepcopy__() method for Python implementation is not needed. 
copy.deepcopy() already works well.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue31907] Clarify error message when attempting to call function via str.format()

2017-12-29 Thread mickey695

mickey695  added the comment:

Well, it has been more than the 2 weeks I promised however now I finally have 
time to look into this.

I did some fuzzing to build a list quickly and the following ASCII characters 
can not be used as part of the argument name:
exclamation mark(!)
period(.)
colon(:)
opening square bracket([)
opening/closing curly brackets({})

also, the argument name may not start with digits from zero to nine(0-9)

Basically what needs to be changed is arg_name under the section "Format String 
Syntax" in \Doc\library\string.rst

Problem is, I really don't understand the syntax of the Python/sphinx formal 
language.

The following expression is what I came up with:
arg_name ::= [^`decinteger`] [ | `integer` ]+

If anyone from the documentation team could look into it I would be grateful.

Moreover, I think attribute_name should probably be changed as it does not have 
to be a valid identifier. In fact, it can be any text. Eric V. Smiths' example 
can be used with any text as the attribute name. A comment should be added to 
the aforementioned section explaining that normally only valid identifiers are 
accepted, however by implementing your own __getattr__ this can be changed.

--
components: +Documentation

___
Python tracker 

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



Re: Python goto

2017-12-29 Thread Grant Edwards
On 2017-12-28, Skip Montanaro  wrote:

> Though it appears some wag has used function decorators to implement
> goto statements:
>
> https://pypi.python.org/pypi/goto-statement/1.1
>
> Rather clever, it seems.

That's brilliant!

Not that I'd look kindly on anybody who used it on project I ended up
working on...

-- 
Grant Edwards   grant.b.edwardsYow! My Aunt MAUREEN was a
  at   military advisor to IKE &
  gmail.comTINA TURNER!!

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


[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Whether the small speed difference is worth worrying about is a different 
> matter.

I don't think so.  Though one could run the benchmarks suite to get an idea of 
the impact on real-world code.

--

___
Python tracker 

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



Re: Goto

2017-12-29 Thread bartc

On 29/12/2017 09:52, alister wrote:

On Thu, 28 Dec 2017 18:54:31 -0800, breamoreboy wrote:


On Thursday, December 28, 2017 at 7:40:14 PM UTC, alister wrote:

On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:


How to use goto in python?

---
This email has been checked for viruses by AVG.
http://www.avg.com


Dont!
actually you cant - there isn't one*

*at least not in the core language no doubt some sick person will have
manager to hack together some sort of dodgy code to simulate it if you
look hard enough)



This http://entrian.com/goto/ has been around for almost 14 years.


ok ill admit i didn't look at all (because goto is a silly idea &
unnecessary)


If you want to translate code from one language to another, and the 
source language uses gotos, or uses control structures not available in 
the target language, then gotos would be very useful in the latter.


(gotos are frowned upon because they make program flow harder to see 
within a normal structured program. However examples of 'advanced' 
Python I've seen are such that I would rather contend with a few gotos.)


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


[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Mark Shannon

Mark Shannon  added the comment:

When I said "significant", I meant from a statistically, not as a judgement 
meaning "useful" or "worthwhile". The code duplication approach is 
significantly faster in the tests. Whether the small speed difference is worth 
worrying about is a different matter.

Also, the comparisons were with each other, not the current interpreter. Both 
approaches are better than the current implementation.

One point I didn't cover is jumping to a new line in the debugger.
Implementing that reliably for finally blocks with code duplication is tricky 
and would mean adding a number of marker bytecodes.
Which is a big point in favour of the JSR style.

If we are going to use the JSR approach, we should do it properly. 
PR 5006 still has elements of the current design such as the overly complex 
END_FINALLY, WITH_CLEANUP_START and WITH_CLEANUP_FINISH bytecodes. None of 
those should be necessary.

--

___
Python tracker 

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



[issue32447] IDLE shell won't open on Mac OS 10.13.1

2017-12-29 Thread Steve Margetts

New submission from Steve Margetts :

I am trying to install Python on a Max running OS 10.13.1 (so my son can use a 
'Coding for Beginners' book). Both 2.7 and 3.6 have the same problem: Clicking 
on IDLE leads to the icon bouncing a couple of times in the dock, but not 
opening a shell. I have tried re-installing and restarting post install. Typing 
python or python3.6 into the terminal seems to launch Python successfully 
(details below). I am as new to coding as my son, please phrase any advice 
accordingly!

Thank you.

Last login: Fri Dec 29 16:26:57 on ttys000
mkdir: /Users/Steve Margetts/.bash_sessions: Permission denied
touch: /Users/Steve 
Margetts/.bash_sessions/79B2448C-E769-409D-A67D-7A96F8C3C348.historynew: No 
such file or directory
iMac:~ Steve Margetts$ python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help
Type help() for interactive help, or help(object) for help about object.
>>>

Last login: Fri Dec 29 16:30:16 on ttys000
mkdir: /Users/Steve Margetts/.bash_sessions: Permission denied
touch: /Users/Steve 
Margetts/.bash_sessions/5A516AB8-0481-4D55-A2BD-1B1017E52147.historynew: No 
such file or directory
iMac:~ Steve Margetts$ python3.6
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

--
assignee: terry.reedy
components: IDLE
messages: 309180
nosy: sm1979, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE shell won't open on Mac OS 10.13.1
type: behavior
versions: Python 3.6

___
Python tracker 

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



Re: PyWin32 installer question

2017-12-29 Thread Paul Moore
On 29 December 2017 at 16:04, Skip Montanaro  wrote:
>> Thanks. I'll shoot Thomas Heller an email...
>
>
> Actually, make that Christopher Toth. Seems he's the current maintainer.

If you get no joy there, then in a week or two, when I next get access
to a system with a Python 2.x build environment on it, I can see if I
can do a 64-bit build for you. Ping me if that would be a help.

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


[issue32424] Synchronize copy methods between Python and C implementations of xml.etree.ElementTree.Element

2017-12-29 Thread Gordon P. Hemsley

Gordon P. Hemsley  added the comment:

Given the discussion, I've gone ahead and created a new PR that synchronizes 
the three copy methods between implementations and deprecates Element.copy().

--

___
Python tracker 

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



[issue32424] Synchronize copy methods between Python and C implementations of xml.etree.ElementTree.Element

2017-12-29 Thread Gordon P. Hemsley

Change by Gordon P. Hemsley :


--
title: Rename copy() to __copy__() in xml.etree.ElementTree.Element Python 
implementation -> Synchronize copy methods between Python and C implementations 
of xml.etree.ElementTree.Element

___
Python tracker 

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



[issue32424] Rename copy() to __copy__() in xml.etree.ElementTree.Element Python implementation

2017-12-29 Thread Gordon P. Hemsley

Change by Gordon P. Hemsley :


--
pull_requests: +4927

___
Python tracker 

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



Re: PyWin32 installer question

2017-12-29 Thread Skip Montanaro
> Thanks. I'll shoot Thomas Heller an email...


Actually, make that Christopher Toth. Seems he's the current maintainer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyWin32 installer question

2017-12-29 Thread Skip Montanaro
> That's not an architecture-independent file. The Wheel spec gives all
> the details, but "cp27" (as opposed to "py27") means it's CPython only
> (which usually means it's got a C extension) and "win32" is 32-bit
> only ("win_amd64" is the tag for 64-bit Windows). So the problem is
> that the py2exe_py2 maintainer doesn't supply a 64-bit build.

Thanks. I'll shoot Thomas Heller an email...

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


[issue32446] ResourceLoader.get_data() should accept a PathLike

2017-12-29 Thread Barry A. Warsaw

New submission from Barry A. Warsaw :

Currently get_data() only accepts a string.  It should also accept a os.PathLike

--
messages: 309178
nosy: barry, brett.cannon
priority: normal
severity: normal
status: open
title: ResourceLoader.get_data() should accept a PathLike
versions: Python 3.7

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I'm ok with turning the warning into an error. Does anyone object here?

--

___
Python tracker 

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



[issue32145] Wrong ExitStack Callback recipe

2017-12-29 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Dec 29, 2017, at 08:40, Nick Coghlan  wrote:
> 
> I'm not clear on what you mean about allowing arbitrary names for the 
> instance creation function -

What I meant was that I don’t see `def _make_instance()` defined in your 
example, so I didn’t know if that was part of the contract between the base and 
derived classes, or an “arbitrary method” that subclasses can come up with.  
From the example, it seems like the latter, but I could be misunderstanding 
your proposal.

> at that point we're back to subclasses not being able to use the default 
> `pop_all()` implementation at all, and needing to duplicate the state 
> transfer logic in the subclass (which we don't provide a public API to do, 
> since the `_exit_callbacks` queue is deliberately private).
> 
> However, I'm thinking we could potentially change `pop_all` *itself* to 
> accept a target object:
> 
>def pop_all(self, *, target=None):
>"""Preserve the context stack by transferring it to a new instance
> 
>If a *target* stack is given, it must be either an `ExitStack`
>instance, or else provide a callback registration method akin to 
> `ExitStack.callback`.
>"""
>if target is None:
>target = type(self)()
>exit_callbacks = self._exit_callbacks
>self._exit_callbacks = deque()
>if isinstance(target, ExitStack):
>target._exit_callbacks = exit_callbacks
>else:
>for cb in exit_callbacks:
>target.callback(cb)
>return target
> 
> The recipe fix would then be to make `Callback.cancel()` look like:
> 
>def cancel(self):
># We deliberately *don't* clean up the cancelled callback
>self.pop_all(target=ExitStack())

That’s actually not bad.  I think I like that better than the (IMHO, misnamed) 
_clone() API.  I’d quibble just a bit about the docstring, since the required 
API for target is exactly that it have a .callback() method that accepts a 
single exit callback argument.

--

___
Python tracker 

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



[issue32427] Rename and expose dataclasses._MISSING

2017-12-29 Thread Eric V. Smith

Change by Eric V. Smith :


--
keywords: +patch
pull_requests: +4926
stage:  -> patch review

___
Python tracker 

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



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

Correct, a new feature should always get a what's new entry.  You could submit 
a PR for it :)

--

___
Python tracker 

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



[issue32444] python -m venv symlink dependency on how python binary is called is not documented

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

Actually, I'm going to reopen this as a doc issue because this behavior is not 
discussed by the docs that I can see, and it is important to know about when 
creating a venv.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
resolution: not a bug -> 
stage: resolved -> needs patch
status: closed -> open
title: python -m venv has incongruous behavor creating binaries -> python -m 
venv symlink dependency on how python binary is called is not documented

___
Python tracker 

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



[issue32444] python -m venv has incongruous behavor creating binaries

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

This is a feature that actually supports your use case, as well as the use 
cases of those who *don't* want to strap the python version: you get what you 
ask for.  If you call venv with 'python3', you get a venv that will use your 
new python if you upgrade your python, but if you call it with python3.x, you 
will get a venv that will *not* upgrade, which is exactly what you want for 
your use case.

--
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
versions: +Python 3.7 -Python 3.5

___
Python tracker 

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



[issue32145] Wrong ExitStack Callback recipe

2017-12-29 Thread Nick Coghlan

Nick Coghlan  added the comment:

I'm not clear on what you mean about allowing arbitrary names for the instance 
creation function - at that point we're back to subclasses not being able to 
use the default `pop_all()` implementation at all, and needing to duplicate the 
state transfer logic in the subclass (which we don't provide a public API to 
do, since the `_exit_callbacks` queue is deliberately private).

However, I'm thinking we could potentially change `pop_all` *itself* to accept 
a target object:

def pop_all(self, *, target=None):
"""Preserve the context stack by transferring it to a new instance

If a *target* stack is given, it must be either an `ExitStack`
instance, or else provide a callback registration method akin to 
`ExitStack.callback`.
"""
if target is None:
target = type(self)()
exit_callbacks = self._exit_callbacks
self._exit_callbacks = deque()
if isinstance(target, ExitStack):
target._exit_callbacks = exit_callbacks
else:
for cb in exit_callbacks:
target.callback(cb)
return target

The recipe fix would then be to make `Callback.cancel()` look like:

def cancel(self):
# We deliberately *don't* clean up the cancelled callback
self.pop_all(target=ExitStack())

(Tangent: https://bugs.python.org/issue32445 suggests adding a small 
optimisation to `ExitStack.callback` to skip adding the wrapper when `args` and 
`kwds` are both empty)

--

___
Python tracker 

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



[issue32445] Skip creating redundant wrapper functions in ExitStack.callback

2017-12-29 Thread Nick Coghlan

New submission from Nick Coghlan :

While discussing https://bugs.python.org/issue32145, I noticed that 
ExitStack.callback *always* adds a wrapper function, even when the `args` and 
`kwds` parameters are both empty.

For plain callbacks that aren't receiving any extra arguments, it would be 
better to skip adding the redundant wrapper function.

--
messages: 309171
nosy: barry, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Skip creating redundant wrapper functions in ExitStack.callback
type: performance
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue18035] telnetlib incorrectly assumes that select.error has an errno attribute

2017-12-29 Thread Segev Finer

Change by Segev Finer :


--
keywords: +patch
pull_requests: +4925
stage:  -> patch review

___
Python tracker 

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



[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le 29/12/2017 à 12:48, Mark Shannon a écrit :
> 
> Why all these competing pull requests? It does feel like my original patch 
> has been hijacked.

The original patch had a number of issues which needed to be fixed (in
addition to forward-port it to the latest git master), such as not
fixing some cases of stack consumption calculation.

> Also, before any more PRs, we need to decide whether to use subroutines or 
> code duplication for finally blocks.
> 
> Here is my attempt at an objective comparison of the two approaches.
> 
>JSR style   Code duplication
> Speed  Slower  Faster
> InterpreterMore complexSimpler
> Bytecode generationSimpler More complex
> Bytecode size  ~ +0.1% ~ +0.4%

Actually, when looking at your original patch
(https://bugs.python.org/review/17611/) vs. Serhiy's
https://github.com/python/cpython/pull/5006/, it looks like interpreter
complexity is the same.  Speed also seems to not be significantly
different.  So I would rephrase it as (compared to legacy bytecode
generation):

  Subroutine  Code duplication
Speed SameInsignificantly faster
Interpreter   Simpler Simpler
Bytecode generation   Slightly more complex   Slightly more complex
Bytecode size ~ +0.1% ~ +0.4%

That said, if you want to submit an updated version of the code
duplication approach (with the same amount of added tests and
debugging), we could compare on more equal grounds.

--

___
Python tracker 

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



[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Mark Shannon

Mark Shannon  added the comment:

Why all these competing pull requests? It does feel like my original patch has 
been hijacked.

Also, before any more PRs, we need to decide whether to use subroutines or code 
duplication for finally blocks.

Here is my attempt at an objective comparison of the two approaches.

   JSR style   Code duplication
Speed  Slower  Faster
InterpreterMore complexSimpler
Bytecode generationSimpler More complex
Bytecode size  ~ +0.1% ~ +0.4%

The increase in bytecode size is insignificant in terms of overall memory use, 
but the performance increase is significant (although small).

Unless I have missed anything important, this says to me that the code 
duplication approach is better.

--

___
Python tracker 

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



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2017-12-29 Thread Mathieu Dupuy

Mathieu Dupuy  added the comment:

maybe it's worth adding an entry in python 3.7 "what's new" ? I think it was a 
very long awaited issue.
The opposite of isoformat() is a very frequent question from python newcomers

--

___
Python tracker 

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



Re: GUI user input to function

2017-12-29 Thread Nico Vogeli
Am Donnerstag, 28. Dezember 2017 14:00:14 UTC+1 schrieb Chris Angelico:
> On Thu, Dec 28, 2017 at 11:06 PM, Nico Vogeli  wrote:
> > Am Donnerstag, 28. Dezember 2017 12:59:24 UTC+1 schrieb Chris Angelico:
> >> On Thu, Dec 28, 2017 at 8:38 PM, Nico Vogeli  wrote:
> >> > Withs test, this return a correct value for the two x functions:
> >> >
> >> > from sympy import symbols
> >> >
> >> > x = symbols('x')
> >> > f1 = eval(input('function 1 '))
> >> > f2 = eval(input('function 2 '))
> >> >
> >>
> >> What are you typing as input? It's hard to grok your code without knowing 
> >> that.
> >>
> >> ChrisA
> >
> > I'm sorry! User input would look like this for example: x**2 + 3*x or x**3
> >
> 
> Cool. That's an expression, but it isn't a function. To make that into
> a function, you need to prefix it with the lambda keyword.
> 
> So you should be able to construct functions like this:
> 
> f1 = eval("lambda x: " + input("function 1: "))
> 
> Then, when you type "x**3", Python evaluates "lambda x: x**3", which
> is a function.
> 
> ChrisA

Thank you very much! It now works perfectly fine now!!

Thank you!

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


Re: Goto

2017-12-29 Thread mm0fmf

On 28/12/2017 22:38, Tim Chase wrote:

On 2017-12-29 08:42, Ben Finney wrote:

Duram  writes:


How to use goto in python?


Step 0: what is goto in Python?

Step 1: that's not something that exists in Python. So why are you
asking how to use something that doesn't exist?


so quick to shoot down a poor soul.

http://entrian.com/goto/

Gives you both GOTO and COMEFROM ;-)

-tkc




This! An awful lot of my early C++, C# and Python programs resembled 
FORTRAN66, it took effort to learn the Zen of each language. Now I can 
continue to write FORTRAN66 style programs in Python and unlearn all the 
good stuff.


Thank you. And remember, a good programmer can write FORTRAN66 programs 
in any language!

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


Re: Goto

2017-12-29 Thread alister via Python-list
On Thu, 28 Dec 2017 18:54:31 -0800, breamoreboy wrote:

> On Thursday, December 28, 2017 at 7:40:14 PM UTC, alister wrote:
>> On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:
>> 
>> > How to use goto in python?
>> > 
>> > ---
>> > This email has been checked for viruses by AVG.
>> > http://www.avg.com
>> 
>> Dont!
>> actually you cant - there isn't one*
>> 
>> *at least not in the core language no doubt some sick person will have
>> manager to hack together some sort of dodgy code to simulate it if you
>> look hard enough)
>> 
>> 
> This http://entrian.com/goto/ has been around for almost 14 years.

ok ill admit i didn't look at all (because goto is a silly idea & 
unnecessary)



-- 
The sunlights differ, but there is only one darkness.
-- Ursula K. LeGuin, "The Dispossessed"
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32443] Add Linux's signalfd() to the signal module

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Also see how the forkserver module does without it:
https://github.com/python/cpython/blob/master/Lib/multiprocessing/forkserver.py#L146

Reading Jean-Paul's messages in https://bugs.python.org/issue8407, I'm unclear 
what is required to take advantage of signalfd().  Jean-Paul says """In order 
to effectively use signalfd(), the signals in question must be blocked, 
though""".  The signalfd man page says:

"""Normally, the set of signals to  be  received  via the  file descriptor 
should be blocked using sigprocmask(2), to prevent the signals being handled 
according to their default dispositions""".

And it's not clear what is meant by that (what happens if you don't block those 
signals?). Also:

"""As a consequence of the read(2), the signals are consumed, so that they are 
no longer pending for the process (i.e., will not be caught by signal handlers, 
and cannot be accepted using sigwaitinfo(2))."""

But how about the converse?  i.e. can a signal be consumed first by a signal 
handler and the fd not written to at all?

Also see fork() semantics which might (or not) require special handling.

Also see https://bugs.python.org/issue31489 for an issue related to fork(), 
signals and fds.

--

___
Python tracker 

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



Creation of a metaclass for dataclass.

2017-12-29 Thread Kirill Balunov
I'm studying the meta-programming topic in Python, and as an exercise I'm
trying to make a somewhat simplified version of dataclass. My goal in this
exercise is to make the difference between annotated variables and usual
ones to be as much transparent as possible. So I come with this code to
obtain initial fields. It does not catch corner cases and as much as
possible undressed to be short. So my question is there any visible
pitfalls or am I doing something wrong from the early beginning?

Two helpful functions not to clutter `__annotations__`:

from typing import Any
AnyType = Any

def _is_not_dunder(name):
return not ((len(name) > 4) and (name[:2] == name[-2:] == '__'))

def _is_not_descriptor(obj):
return not (hasattr(obj, '__get__') or
hasattr(obj, '__set__') or
hasattr(obj, '__delete__'))

The special dict (class namespace) to inject usual variables in `
__annotations__` with default typehint - `AnyType`, and also keep their
ordered appearance in the class body.

class SpecialDict(dict):
def __init__(self):
super().__init__()
super().__setitem__('__annotations__', {})

def __setitem__(self, key, value):
if not (key in self) and _is_not_dunder(key) and
_is_not_descriptor(value):
self['__annotations__'][key] = AnyType
super().__setitem__(key, value)

Data meta-class which defines `__fields` from `__annotations__`:

class DataMeta(type):
@classmethod
def __prepare__(metacls, cls, bases, **kwargs):
_dict = SpecialDict()
return _dict

def __init__(cls, *args , **kwargs):
super().__init__(*args)

def __new__(metacls, cls, bases, clsdict):
clsdict['__fields'] = tuple(clsdict['__annotations__'].items())
_cls = type.__new__(metacls, cls, bases, clsdict)
return _cls

And test class:

class MyClass(metaclass=DataMeta):
a: float
barattr: int = 2
jik = 12
bzik: int =14

def foo(self, param):
pass

data = MyClass()

a.__fields   # (('a', float), ('barattr', int), ('jik', typing.Any),
('bzik', int))


Thank you!

With kind regards, -gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32443] Add Linux's signalfd() to the signal module

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

See also https://bugs.python.org/issue12304

--
nosy: +pitrou

___
Python tracker 

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



[issue32434] pathlib.WindowsPath.reslove(strict=False) returns absoulte path only if at least one component exists

2017-12-29 Thread Eryk Sun

Eryk Sun  added the comment:

resolve() has additional problems, which possibly could be addressed all at 
once because it's a small method and the problems are closely related.

For an empty path it returns os.getcwd(). I don't think this case is possible 
in the normal way a Path gets constructed. Anyway, returning the unresolved 
working directory is incorrect. Windows is not a POSIX OS. WinAPI 
[Set,Get]CurrentDirectory does not ensure the working directory is a resolved 
path. An empty path should be replaced with "." and processed normally.

It fails when access is denied. _getfinalpathname needs to open a handle, and 
CreateFile requires at least the right to read file attributes and synchronize. 
For example, resolve() fails for a path in another user's profile, which grants 
access only to the user, system, and administrators.

It doesn't keep the "?\\" extended-path prefix when the source path already 
has it. It should only strip the prefix if the source path doesn't have it. 
That said, the resolved path may actually require it (i.e. long paths, DOS 
device names, trailing spaces), so maybe it should  never be removed.

Its behavior is inconsistent for invalid paths. For example, if "C:/Temp" 
exists and "C:/Spam" does not, then resolving "C:/Temp/bad?" raises whereas 
"C:/Spam/bad?" does not. IMO, it's simpler if neither raises in non-strict 
mode, at least not in _WindowsFlavour.resolve. Malformed paths will slip 
through, but raising an exception in those cases should be the job of the 
constructor. 

It fails to handle device paths. For example, C:/Temp/nul" resolves to the 
"NUL" device if "C:/Temp" exists. In this case _getfinalpathname will typically 
fail, either due to an invalid function or an invalid parameter. These errors, 
along with the error for an invalid filename, get lumped into the CRT's default 
EINVAL error code.

Also, GetFinalPathNameByHandle was added in Vista, so _getfinalpathname is 
always available in 3.5+. There's no need to use it conditionally.

Here's a prototype that addresses these issues:

import nt
import os
import errno

def _is_extended(path):
return path.startswith('?\\')

def _extended_to_normal(path):
if _is_extended(path):
path = path[4:]
if path.startswith('UNC\\'):
path = '\\' + path[3:]
return path

def _getfinalpathname(path):
if not path:
path = '.'
elif _is_extended(path):
return nt._getfinalpathname(path)
return _extended_to_normal(nt._getfinalpathname(path))

def resolve(path, strict=False):
s = str(path)
if strict:
return _getfinalpathname(s)
# Non-strict mode resolves as much as possible while retaining
# tail components that cannot be resolved if they're missing,
# inaccessible, or invalid.
tail_parts = []
while True:
try:
s = _getfinalpathname(s)
break
except OSError as e:
if not (isinstance(e, (FileNotFoundError, PermissionError)) or
e.errno == errno.EINVAL):
raise
head, tail = os.path.split(s)
if head == s:
return path.absolute()
s = head
tail_parts.append(tail)
if tail_parts:
s = os.path.join(s, *reversed(tail_parts))
return s

--

___
Python tracker 

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



[issue32434] pathlib.WindowsPath.reslove(strict=False) returns absoulte path only if at least one component exists

2017-12-29 Thread Eryk Sun

Eryk Sun  added the comment:

If none of the components of a relative path exist, then splitting off the head 
returns an empty string in the second-to-last pass through the while loop. In 
the last pass, _getfinalpathname("") raises FileNotFoundError, and ultimately 
resolve() ends up returning `path`. To avoid this, the empty string needs to be 
replaced with a ".". Then the last pass can resolve the working directory.

--
components: +Windows
nosy: +eryksun, paul.moore, steve.dower, tim.golden, zach.ware
stage:  -> needs patch
versions: +Python 3.7

___
Python tracker 

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



[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2017-12-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le 29/12/2017 à 06:26, Neil Schemenauer a écrit :
> 
> I wonder if I should drop PR 4682.

My main criterion (apart from performance issues which don't seem to
exist) for choosing between the two PRs would be implementation
complexity.  I find Serhiy's PR pleasantly uncomplicated (it even
*simplifies* the code in frameobject.c).

Your PR seems to add more complexity, so I would be inclined to choose
Serhiy's PR.

--

___
Python tracker 

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