Re: Sorting NaNs

2018-06-07 Thread Gregory Ewing
Steven D'Aprano wrote: But if it were (let's say) 1 ULP greater or less than one half, would we even know? In practice it's probably somewhat bigger than 1 ULP. A typical PRNG will first generate a 32-bit integer and then map it to a float, giving a resolution coarser than the 52 bits of an IEE

EuroPython 2018: Training pass sale starts on Friday at 12:00 CEST

2018-06-07 Thread M.-A. Lemburg
As we have already announced, access to trainings is not included in our regular conference tickets this year. We have done this to keep the conference ticket prices reasonable, acknowledge the value in the trainings are and to add more flexibility. Two full days of trainings included ---

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 1:55 PM, Steven D'Aprano wrote: > On Tue, 05 Jun 2018 23:27:16 +1000, Chris Angelico wrote: > >> And an ASCIIZ string cannot contain a byte value of zero. The parallel >> is exact. > > Why should we, as Python programmers, care one whit about ASCIIZ strings? > They're not re

Re: Sorting NaNs

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 2:14 PM, Steven D'Aprano wrote: > On Sat, 02 Jun 2018 21:02:14 +1000, Chris Angelico wrote: > >> Point of curiosity: Why "> 0.5"? > > No particular reason, I just happened to hit that key and then copied and > pasted the line into the next one. Hah! The simplicity of it. >

Re: Why exception from os.path.exists()?

2018-06-07 Thread Antoon Pardon
On 07-06-18 05:55, Steven D'Aprano wrote: > Python strings are rich objects which support the Unicode code point \0 > in them. The limitation of the Linux kernel that it relies on NULL- > terminated byte strings is irrelevant to the question of what > os.path.exists ought to do when given a path

Re: Why exception from os.path.exists()?

2018-06-07 Thread Marko Rauhamaa
Antoon Pardon : > On 07-06-18 05:55, Steven D'Aprano wrote: >> As a Python programmer, how does treating NUL specially make our life >> better? > > By treating possible path values differently from impossible path > values. There are all kinds of impossibility. The os.stat() reports those impossi

Re: Why exception from os.path.exists()?

2018-06-07 Thread Marko Rauhamaa
Marko Rauhamaa : > This is a security risk. Here is a brief demonstration. Copy the example > HTTP server from: > >https://docs.python.org/3/library/http.server.html?highlight=h >ttp#http.server.SimpleHTTPRequestHandler> > > [...] > > 3. http://localhost:8000/te%00st.html > > => The

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 7:29 PM, Marko Rauhamaa wrote: > This is a security risk. Here is a brief demonstration. Copy the example > HTTP server from: > >https://docs.python.org/3/library/http.server.html?highlight=h >ttp#http.server.SimpleHTTPRequestHandler> > > Run the server. Try these UR

Re: Why exception from os.path.exists()?

2018-06-07 Thread Antoon Pardon
On 07-06-18 11:29, Marko Rauhamaa wrote: > Antoon Pardon : > >> On 07-06-18 05:55, Steven D'Aprano wrote: >>> As a Python programmer, how does treating NUL specially make our life >>> better? >> By treating possible path values differently from impossible path >> values. > There are all kinds of im

Re: Why exception from os.path.exists()?

2018-06-07 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Jun 7, 2018 at 7:29 PM, Marko Rauhamaa wrote: >> 3. http://localhost:8000/te%00st.html >> >> => The server crashes with a ValueError and the TCP connection is >> reset >> > > Actually, I couldn't even get Chrome to make that request, so it > obviously was

round

2018-06-07 Thread ast
Hi round is supposed to provide an integer when called without any precision argument. here is the doc: >>> help(round) round(number[, ndigits]) -> number Round a number to a given precision in decimal digits (default 0 digits). This returns an int when called with one argument, otherwise the

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 8:47 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Jun 7, 2018 at 7:29 PM, Marko Rauhamaa wrote: >>> 3. http://localhost:8000/te%00st.html >>> >>> => The server crashes with a ValueError and the TCP connection is >>> reset >>> >> it's somewhat uni

Re: round

2018-06-07 Thread Lutz Horn
M = np.array([[0, 9],[2, 7]], dtype=int) np.linalg.det(M) -18.004 round(np.linalg.det(M)) np.linalg.det(M) has type numpy.float64, not float. Try this: round(float(np.linalg.det(M))) -18 Lutz -- https://mail.python.org/mailman/listinfo/python-list

Re: round

2018-06-07 Thread Peter Otten
ast wrote: > Hi > > round is supposed to provide an integer when > called without any precision argument. > > here is the doc: > > >>> help(round) > > round(number[, ndigits]) -> number > > Round a number to a given precision in decimal digits (default 0 digits). > This returns an int when c

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 19:47:03 +1000, Chris Angelico wrote: > To be fair, it's somewhat unideal behaviour - I would prefer to see an > HTTP 500 come back if the server crashes - but I can't see that that's a > security problem. You think that being able to remotely crash a webserver isn't a securit

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 13:47:07 +0300, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Jun 7, 2018 at 7:29 PM, Marko Rauhamaa >> wrote: >>> 3. http://localhost:8000/te%00st.html >>> >>> => The server crashes with a ValueError and the TCP connection is >>> reset >>> >>> >> Actua

Re: round

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 13:09:18 +0200, ast wrote: > Hi > > round is supposed to provide an integer when called without any > precision argument. True, but that's really under the control of the object you feed it to. It would be possible for round() to enforce that, but it might break code that r

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 10:18 PM, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 13:47:07 +0300, Marko Rauhamaa wrote: > >> Chris Angelico : >> >>> On Thu, Jun 7, 2018 at 7:29 PM, Marko Rauhamaa >>> wrote: 3. http://localhost:8000/te%00st.html => The server crashes with a Value

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 10:04:53 +0200, Antoon Pardon wrote: > On 07-06-18 05:55, Steven D'Aprano wrote: >> Python strings are rich objects which support the Unicode code point \0 >> in them. The limitation of the Linux kernel that it relies on NULL- >> terminated byte strings is irrelevant to the que

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 10:13 PM, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 19:47:03 +1000, Chris Angelico wrote: > >> To be fair, it's somewhat unideal behaviour - I would prefer to see an >> HTTP 500 come back if the server crashes - but I can't see that that's a >> security problem. > > You t

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 22:46:09 +1000, Chris Angelico wrote: >> I wonder how many publicly facing web servers can be induced to either >> crash, or serve the wrong content, this way? >> >> > Define "serve the wrong content". You could get the exact same content > by asking for "te" instead of "te%00s

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Thu, Jun 7, 2018 at 11:09 PM, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 22:46:09 +1000, Chris Angelico wrote: > >>> I wonder how many publicly facing web servers can be induced to either >>> crash, or serve the wrong content, this way? >>> >>> >> Define "serve the wrong content". You could g

Python web server weirdness

2018-06-07 Thread Steven D'Aprano
I'm following the instructions here: https://docs.python.org/3/library/http.server.html and running this from the command line as a regular unprivileged user: python3.5 -m http.server 8000 What I expected was a directory listing of my current directory. What I got was Livejournal's front page

Re: Why exception from os.path.exists()?

2018-06-07 Thread Antoon Pardon
On 07-06-18 14:47, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 10:04:53 +0200, Antoon Pardon wrote: > >> On 07-06-18 05:55, Steven D'Aprano wrote: >>> Python strings are rich objects which support the Unicode code point \0 >>> in them. The limitation of the Linux kernel that it relies on NULL- >>>

Re: Python web server weirdness

2018-06-07 Thread Grant Edwards
On 2018-06-07, Steven D'Aprano wrote: > I'm following the instructions here: > > https://docs.python.org/3/library/http.server.html > > > and running this from the command line as a regular unprivileged user: > > python3.5 -m http.server 8000 > > What I expected was a directory listing of my curre

Re: Python web server weirdness

2018-06-07 Thread Grant Edwards
On 2018-06-07, Steven D'Aprano wrote: > I'm following the instructions here: > > https://docs.python.org/3/library/http.server.html > > > and running this from the command line as a regular unprivileged user: > > python3.5 -m http.server 8000 > > What I expected was a directory listing of my curre

Re: Why exception from os.path.exists()?

2018-06-07 Thread Tim Chase
On 2018-06-07 22:46, Chris Angelico wrote: > On Thu, Jun 7, 2018 at 10:18 PM, Steven D'Aprano > 3. http://localhost:8000/te%00st.html > >>> Actually, I couldn't even get Chrome to make that request, so it > >>> obviously was considered by the browser to be invalid. It doesn't matter wheth

Re: Python web server weirdness SOLVED

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 13:32:10 +, Steven D'Aprano wrote: [...] > python3.5 -m http.server 8000 > > What I expected was a directory listing of my current directory. > > What I got was Livejournal's front page. Never mind -- it turned out I had an "index.html" file in the directory which had b

Re: Python web server weirdness

2018-06-07 Thread Ed Kellett
On 2018-06-07 14:32, Steven D'Aprano wrote: > I'm following the instructions here: > > https://docs.python.org/3/library/http.server.html > > > and running this from the command line as a regular unprivileged user: > > python3.5 -m http.server 8000 > > What I expected was a directory listing o

Re: Python web server weirdness

2018-06-07 Thread Tim Chase
On 2018-06-07 13:32, Steven D'Aprano wrote: > I'm following the instructions here: > > https://docs.python.org/3/library/http.server.html > > and running this from the command line as a regular unprivileged > user: > > python3.5 -m http.server 8000 > > What I expected was a directory listing of

Re: Python web server weirdness

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 13:32:10 +, Steven D'Aprano wrote: > python3.5 -m http.server 8000 [...] Thank you to everyone who responded, pointing out that I should check for an index.html file. That was exactly the problem. And yes, I acknowledge that my original post was lacking in some necessa

Re: Problem finding my folder via terminal

2018-06-07 Thread T Berger
On Wednesday, June 6, 2018 at 12:19:35 PM UTC-4, T Berger wrote: > I’m learning Python on my own and have been stuck for two days trying to get > modules I created into site-packages. As a trial step, we were asked to > change directly into the folder containing our modules. I typed “cd > mymodu

Re: Problem finding my folder via terminal

2018-06-07 Thread T Berger
On Wednesday, June 6, 2018 at 12:19:35 PM UTC-4, T Berger wrote: > I’m learning Python on my own and have been stuck for two days trying to get > modules I created into site-packages. As a trial step, we were asked to > change directly into the folder containing our modules. I typed “cd > mymodu

FULLSCREEN and DOUBLEBUF

2018-06-07 Thread Paul St George
This is both a narrow question about some code and a more general question about syntax in Python Using the Pygame modules, I want to set both FULLSCREEN and DOUBLEBUF I can use screen = pygame.display.set_mode((screen_width,screen_height),pygame.FULLSCREEN) to set a FULLSCREEN display Or, I

Re: Why exception from os.path.exists()?

2018-06-07 Thread MRAB
On 2018-06-07 08:45, Chris Angelico wrote: On Thu, Jun 7, 2018 at 1:55 PM, Steven D'Aprano wrote: On Tue, 05 Jun 2018 23:27:16 +1000, Chris Angelico wrote: And an ASCIIZ string cannot contain a byte value of zero. The parallel is exact. Why should we, as Python programmers, care one whit ab

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 3:10 AM, MRAB wrote: > On 2018-06-07 08:45, Chris Angelico wrote: >> Under Linux, a file name contains bytes, most commonly representing >> UTF-8 sequences. So... an ASCIIZ string *can* contain that character, >> or at least a representation of it. Yet it cannot contain "\0"

Re: FULLSCREEN and DOUBLEBUF

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 3:12 AM, Paul St George wrote: > This is both a narrow question about some code and a more general question > about syntax in Python > > Using the Pygame modules, I want to set both FULLSCREEN and DOUBLEBUF > > I can use > screen = > pygame.display.set_mode((screen_width,scr

logging with multiprocessing

2018-06-07 Thread jenil . desai25
Hello, I am new to logging module. I want to use logging module with multiprocessing. can anyone help me understand how can I do it?. Any help would be appreciated. Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Re: FULLSCREEN and DOUBLEBUF

2018-06-07 Thread Mark Lawrence
On 07/06/18 18:12, Paul St George wrote: This is both a narrow question about some code and a more general question about syntax in Python Using the Pygame modules, I want to set both FULLSCREEN and DOUBLEBUF I can use screen = pygame.display.set_mode((screen_width,screen_height),pygame.FULLS

Re: Stefan's headers [was:Names and identifiers]

2018-06-07 Thread Peter Pearson
On Thu, 7 Jun 2018 01:23:31 + (UTC), Steven D'Aprano wrote: > Disclaimer: Ido not see Stefan's original post. I recall that he has set > some sort of header on his posts which means they are not processed by > Gmane, but unfortunately I no longer have any of his posts in my cache > where I c

Re: Sorting NaNs

2018-06-07 Thread Peter Pearson
On Thu, 07 Jun 2018 19:02:42 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> But if it were (let's say) 1 ULP greater or less >> than one half, would we even know? > > In practice it's probably somewhat bigger than 1 ULP. > A typical PRNG will first generate a 32-bit integer and > then map

Re: Stefan's headers [was:Names and identifiers]

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 6:36 AM, Peter Pearson wrote: > Here's the full header, as received by slrn from news.individual.net: > > X-Copyright: (C) Copyright 2018 Stefan Ram. All rights reserved. Distribution > through any means > other than regular usenet channels is forbidden. It is forbidden t

Valid encodings for a Python source file

2018-06-07 Thread Daniel Glus
I'm trying to figure out the entire list of possible encodings for a Python source file - that is, encodings that can go in a PEP 263 encoding specification, like # -*- encoding: foo -*-. Is this list the same as the list given in the documentation for t

Re: Sorting NaNs

2018-06-07 Thread Michael Lamparski
On Thu, Jun 7, 2018 at 4:43 PM, Peter Pearson wrote: > But gosh, if there are only 2**32 different "random" floats, then > you'd have about a 50% chance of finding a collision among any > set of 2**16 samples. Is that really tolerable? > -- > https://mail.python.org/mailman/listinfo/python-list

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 15:38:39 -0400, Dennis Lee Bieber wrote: > On Fri, 1 Jun 2018 23:16:32 + (UTC), Steven D'Aprano > declaimed the following: > >>It should either return False, or raise TypeError. Of the two, since >>3.14159 cannot represent a file on any known OS, TypeError would be more >

Django-hotsauce/ZODB 5.4.0/PyPy nightly sprint!!

2018-06-07 Thread Etienne Robillard
Yo people I'm doing a nightly hacking sprint for django-hotsauce on pypy and got some cool bugs I would like to share: Traceback (most recent call last):   File "/usr/local/bin/schevo", line 11, in     load_entry_point('libschevo', 'console_scripts', 'schevo')()   File "/home/erob/src/libschevo

Re: Sorting NaNs

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 20:43:10 +, Peter Pearson wrote: > On Thu, 07 Jun 2018 19:02:42 +1200, Gregory Ewing wrote: >> Steven D'Aprano wrote: >>> But if it were (let's say) 1 ULP greater or less than one half, would >>> we even know? >> >> In practice it's probably somewhat bigger than 1 ULP. A ty

Re: Problem finding my folder via terminal

2018-06-07 Thread Cameron Simpson
Hi, Replies inline below, which is the style we prefer on this list. (And to reply, please reply to the specific message, not your original post. This will let you pick up that branch of the conversation directly and not confuse your readers.) On 07Jun2018 08:39, T Berger wrote: On Wednesda

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 23:25:54 +1000, Chris Angelico wrote: [...] >> Does the Python web server suffer from that vulnerability? I would be >> surprised if it were. But it can be induced to crash (an exception, not >> a seg fault) which is certainly a vulnerability. > > "Certainly"? I'm dubious on t

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 17:45:06 +1000, Chris Angelico wrote: > On Thu, Jun 7, 2018 at 1:55 PM, Steven D'Aprano > wrote: >> On Tue, 05 Jun 2018 23:27:16 +1000, Chris Angelico wrote: >> >>> And an ASCIIZ string cannot contain a byte value of zero. The parallel >>> is exact. >> >> Why should we, as Pyt

Re: Why exception from os.path.exists()?

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 12:16 PM, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 23:25:54 +1000, Chris Angelico wrote: >> Yes, it's a bug. If someone tries a page size of zero, it'll divide by >> zero and bomb. Great. But how is it a vulnerability? It is a >> properly-handled exception. > > Causing a

Re: Why exception from os.path.exists()?

2018-06-07 Thread Richard Damon
On 6/7/18 9:17 PM, Steven D'Aprano wrote: > On Thu, 07 Jun 2018 15:38:39 -0400, Dennis Lee Bieber wrote: > >> On Fri, 1 Jun 2018 23:16:32 + (UTC), Steven D'Aprano >> declaimed the following: >> >>> It should either return False, or raise TypeError. Of the two, since >>> 3.14159 cannot represen

Re: Valid encodings for a Python source file

2018-06-07 Thread Ben Finney via Python-list
Daniel Glus writes: > I'm trying to figure out the entire list of possible encodings for a Python > source file - that is, encodings that can go in a PEP 263 > encoding specification, like # > -*- encoding: foo -*-. What if the answer is not an emunera

Re: Why exception from os.path.exists()?

2018-06-07 Thread Ben Finney
Richard Damon writes: > This does bring up an interesting point. Since the Unix file system > really has file names that are collection of bytes instead of really > being strings, and the Python API to it want to treat them as strings, > then we have an issue that we are going to be stuck with pr

Re: Python web server weirdness SOLVED

2018-06-07 Thread Gregory Ewing
Steven D'Aprano wrote: Never mind -- it turned out I had an "index.html" file in the directory which had been wget'ed from LiveJournal. That's okay, then. The other possibility was that your computer had been recruited into an evil botnet set up by LiveJournal to create backup servers for their

Re: Sorting NaNs

2018-06-07 Thread Gregory Ewing
Michael Lamparski wrote: In any case, it's verifiably not true for CPython. Yes, CPython uses a particularly good PRNG. You may not be as lucky using libraries that come with other languages. A great many PRNG algorithms have been proposed, and a good proportion of them produce 32-bit ints as

Re: Valid encodings for a Python source file

2018-06-07 Thread Terry Reedy
On 6/7/2018 4:40 PM, Daniel Glus wrote: I'm trying to figure out the entire list of possible encodings for a Python source file - that is, encodings that can go in a PEP 263 encoding specification, like # -*- encoding: foo -*-. For new code for python

Re: Stefan's headers [was:Names and identifiers]

2018-06-07 Thread Thomas Jollans
On 07/06/18 22:36, Peter Pearson wrote: > X-Copyright: (C) Copyright 2018 Stefan Ram. All rights reserved. Distribution > through any means > other than regular usenet channels is forbidden. It is forbidden to publish > this article in the > Web, to change URIs of this article into links,

Re: Why exception from os.path.exists()?

2018-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2018 22:56:49 -0400, Richard Damon wrote: > or we need an alternate API that lets us pass raw bytes as file names Guido's Time Machine strikes again. All the path related functions, include open(), take arguments as either bytes or strings. -- Steven D'Aprano "Ever since I le