[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Sorry, I misread the traceback itself as if it's from pip. It's from html5lib 
being incompatible with 3.9 as per the latest release on 1.0.1 (Dec 7, 2017) . 
There is an issue to request new release with the fix at 
https://github.com/html5lib/html5lib-python/issues/419 . Maybe you can try 
building html5lib from their master branch to be used in pyperformance. I would 
propose closing it as third party.

--

___
Python tracker 

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



[issue38729] mock.create_autospec generates incorrect signature for some decorated methods

2019-11-07 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

If I understand this correctly, when an autospec of a class is created the 
attributes themselves of the given class are autospecced. During autospec of 
attributes it's modelled upon __call__'s signature for the given attributes 
[0]. Here you are wrapping the method's inside a class with Wrapper with a 
custom __call__ implementation. During actual calls the chain goes through 
__call__ and executes __get__ where bound method is called. But in mock I am 
not sure of a way where it can figure out __call__ and then look more into the 
body to see if there are actual calls being made to be mocked with current 
implementation just going through signature of __call__.

[0] 
https://github.com/python/cpython/blob/befa032d8869e0fab4732d910f3887642879d644/Lib/unittest/mock.py#L94

--

___
Python tracker 

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



[issue38741] Definition of multiple ']' in header configparser

2019-11-07 Thread Mark


New submission from Mark :

in example header is "[i love [python] lang]"
parse as "i love [python", only up to the first character ']'.

now saving works correctly, but reading does not

--
messages: 356225
nosy: @mark99i
priority: normal
severity: normal
status: open
title: Definition of multiple ']' in header configparser
type: behavior
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



[issue38740] Line count mis match between open() vs sys.stdin api calls

2019-11-07 Thread Thamme Gowda


Change by Thamme Gowda :


Added file: https://bugs.python.org/file48702/line_break_err.txt

___
Python tracker 

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



[issue38740] Line count mis match between open() vs sys.stdin api calls

2019-11-07 Thread Thamme Gowda


New submission from Thamme Gowda :

I ran into a line count mismatch bug and I narrowed it down to 9 lines where 
the line break handling is causing an issue. Please find the attachment named 
line_break_err.txt to reproduce the below. 


$ md5sum line_break_err.txt
5dea501b8e299a0ece94d85977728545  line_break_err.txt

# wc says there are 9 lines
$ wc -l line_break_err.txt
9 line_break_err.txt

# if I read from sys.stdin, I get 9 lines
$ python -c 'import sys; print(sum(1 for x in sys.stdin))' < line_break_err.txt

# but... if I use a open() call, i get 18 
$ python -c 'import sys; print("Linecount=", sum(1 for x in 
open(sys.argv[1])))' line_break_err.txt
Linecount= 18

# changing encoding or error handling has no effect
$ python -c 'import sys; print("Linecount=", sum(1 for x in open(sys.argv[1], 
"r", encoding="utf-8", errors="replace")))' line_break_err.txt
Linecount= 18

$ python -c 'import sys; print("Linecount=", sum(1 for x in open(sys.argv[1], 
"r", encoding="utf-8", errors="ignore")))' line_break_err.txt
Linecount= 18
# but, not just wc, even awk says there are only 9 lines
$ awk 'END {print "Linecount=", NR}' line_break_err.txt
Linecount= 9

# let's see python 2 using io
# python2 -c 'import sys,io; print("Linecount=", sum(1 for x in 
io.open(sys.argv[1],  encoding="ascii", errors="ignore")))' line_break_err.txt
('Linecount=', 18)

# But this one which we no longer use somehow gets it right
$ python2 -c 'import sys; print("Linecount=", sum(1 for x in 
open(sys.argv[1])))' line_break_err.txt
('Linecount=', 9)


Tested it on 
1. Linux 
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21)
[GCC 7.3.0] :: Anaconda, Inc. on linux


2. OSX
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

3. python 2 on OSX
Python 2.7.16 (default, Jun 19 2019, 07:40:37)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin

 

P.S. 
this is my first issue created. If this issue is a duplicate, I am happy to 
close it.

--
components: IO, Library (Lib), Unicode
messages: 356224
nosy: Thamme Gowda, ezio.melotti, vstinner
priority: normal
severity: normal
status: open
title: Line count mis match between open() vs sys.stdin api calls
type: behavior

___
Python tracker 

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



Questions on working with unittest.IsolatedAsyncioTestCase

2019-11-07 Thread Mond Wan
Hello all,

I would like to ask for helps on working with 
**unittest.IsolatedAsyncioTestCase**.

Q1: How to handle asyncio.CancelledError inside IsolatedAsyncioTestCase.

My test is hanging up if there are futures being cancelled some how. Is there a 
way for me to configure IsolatedAsyncioTestCase to throw any exceptions
to crash the main program such that I can read the line number?

I have also issue a post on stackoverflow, which include the codes I have 
written for explaining the question.

Stackoverflow: 
https://stackoverflow.com/questions/58744043/how-to-handle-cancellederror-with-python-3-8-unittest-isolatedasynciotestcase


Q2: addAsyncCleanup vs asyncTearDown?

In the py3.8 manual, there is a method **addAsyncCleanup** for cleaning up 
stuff in async way. Why we need this instead of merging them altogether
into **asyncTearDown** at all?


Q3: Is it possible to configure a timeout mechanism for IsolatedAsyncioTestCase?

During my development, my tests always pending in somewhere. I cannot located 
them until I add print statements line by line. Is it possible to
configure the IsolatedAsyncioTestCase to crash the test, with line number, 
after specific period if such future is not resolved?


Thanks for your time

--

Mond WAN

Senior Engineer, Engineering Department

Anywhere Networks
Mobile/WhatsApp: +852 3899 1928

mondwan@anywherenetworks.com

www.AnywhereNetworks.com

P2 Wireless Technologies is now Anywhere Networks!

[Anywhere Networks]

Disclaimer: This email and its attachment(s) are solely for the use of the 
intended addressee and may contain confidential information. If you are not the 
intended recipient, you must not use, distribute or copy this email. If you 
have received this email in error, please notify the sender immediately and 
delete this email. No employee or agent is authorized to bind the company or 
conclude a binding agreement on behalf of the company without express written 
approval by an authorized senior officer of the company. In no event will this 
email or its content be construed as written approval.


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


[issue32545] Unable to install Python 3.7.0a4 on Windows 10 - Error 0x80070643: Failed to install MSI package.

2019-11-07 Thread Gustavo


Gustavo  added the comment:

I was able to fix this problem quickly following these easy guide:

First, you need to press the keys Win + R to open the Run dialog, there type 
the command msiexec /unreg and hit Enter
Now, open the Run dialog again and this time, type the command msiexec 
/regserver, then hit Enter
Finally, try to install python again.

I found this guide on https://windowshelper.co

--
nosy: +gustavoxo

___
Python tracker 

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



[issue38736] argparse: wrong type from get_default when type is set

2019-11-07 Thread paul j3


paul j3  added the comment:

get_default just returns the default attribute as it is stored in the Action.   
Defaults are stored as given. 

During parsing the Action's default is placed in the args namespace at the 
start.  At the end, it checks if the value in the namespace is a string that 
matches the default (i.e. has been over written by user input).  Only then is 
it passed through the type function.

--
nosy: +paul.j3

___
Python tracker 

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



[issue38730] 2.7 modern compiler warnings

2019-11-07 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

collections removed ABC access in 3.9. It seems you are using an older version 
of pip. Please update to the latest version which has the vendored html5lib 
package fixed.

--
nosy: +xtreak

___
Python tracker 

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Travis Lazar


Travis Lazar  added the comment:

Forgot to include that this was built on an aarch64 (Ampere eMAG) system.

--

___
Python tracker 

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Travis Lazar


New submission from Travis Lazar :

When running pyperformance html5lib test, the application crashes with 
"ImportError: cannot import name 'Mapping' from 'collections' 
(/py3buildpath/lib/python3.9/collections/__init__.py)"

To reproduce:

1 - Build Python from source. I produced with git commit 
befa032d8869e0fab4732d910f3887642879d644 from cpython GitHub.

2 - Run pyperformance with: /py3buildpath/bin/pyperformance run 
--python=/py3buildpath/bin/python3 --venv venvpath -b html5lib -o output.json

3 - Immediate crash is seen with message:

#!/bin/sh
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_tokenizer.py",
 line 16, in 
from ._trie import Trie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/__init__.py",
 line 3, in 
from .py import Trie as PyTrie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/py.py",
 line 6, in 
from ._base import Trie as ABCTrie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/_base.py",
 line 3, in 
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' 
(/root/py3-tot-no/lib/python3.9/collections/__init__.py)
ERROR: Benchmark html5lib failed: Benchmark died
Traceback (most recent call last):
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 132, in run_benchmarks
bench = func(cmd_prefix, options)
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/benchmarks/__init__.py",
 line 244, in BM_html5lib
return run_perf_script(python, options, "html5lib")
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 98, in run_perf_script
run_command(cmd, hide_stderr=not options.verbose)
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 66, in run_command
raise RuntimeError("Benchmark died")
RuntimeError: Benchmark died

--
components: Tests
messages: 356219
nosy: Travis Lazar
priority: normal
severity: normal
status: open
title: pyperformance html5lib cannot import Mapping (and fails)
type: crash
versions: Python 3.9

___
Python tracker 

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



[issue38707] Multiprocessing: bug with Native ID for threading.mainthread()

2019-11-07 Thread Jake Tesler


Jake Tesler  added the comment:

@vstinner PR created :)
https://github.com/python/cpython/pull/17088

--

___
Python tracker 

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



[issue38707] Multiprocessing: bug with Native ID for threading.mainthread()

2019-11-07 Thread Jake Tesler


Change by Jake Tesler :


--
keywords: +patch
pull_requests: +16596
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17088

___
Python tracker 

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



Re: Using Makefiles in Python projects

2019-11-07 Thread Cameron Simpson

On 08Nov2019 10:30, David  wrote:

On Fri, 8 Nov 2019 at 09:43, Cameron Simpson  wrote:
[...]


_help:
@echo '_build: make $(py_static_bundle)'
@echo '_deploy_tip: formally deploy the current tip to the dev host 
dev tree:'
@echo '_sync_dev: rsync the current working files into the dev tip 
tree'


[...]


Things to note:

"Virtual targets" are actions rather than result files, and start with
an underscore.

The default target is _help, which recites a description of the other
targets.


Hi, as you might be aware, the above recipe will not be run if a file
named '_help' exists.


Hence the funny name. I don't make files whole names begin with 
underscores.



The Gnu make documentation term for what you call "virtual targets"
is "phony targets", and it discusses them here:
https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets

I would add the line:
.PHONY: _help
And similar for all the other phony targets.


If you're using GNU make, go right ahead. But that approach treats 
.PHONY like a label to be applied to _its_ dependents. Probably that's 
exactly what it does. However, that is the inverse of the normal 
target:dependent relationship one puts in Makefiles.


My personal approach is this:

   _always:
   :

   _help:  _always

i.e. make the "phony" targets depend on "_always", which are thus always 
out of date and thus will always run. You've still to avoid making a 
"_always", but that is a smaller thing than the whole "_*" space, if 
that is a concern.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

I heard that for debuggers, the PEP 523 is really useful. I recall a huge 
speedup thanks to this PEP in Jetbrain:
https://blog.jetbrains.com/pycharm/2017/03/inside-the-debugger-interview-with-elizaveta-shashkova/

--

___
Python tracker 

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



Re: Using Makefiles in Python projects

2019-11-07 Thread David
On Fri, 8 Nov 2019 at 09:43, Cameron Simpson  wrote:

[...]

> _help:
> @echo '_build: make $(py_static_bundle)'
> @echo '_deploy_tip: formally deploy the current tip to the dev 
> host dev tree:'
> @echo '_sync_dev: rsync the current working files into the dev 
> tip tree'

[...]

> Things to note:
>
> "Virtual targets" are actions rather than result files, and start with
> an underscore.
>
> The default target is _help, which recites a description of the other
> targets.

Hi, as you might be aware, the above recipe will not be run if a file
named '_help' exists.

The Gnu make documentation term for what you call "virtual targets"
is "phony targets", and it discusses them here:
https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets

I would add the line:
.PHONY: _help
And similar for all the other phony targets.

Doing this has other advantages as described in the linked docs.
In particular, it saves 'make' wasting time searching for built-in
implicit rules
that might build these never-built targets. 'make -d' will reveal this.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

2019-11-07 Thread Brett Cannon


Brett Cannon  added the comment:

PEP 523 was to give user code the ability to change the eval function. While 
the work was motivated by our JIT work, supporting debugging was another 
motivating factor: https://www.python.org/dev/peps/pep-0523/#debugging. There's 
no C API because at the time there was no need as PyInterpreterState was 
publicly exposed.

I don't think anyone is suggesting to add something to the stable ABI, so this 
comes down to whether this should be exposed as part of the CPython API or the 
publicly accessible internal API. Since there is no distinction of "you 
probably don't want to use this but we won't yank it out from underneath" you I 
think this belongs in the CPython API somehow. Otherwise someone should propose 
withdrawing PEP 523 as I think that shifts what the PEP was aiming for. You can 
also ask on python-dev or the steering council (which I will abstain myself 
from due to being a co-author of PEP 523).

--

___
Python tracker 

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



Re: How execute at least two python files at once when imported?

2019-11-07 Thread Cameron Simpson

On 08Nov2019 00:52, Greg Ewing  wrote:

Cameron Simpson wrote:
Spencer's modules run unconditional stuff in addition to defining 
classes. That may cause trouble.


It will -- because of the import lock, they won't run simultaneously
in the same process.


I was unsure as to how serialised this was: just the import data 
structures or the whole source-of-the-module. But I guess serialising 
the latter is essential anyway, now I think about it.


Hence my separate post suggesting the OP move the "main task" into a 
function, runs the imports serailly (very cheap) and then kick off 
threads if that's what he wants.


Thanks for the clarification.

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-11-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yes, that's likely where the change should be made.

I think if the *first* token encountered is either NL or COMMENT the parse 
should be abandoned by the tokenizer.

--

___
Python tracker 

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



Re: Using Makefiles in Python projects

2019-11-07 Thread Cameron Simpson

On 07Nov2019 22:20, Vitaly Potyarkin  wrote:

What do you think of using Makefiles for automating common chores in
Python projects? Like linting, type checking and testing?


I do use one for some things. (Not linting, which I'll describe lower 
down.)


I do like to use it for what make's strength is: running actions based 
on updated files, but there are a few "action" targets too.


Here's a slightly edited and trimmed excerpt from a Makefile (well, 
Mykefile, but the intent and syntax are very similar) from a current 
project:


   venv_dir = $./venv
   venv_reqs = requirements.txt
   venv_pip = $(venv_dir)/bin/pip

   py_static_bundle = $(py_app)/static/app.js

   fleet_dev = [ "$$HOST" = fleet -a "$$USER" = cameron ]

   _help:
   @echo '_build: make $(py_static_bundle)'
   @echo '_deploy_tip: formally deploy the current tip to the dev host 
dev tree:'
   @echo '_sync_dev: rsync the current working files into the dev tip 
tree'

   _build:
   make $(py_static_bundle)

   _venv:
   :make $(venv_dir)

   $(venv_dir):$(venv_reqs)
   python3 -m venv $(venv_dir)
   $(venv_pip) install -U pip
   $(venv_pip) install -U -r $(venv_reqs)

   $(py_static_bundle): $(app_js)
   env-dev browserify -t [ babelify --presets [ react ] ] $? >$@

   _sync_dev:
   $(fleet_dev) || { echo "not cameron@fleet, refusing to rsync" >&2; 
exit 1; }
   :make $(py_static_bundle)
   $(sync_src(target_dev_host:releases/tip))

Things to note:

"Virtual targets" are actions rather than result files, and start with 
an underscore.


The default target is _help, which recites a description of the other 
targets.


The _venv target makes the venv directory if missing, and that runs 
python3 -m venv and then pip to do the required packages.


There's a traditional make rule i.e. an action based on a dependent 
file, gosh! for the static bundle (javascript compiled into a single 
file).


You'll see that _sync_dev has a leading sanity check: it won't run 
unless I'm me on my personal machine; avoids accidents. This is 
important because it isn't running the formal deploy script, which 
builds a clean versioned tree at the far end, instead it just rsyncs my 
local code into a "live" dev tree at the far end. Obviously that is a 
very personal hack.


I've come up with a reusable Makefile for automating virtual 
environment

management in Python projects. I think it can be useful for simplifying
the onboarding of new developers (both new to project and new to Python)
and for documenting project's development practices.


These are laudable goals. I like the expose the dev practices in 
particular.



Here it is:
- Repo: https://github.com/sio/Makefile.venv
- Demo screencast: https://asciinema.org/a/279646

What do you think? Is this useful or I'm just unaware of some tool that
abstracts venv chores away better?


There may be other tools.

Linting can be personal. In my current team we have varying lint habits 
among the devs. OTOH a common "required lint before release" could be 
useful, covering off the project lint standards if they exist.


I lint by hand, with 2 main levels of automation:

1: I have a personal "lint" script with runs my preferred linters with 
my preferred options, so I can just say "lint filenames..." and have it 
do the right thing. It is also multilanguage: python linters, shell 
linters, etc.


2: I have a few VCS related shell functions. One is named "lint". With 
arguments is invokes the above lint script directly. _Without_ arguments 
it lints the "modified" (== changed and not committed) files. So I can 
just say "lint" and it lints my changes, not all the files.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Using Makefiles in Python projects

2019-11-07 Thread Grant Edwards
On 2019-11-07, Skip Montanaro  wrote:

> In short, if you have to type a command more than once, you need a
> Makefile. It will save you time and serve as documentation to
> yourself and others about how the various pieces of your project fit
> together.

Definitely.

Some of the projects I work on don't actually use "make" to build the
software product.  But they still have a Makefiles with targets for
things like formatting documentation, installing the software on a
target, tagging and archiving a version, generating a tarball of GPL
sources, updating source trees from upstream, etc...

-- 
Grant Edwards   grant.b.edwardsYow! BARBARA STANWYCK makes
  at   me nervous!!
  gmail.com

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


[issue38608] Undocumented behavior that IsolatedAsyncioTestCase would enable event loop debug mode

2019-11-07 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Slower by percents, not in the factor of times.

I guess for tests it is satisfactory.

--

___
Python tracker 

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



Re: Using Makefiles in Python projects

2019-11-07 Thread Skip Montanaro
On Thu, Nov 7, 2019 at 1:24 PM Vitaly Potyarkin  wrote:
>
> What do you think of using Makefiles for automating common chores in
> Python projects? Like linting, type checking and testing?

Kinda unsure why this needs to be asked (says the guy who's used Make
longer than Python and nearly as long as Emacs). :-) That said, I will
answer in the affirmative. Make is a great tool. Every Makefile should
have "test", "lint" and "clean" targets (where they make sense) in
addition to something equating to "all" (the first target in the
file). In short, if you have to type a command more than once, you
need a Makefile. It will save you time and serve as documentation to
yourself and others about how the various pieces of your project fit
together.

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


Re: Can't run easy_install even though setuptools is installed

2019-11-07 Thread Cameron Simpson

On 07Nov2019 21:38, Chris Green  wrote:

I'm a bit flummoxed.

I'm trying to install a Python package from pypi.org, it says it
should be installed by running "easy_install onkyo-eiscp" but I just
get "easy_install:  command not found" when I try that.  I do have
setuptools installed on my system and I can see "easy_install.py" in
the package installation area.

This is on an xubuntu 19.04 Linux system.

So what is wrong?


Have you tried this?

   pip install onkyo-eiscp

Using the pip associated with your intended Python executable. "python 
-m pip" should also work, where "python" is the python you're intending 
to use it with.


Thus (using pip, the command line flavour of the module, should be 
preinstalled with Python 2 >=2.7.9 or Python 3 >=3.4):


   [~]fleet*> pip install onkyo-eiscp
   Collecting onkyo-eiscp
 Downloading 
   https://files.pythonhosted.org/packages/05/7b/a25440e34d015237d1f68b8e353f06eaa3a90c1fa77a6621e5e15e4388de/onkyo-eiscp-1.2.7.tar.gz 
   (48kB)

|| 51kB 864kB/s
   Collecting docopt>=0.4.1
 Downloading 
   https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz

   Collecting netifaces
 Downloading 
   https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz

   Installing collected packages: docopt, netifaces, onkyo-eiscp
   Running setup.py install for docopt ... done
   Running setup.py install for netifaces ... done
   Running setup.py install for onkyo-eiscp ... done
   Successfully installed docopt-0.6.2 netifaces-0.10.9 onkyo-eiscp-1.2.7

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Can't run easy_install even though setuptools is installed

2019-11-07 Thread Chris Green
I'm a bit flummoxed.

I'm trying to install a Python package from pypi.org, it says it
should be installed by running "easy_install onkyo-eiscp" but I just
get "easy_install:  command not found" when I try that.  I do have
setuptools installed on my system and I can see "easy_install.py" in
the package installation area.

This is on an xubuntu 19.04 Linux system.

So what is wrong?

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue16576] ctypes: structure with bitfields as argument

2019-11-07 Thread Vinay Sajip


Change by Vinay Sajip :


--
versions: +Python 3.7, Python 3.8, Python 3.9 -Python 2.7, Python 3.2

___
Python tracker 

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



[issue22367] Add open_file_descriptor parameter to fcntl.lockf() (use the new F_OFD_SETLK flag)

2019-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16594
pull_request: https://github.com/python/cpython/pull/17084

___
Python tracker 

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



[issue22367] Add open_file_descriptor parameter to fcntl.lockf() (use the new F_OFD_SETLK flag)

2019-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16595
pull_request: https://github.com/python/cpython/pull/17085

___
Python tracker 

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



[issue22367] Add open_file_descriptor parameter to fcntl.lockf() (use the new F_OFD_SETLK flag)

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset befa032d8869e0fab4732d910f3887642879d644 by Serhiy Storchaka 
(Dong-hee Na) in branch 'master':
bpo-22367: Add tests for fcntl.lockf(). (GH-17010)
https://github.com/python/cpython/commit/befa032d8869e0fab4732d910f3887642879d644


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue38706] What should the error message in the exception raised by assertTrue and assertFalse be?

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue38738.

--

___
Python tracker 

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



[issue38738] Fix formatting of True and False

2019-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +16593
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17083

___
Python tracker 

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



Re: can't install http module

2019-11-07 Thread Chris Angelico
On Fri, Nov 8, 2019 at 6:34 AM Tony van der Hoff  wrote:
>
>
>
> On 07/11/2019 19:00, Chris Angelico wrote:
> > On Fri, Nov 8, 2019 at 5:47 AM tony van der Hoff  
> > wrote:
> >>
> >> Hi,
> >> I'm attempting to install (among other things) the "http" module on my
> >> debian10 box, and am encountering the following problem:
> >>
> >
> > Can you link to the documentation for the package you're trying to
> > install? Python already ships with a module called "http". You don't
> > need to install it.
> >
> Thanks Chris, but it doesn't seem to be installed here, but maybe I'm
> doing something stupid:
>
> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-
>

Ah. I wouldn't call this "something stupid", because this is a bit of
a gotcha, but there is a small problem here. In your original post,
you attempted to install using "python3 -m pip", but here your shebang
just says "python", so you're running it in Python 2.7. Replace the
shebang with "python3" (and then drop the coding cookie - Python 3
assumes UTF-8 by default) and you should be able to run your code. (At
least the import lines you posted. No idea about anything else.)

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


[issue38738] Fix formatting of True and False

2019-11-07 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR fixes some issues with True and False in the documentation:

* "Return true/false" is replaced with "Return ``True``/``False``" if the 
function actually returns a bool.

* Fixed formatting of some True and False literals (now in monospace).

* Replaced "True/False" with "true/false" if it can be not only bool.

* Replaced some 1/0 with True/False if it corresponds the code.

--
assignee: docs@python
components: Documentation
messages: 356210
nosy: docs@python, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Fix formatting of True and False
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: can't install http module

2019-11-07 Thread Tony van der Hoff




On 07/11/2019 19:00, Chris Angelico wrote:

On Fri, Nov 8, 2019 at 5:47 AM tony van der Hoff  wrote:


Hi,
I'm attempting to install (among other things) the "http" module on my
debian10 box, and am encountering the following problem:



Can you link to the documentation for the package you're trying to
install? Python already ships with a module called "http". You don't
need to install it.

Thanks Chris, but it doesn't seem to be installed here, but maybe I'm 
doing something stupid:


#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import cgi
import logging
from http import cookies


[Thu Nov 07 17:29:24.002303 2019] [cgi:error] [pid 30937] [client 
127.0.0.1:41912] AH01215: Traceback (most recent call last):: 
/home/tony/public_html/private/pygallery/pygallery.py
[Thu Nov 07 17:29:24.002455 2019] [cgi:error] [pid 30937] [client 
127.0.0.1:41912] AH01215:   File 
"/home/tony/public_html/private/pygallery/pygallery.py", line 6, in 
: /home/tony/public_html/private/pygallery/pygallery.py
[Thu Nov 07 17:29:24.002480 2019] [cgi:error] [pid 30937] [client 
127.0.0.1:41912] AH01215: from http import cookies: 
/home/tony/public_html/private/pygallery/pygallery.py
[Thu Nov 07 17:29:24.002502 2019] [cgi:error] [pid 30937] [client 
127.0.0.1:41912] AH01215: ImportError: No module named http: 
/home/tony/public_html/private/pygallery/pygallery.py


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


Using Makefiles in Python projects

2019-11-07 Thread Vitaly Potyarkin
What do you think of using Makefiles for automating common chores in
Python projects? Like linting, type checking and testing?

I've come up with a reusable Makefile for automating virtual environment
management in Python projects. I think it can be useful for simplifying
the onboarding of new developers (both new to project and new to Python)
and for documenting project's development practices.

Here it is:
- Repo: https://github.com/sio/Makefile.venv
- Demo screencast: https://asciinema.org/a/279646

What do you think? Is this useful or I'm just unaware of some tool that
abstracts venv chores away better?

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


[issue38737] StreamReaderProtocol.eof_received() should return True only for _SSLProtocolTransport

2019-11-07 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

StreamReaderProtocol is tightly coupled with builtin asyncio transports.
Even worse, it is an internal class actually.
If you want a code to operate with custom transports -- perhaps you need to 
reimplement streams for them as well.

--
resolution:  -> wont fix
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



Re: can't install http module

2019-11-07 Thread Chris Angelico
On Fri, Nov 8, 2019 at 5:47 AM tony van der Hoff  wrote:
>
> Hi,
> I'm attempting to install (among other things) the "http" module on my
> debian10 box, and am encountering the following problem:
>

Can you link to the documentation for the package you're trying to
install? Python already ships with a module called "http". You don't
need to install it.

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


can't install http module

2019-11-07 Thread tony van der Hoff

Hi,
I'm attempting to install (among other things) the "http" module on my 
debian10 box, and am encountering the following problem:


##
tony@tony-lx:~/_pycharm/pygallery$ python3 -m pip install http

Collecting http
   Using cached 
https://files.pythonhosted.org/packages/e3/91/a9260805e532e33df273b8f7dffad5c51693f8f9ba5f86bedcf42a7f22eb/http-0.02.tar.gz

     Complete output from command python setup.py egg_info:
     Traceback (most recent call last):
   File "", line 1, in 
   File "/tmp/pip-install-fr02g_f6/http/setup.py", line 3, in 
     import http
   File "/tmp/pip-install-fr02g_f6/http/http/__init__.py", line 17, 
in 

     from request import Request
     ModuleNotFoundError: No module named 'request'

     
Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-install-fr02g_f6/http/


##
So, I tried installing "request":

##

tony@tony-lx:~/_pycharm/pygallery$ python3 -m pip install request
Collecting request
   Downloading 
https://files.pythonhosted.org/packages/f1/27/7cbde262d854aedf217061a97020d66a63163c5c04e0ec02ff98c5d8f44e/request-2019.4.13.tar.gz

Collecting get (from request)
   Downloading 
https://files.pythonhosted.org/packages/3f/ef/bb46f77f7220ac1b7edba0c76d810c89fddb24ddd8c08f337b9b4a618db7/get-2019.4.13.tar.gz

Collecting post (from request)
   Downloading 
https://files.pythonhosted.org/packages/0f/05/bd79da5849ea6a92485ed7029ef97b1b75e55c26bc0ed3a7ec769af666f3/post-2019.4.13.tar.gz
Requirement already satisfied: setuptools in 
/usr/lib/python3/dist-packages (from request) (40.8.0)

Collecting query_string (from get->request)
   Downloading 
https://files.pythonhosted.org/packages/12/3c/412a45daf5bea9b1d06d7de41787ec4168001dfa418db7ec8723356b119f/query-string-2019.4.13.tar.gz

Collecting public (from query_string->get->request)
   Downloading 
https://files.pythonhosted.org/packages/54/4d/b40004cc6c07665e48af22cfe1e631f219bf4282e15fa76a5b6364f6885c/public-2019.4.13.tar.gz
Building wheels for collected packages: request, get, post, 
query-string, public

   Running setup.py bdist_wheel for request ... done
   Stored in directory: 
/home/tony/.cache/pip/wheels/30/84/5f/484cfba678967ef58c16fce6890925d5c7172622f20111fbfd

   Running setup.py bdist_wheel for get ... done
   Stored in directory: 
/home/tony/.cache/pip/wheels/c1/e3/c1/d02c8c58538853e4c9b78cadb74f6d5c5c370b48a69a7271aa

   Running setup.py bdist_wheel for post ... done
   Stored in directory: 
/home/tony/.cache/pip/wheels/c3/c3/24/b5c132b537ab380c02d69e6bd4dec1f5db56b5fe19030473d7

   Running setup.py bdist_wheel for query-string ... done
   Stored in directory: 
/home/tony/.cache/pip/wheels/d6/a4/78/01b20a9dc224dcc009fab669f7f27b943b8889c5150bd68d8a

   Running setup.py bdist_wheel for public ... done
   Stored in directory: 
/home/tony/.cache/pip/wheels/23/7c/6e/f5b4e09d6596c8b8802b347e48f149031e2363368048f1347a

Successfully built request get post query-string public
Installing collected packages: public, query-string, get, post, request
Successfully installed get-2019.4.13 post-2019.4.13 public-2019.4.13 
query-string-2019.4.13 request-2019.4.13

##
So far, so good; retry http:

##

tony@tony-lx:~/_pycharm/pygallery$ python3 -m pip install http
Collecting http
   Using cached 
https://files.pythonhosted.org/packages/e3/91/a9260805e532e33df273b8f7dffad5c51693f8f9ba5f86bedcf42a7f22eb/http-0.02.tar.gz

     Complete output from command python setup.py egg_info:
     Traceback (most recent call last):
   File "", line 1, in 
   File "/tmp/pip-install-zwguez5m/http/setup.py", line 3, in 
     import http
   File "/tmp/pip-install-zwguez5m/http/http/__init__.py", line 17, 
in 

     from request import Request
     ImportError: cannot import name 'Request' from 'request' 
(/home/tony/.local/lib/python3.7/site-packages/request/__init__.py)


     
Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-install-zwguez5m/http/


##
So now I seem to have broken it. I'm not very savvy with the python 
packaging system, so perhaps someone here can help me as a numpty.

Thanks in advance.


-- Tony van der Hoff | mailto:t...@vanderhoff.org Buckinghamshire, England |
--
https://mail.python.org/mailman/listinfo/python-list


[issue38706] What should the error message in the exception raised by assertTrue and assertFalse be?

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

In some cases "a true value" and "a false value" are used in the documentation. 
But in most cases it is just "true" and "false".

--

___
Python tracker 

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



[issue38737] StreamReaderProtocol.eof_received() should return True only for _SSLProtocolTransport

2019-11-07 Thread Anthony Baire


New submission from Anthony Baire :

We developed an alternate asyncio TLS transport based on GnuTLS 
(https://pypi.org/project/aio-gnutls-transport/). In this project we want to 
support half-closed TLS connections (WriteTransport.write_eof()).


Unfortunately StreamReaderProtocol won't interoperate properly without a monkey 
patch because its eof_received() method returns True for any ssl transport 
(this is to avoid a warning in the _SSLProtocolTransport):

def eof_received(self):
self._stream_reader.feed_eof()
if self._over_ssl:
# Prevent a warning in SSLProtocol.eof_received:
# "returning true from eof_received()
# has no effect when using ssl"
return False
return True

As this is an unspecified internal feature, very specific to the 
_SSLProtocolTransport class (which issues the warning), we think the test 
should be made explicitly against this class (see the attached patch).

--
components: asyncio
files: eof-received-over-ssl.diff
keywords: patch
messages: 356207
nosy: aba, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: StreamReaderProtocol.eof_received() should return True only for 
_SSLProtocolTransport
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48701/eof-received-over-ssl.diff

___
Python tracker 

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



Re: psutil.boot_time() ... doesn't ?

2019-11-07 Thread Chris Angelico
On Fri, Nov 8, 2019 at 1:24 AM R.Wieser  wrote:
>
> Chris,
>
> > Yes, but even if it's not recorded as a timestamp but as an
> > uptime counter, that counter can be referenced against the
> > current time in UTC.
>
> Absolutily.   Though the keyword here is "can".  My "could easily imagine"
> considers the other possibility.
>
> I guess I should sit down sometime and just flip the date back and forward
> (in-and-outof DST), and see how the result of psutil.boot_time() compares to
> the thanwhile current time.
>

Yep! Nothing like experimentation! :)

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


[issue38706] What should the error message in the exception raised by assertTrue and assertFalse be?

2019-11-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Terry]

> A correct failure message, correct both as English and Python, should be 
> something like 'bool(x) is not True'.  I see 'x is not true' as an informal 
> English equivalent of the full claim.

I'm not clear whether you're suggesting having something like "bool(x) is not 
True" be the actual failure message, but if you are, that makes a lot of sense 
to me. (My current advice to coworkers is always to include the "msg" attribute 
when using assertTrue and assertFalse, because the default message tends to be 
spectacularly unhelpful.)

-1 on introducing the terms "truthy" and "falsy" (or "falsey"?) into this one 
corner of Python. Given that those terms don't seem to be used elsewhere in the 
codebase, I'd expect introducing them here to cause more confusion, rather than 
less.

--
nosy: +mark.dickinson

___
Python tracker 

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



RE: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread David Raymond
Here is it rewritten using the proposal:
```
#Definition
def myFoo (str1, str2, foo, str = " "):
print( foo(str = str1), foo(str = str2) )


#Call
myFoo ("hello", "world!"):
str = list(str)[0].upper() + str[1:]
return str
```

Are you looking for multi-line lambdas?
Isn't this basically just defining a function... but without an argument list? 
How would that know what "str" is?

Since you can already define functions inside of functions, what functionality 
does this give you that you can't already do with something like this:

def myFoo(str1, str2, foo):
print(foo(str1), foo(str2))

def main():
print("Stuff here")

def f1(str):
str = list(str)[0].upper() + str[1:]
return str
myFoo("hello", "world", f1)

def f1(str): #yup, same name
str = str[:-1] + list(str)[-1].upper()
return str
myFoo("hello", "world", f1)

del f1

print("More stuff")

main()


Which results in:
Stuff here
Hello World
hellO worlD
More stuff

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


[issue38673] REPL shows continuation prompt (...) when comment or space entered

2019-11-07 Thread Anders Lorentsen


Anders Lorentsen  added the comment:

As a person without much experience, it sounded like a simple enough task, but 
having dug a bit, I found it quite complicated. It seems to me that the 
interpreter loop (in the standard REPL, that you get when you start ./python, 
blocks for input somewhere inside a massive function called 'parsetok' (in 
Parser/parsetok.c). Now, I could maybe investigate further, to have it return 
to the interpreter loop if it reads a comment (or empty line), but I'm afraid 
to mess up something.

>From my understanding, there aren't that many other choices, because 
>parsetok() doesn't return before you finish the statement (in other words, it 
>does not return if you type a comment line or a blank line - it instead waits 
>for more input, as indicated by the '... ').

Am I way off in concluding that this would be a change to the parser?

--
nosy: +Phaqui

___
Python tracker 

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



Re: Python 3.8 install

2019-11-07 Thread Terry Reedy

On 11/7/2019 11:59 AM, MRAB wrote:

On 2019-11-07 13:52, Daniel wrote:

How to install Python 3.8 on top of Python 3.6?


Don't do that.

If you're using Windows, you install into a separate folder, usually 
called Python36 for Python 3.6 and Python38 for Python 3.8.


Both the Windows and macOS installers put each version in separate 
directories by default.  On Windows, I change the patch to my Python 
directory but leave the final directory name, Pythonxy, alone.  On 
macOS, I don't touch the path.


--
Terry Jan Reedy

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


[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-07 Thread Marco Sulla


Marco Sulla  added the comment:

When Python started to emulate the other languages?

Who cares about what other languages do? Python uses `raise` instead of 
`throw`, even if `throw` is much more popular in the most used languages, only 
because `raise` in English has more sense. 

And IMHO a newbie that see a multi-string in the code does not read the 
documentation. It's evident that is a multi-string. And it expects that it acts 
as in English or any other written language, that is the text is *that* one 
that (s)he read.

On the contrary, if (s)he reads 

d"""
   Marco
   Sulla
"""

maybe (s)he thinks "this must be something different", and read the docs.

--

___
Python tracker 

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



Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to 
"reference its [the function's] name" as an argument, however the point I was 
trying to make was that it isn't possible to pass a function that is either not 
in some way previously defined or a reference to something previously defined.

In your example, you still make reference to the existing function `truediv` 
from the `operator` library, even though the `partial` function does create a 
new function.

What I'm aiming for is the ability to, within a function call, pass a suite 
that would be there automatically defined by the compiler/interpreter. Another 
comment did mention lambda functions, which does to some degree provide that 
capability, but is restricted to well, lambda functions (only expressions, not 
statements).

Your example does however suggest the possibilities of a function or expression 
that creates functions. For example, the `function` expression in JavaScript.

```
//Definition
function myFoo (str1, str2, foo){
console.log( foo(str1), foo(str2) );
}


//Call
myFoo ("hello", "world!", function(str){

str[0] = str[0].toUpper();
return str;

});


Output:
Hello World!
```

However it does not seem that there would be any such expression in Python as 
is. In python, this code would be written:


```
#Definition
def myFoo (str1, str2, foo):
print( foo(str1), foo(str2) )


#Call
def other_foo(str):
str = list(str)[0].upper() + str[1:]
return str

myFoo ("hello", "world!", other_foo)

```


Here is it rewritten using the proposal:
```
#Definition
def myFoo (str1, str2, foo, str = " "):
print( foo(str = str1), foo(str = str2) )


#Call
myFoo ("hello", "world!"):
str = list(str)[0].upper() + str[1:]
return str

```

Of course this example presents only a minor, though you can see the difference 
in the call, in which no new function needs be referenced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to 
"reference its [the function's] name" as an argument, however the point I was 
trying to make was that you cannot pass a function that is either not in some 
way previously defined or a reference to something previously defined.

In your example, you still make reference to the existing function `truediv` 
from the `operator` library, even though the `partial` function does create a 
new function.

What I'm aiming for is the ability to, within a function call, pass a suite 
that would be there automatically defined by the compiler/interpreter. Another 
comment did mention lambda functions, which does to some degree provide that 
capability, but is restricted to well, lambda functions (only expressions, not 
statements).

Your example does however suggest the possibilities of a function or expression 
that creates functions. For example, the `function` expression in JavaScript.

```
//Definition
function myFoo (str1, str2, foo){
console.log( foo(str1), foo(str2) );
}


//Call
myFoo ("hello", "world!", function(str){

str[0] = str[0].toUpper();
return str;

});


Output:
Hello World!
```

However it does not seem that there would be any such expression in Python as 
is. In python, this code would be written:


```
#Definition
def myFoo (str1, str2, foo):
print( foo(str1), foo(str2) )


#Call
def other_foo(str):
str = list(str)[0].upper() + str[1:]
return str

myFoo ("hello", "world!", other_foo)

```


Here is it rewritten using the proposal:
```
#Definition
def myFoo (str1, str2, foo, str = " "):
print( foo(str = str1), foo(str = str2) )


#Call
myFoo ("hello", "world!"):
str = list(str)[0].upper() + str[1:]
return str

```

Of course this example presents only a minor, though you can see the difference 
in the call, in which no new function needs be referenced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.8 install

2019-11-07 Thread MRAB

On 2019-11-07 13:52, Daniel wrote:

How to install Python 3.8 on top of Python 3.6?


Don't do that.

If you're using Windows, you install into a separate folder, usually 
called Python36 for Python 3.6 and Python38 for Python 3.8.

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


[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Julia syntax looks well thought out, so I suggest to borrow it.

--

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2019-11-07 Thread Ben Reilly


Change by Ben Reilly :


--
nosy: +breilly_box

___
Python tracker 

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



[issue38707] Multiprocessing: bug with Native ID for threading.mainthread()

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

> See the branch here: 
> https://github.com/jaketesler/cpython/tree/fix-mp-native-id

Can you please create a PR?

--

___
Python tracker 

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



[issue36084] Threading: add builtin TID attribute to Thread objects

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

Jake created bpo-38707.

--

___
Python tracker 

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



[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

By the way, it's still possible to access directly ts->interp if you include 
"pycore_pystate.h" header, which requires to define Py_BUILD_CORE_MODULE. This 
header is an internal header.

--

___
Python tracker 

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



Re: return a ctypes object to C

2019-11-07 Thread Arnaud Loonstra

On 31-10-2019 15:39, Arnaud Loonstra wrote:

On 31-10-2019 14:44, Thomas Jollans wrote:

On 31/10/2019 14.13, Arnaud Loonstra wrote:

On 30-10-2019 09:32, Arnaud Loonstra wrote:

Hi all,

I'm trying to wrap my head around the ctypes API. I have a C
structure I wish to create in Python and then return from python to C.

So a python method is called from C and needs to return an object
which we then process in C again.

I have a binding to access and create the C methods and structures so
in Python I can call the Zmsg() constructor. I now need to return this.

My python test method is simply:

def actor_test( *args, **kwargs):
  print("test")
  msg = Zmsg()
  frame = Zframe(b"Hello", 5)
  msg.prepend(frame)
  return msg

the method is called from C as follows:

PyObject *pReturn = PyObject_CallObject(pFunc, NULL);

This correctly calls the method. However the returned object is of
course a PyObject*. The debugger says it's

""    PyObject
  [class]    ""
  [super class]    ""
  [meta type]    ""
  ob_refcnt    1    Py_ssize_t

However how I can I get it back to the original C type (zmsg_t *)

Any help really appreciated.



What I've found so far is that I can return the address of the ctypes
object.

msg = Zmsg()
frame = Zframe(b"Hello", 5)
msg.prepend(frame)
return addressof(msg._as_parameter_.contents)

In C I can then cast it back to the original type.

PyObject *pReturn = PyObject_CallObject(pFunc, NULL);
assert(pReturn);
long bla = PyLong_AsLong(pReturn);
zmsg_t* test = (zmsg_t *)bla;
assert(test);
char *hello = zmsg_popstr(test);
assert(hello);
assert(streq(hello, "Hello"));

This works, I'm not sure if this is the right way. It also creates a
complicated setup with the garbage collector.

Anybody better ideas?


You've already got a complicated setup with your ctypes objects...

If you're using the Python C API anyway, why would you use ctypes at
all? You can create custom Python types in C to wrap your C pointers.

Alternatively: if you're using ctypes anyway, why use the Python C API
at all? You can create C function pointers from Python functions with
ctypes.

If you're mixing two different ways of interfacing Python and C, the
result will ALWAYS be messy. Better to stick to one. Personally, I
prefer cffi or cython depending on the situation, as I find them clearer
and easier to use than ctypes. Using the Python C API directly is
usually the hardest to understand and the easiest to get wrong.

-- Thomas


Hi Thomas,

I have an engine running which can call handlers. These handlers return 
a zmsg_t (a message) which the engine then can process.


In this engine we have Python embedded and I want to use a Python method 
as a handler. To embed Python we need to use the Python C API. To 
construct a zmsg_t type in Python we need to call the corresponding C 
method and we use ctypes to do that.


I'm using a ctypes binding because it already exists, it's here: 
https://github.com/zeromq/czmq/blob/d6283985ba52fd8c3f8fbdc7cd5c08372ff69ca1/bindings/python/czmq/_czmq_ctypes.py#L4392 



I know I can use cffi for example but that's IMHO just a ctypes 
alternative.


Are you saying it's better to create some approach to create a zmsg_t 
using the Python C API?


Please enlighten me if this should be done differently.

Rg,

Arnaud


Ok, you're reply triggered me to do some more reading into the C-API. 
I've found I can do it all using the C-API. Especially this guide was 
very helpful for my situation:


https://docs.python.org/3/extending/newtypes_tutorial.html

Thnx,

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


[issue31842] pathlib: "Incorrect function" during resolve()

2019-11-07 Thread maciozo


maciozo  added the comment:

Same error occurs when attempting to resolve a path on an ImDisk RAM disk:

>>> pathlib.Path("T:\\").resolve()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\Users\maciozo\AppData\Local\Continuum\miniconda3\envs\brainboxes\lib\pathlib.py",
 line 1151, in resolve
s = self._flavour.resolve(self, strict=strict)
  File 
"C:\Users\maciozo\AppData\Local\Continuum\miniconda3\envs\brainboxes\lib\pathlib.py",
 line 202, in resolve
s = self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 1] Incorrect function: 'T:\\'

--
nosy: +maciozo

___
Python tracker 

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



[issue2986] difflib.SequenceMatcher not matching long sequences

2019-11-07 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +16592
pull_request: https://github.com/python/cpython/pull/17082

___
Python tracker 

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



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The user expects what they read in the documentation of what they learn in 
other programming languages. If we update the documentation their expectation 
will change.

As for other programming languages, Bash has an option for stripping all 
leading tab characters from a here document, and in Julia triple-quoted strings 
are dedented 
(https://docs.julialang.org/en/v1/manual/strings/#Triple-Quoted-String-Literals-1).
 Since Julia is a competitor of Python in science applications, I think that 
significant fraction of Python users expected Python triple-quoted strings be 
dedented too, especially if they are dedented by help() and other tools.

--

___
Python tracker 

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



[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

2019-11-07 Thread Fabio Zadrozny


Fabio Zadrozny  added the comment:

@Mark I don't want to change the original function code, I just want to change 
the code to be executed in the frame (i.e.: as breakpoints change things may be 
different).

Changing the actual function code is a no-go since changing the real function 
code can break valid user code.

--

___
Python tracker 

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



[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

2019-11-07 Thread Mark Shannon


Mark Shannon  added the comment:

Victor,
I don't think this is a regression.
`PyThreadState` is an internal opaque data structure, which means we are free 
to change it.
That the `eval_frame` is hard to access is a feature not a bug, as it 
discourages misuse and enables us to remove it easily, when a better approach 
becomes available.

PEP 523 is quite vague, but the rationale indicates that exposing `eval_frame` 
is for "a method-level JIT". PEP 523 did not suggest adding an API. If it had 
(and I had had the time) I would have opposed it more vigorously.

IMO, the correct way to change the code object is to set `function.__code__` 
which can be done easily from either Python or C code.

@Fabioz, is there anything preventing you from doing that?

--

___
Python tracker 

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



[issue36876] Global C variables are a problem.

2019-11-07 Thread Chih-Hsuan Yen


Change by Chih-Hsuan Yen :


--
nosy:  -yan12125

___
Python tracker 

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



[issue38613] Optimize some set operations in dictkeys object

2019-11-07 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 6cbc84fb99acb33dd659d7adb29a20adbe62b74a by Inada Naoki in branch 
'master':
bpo-38613: Optimize set operations of dict keys. (GH-16961)
https://github.com/python/cpython/commit/6cbc84fb99acb33dd659d7adb29a20adbe62b74a


--

___
Python tracker 

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



[issue38613] Optimize some set operations in dictkeys object

2019-11-07 Thread Inada Naoki


Change by Inada Naoki :


--
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: SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-07 Thread Grant Edwards
On 2019-11-07, Jon Ribbens via Python-list  wrote:
> On 2019-11-07, Veek M  wrote:
>> Could someone suggest some introductory reading material that will allow 
>> me to use 'telnetlib' with 'ssl' or 'ssltelnet'. 
>> (currently using Pan since Knode is dropped on Debian)
>>
>> I'm trying to write something that will download the NNTP headers
>> over TLS.
>
> As someone else has pointed out, nntplib would be the obvious choice
> for this. But even if you don't want to use that, you absolutely
> should not be using telnetlib. NNTP is not Telnet and there is no
> connection between the two protocols. (Don't get misled by the common
> practice of using the command-line telnet client as a convenient way
> for connecting to line-based TCP services for testing purposes.)

IIRC, the reason that you could test stuff like NNTP servers using the
old Unix telnet client is because that client defaults to disabling
all of the actual TELNET protocol and handshaking support when
connected to a port other than 23.

-- 
Grant Edwards   grant.b.edwardsYow! PARDON me, am I
  at   speaking ENGLISH?
  gmail.com

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


[issue38736] argparse: wrong type from get_default when type is set

2019-11-07 Thread Erik Ahlén

New submission from Erik Ahlén :

The type of the object returned by get_default isn't converted to the specified 
type supplied to add_argument. I would expect the type to be the same.

--
components: Library (Lib)
files: test.py
messages: 356194
nosy: Erik Ahlén
priority: normal
severity: normal
status: open
title: argparse: wrong type from get_default when type is set
type: enhancement
versions: Python 3.7
Added file: https://bugs.python.org/file48700/test.py

___
Python tracker 

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



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-07 Thread Marco Sulla


Marco Sulla  added the comment:

Excuse me for the spam, but against make it the default behavior I have a 
simple consideration: what will expect a person that reads the code, that 
doesn't know Python?

IMHO it expects that the string is *exactly* like it's written. The fact that 
it will be de-dented it's a bit surprising.

For readability and for not breaking old code, I continue to be in favor of a 
letter before the multi-string. Maybe `d`, for de-dent, it's more appropriate 
than `t`, since it does not only trim the string.

But probably there's a better solution than the letter.

--

___
Python tracker 

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



[issue38730] 2.7 modern compiler warnings

2019-11-07 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 9f94e52e8d38092520a3bfb1bf1ef9cbb0836584 by Benjamin Peterson in 
branch '2.7':
bpo-38730: Remove usage of stpncpy as it's not supported on MSVC 2008. 
(GH-17081)
https://github.com/python/cpython/commit/9f94e52e8d38092520a3bfb1bf1ef9cbb0836584


--

___
Python tracker 

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



[issue38730] 2.7 modern compiler warnings

2019-11-07 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
pull_requests: +16591
pull_request: https://github.com/python/cpython/pull/17081

___
Python tracker 

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



[issue38730] 2.7 modern compiler warnings

2019-11-07 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset f32bcf8c27f3681407707bbb029323eb340d3c4b by Benjamin Peterson in 
branch '2.7':
[2.7] bpo-38730: Fix -Wstringop-truncation warnings. (GH-17075)
https://github.com/python/cpython/commit/f32bcf8c27f3681407707bbb029323eb340d3c4b


--

___
Python tracker 

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



[issue38661] Changes to tkinter result in (unexpected) widget map call return changes wrt. 3.7

2019-11-07 Thread Juliette Monsel


Change by Juliette Monsel :


--
nosy: +j-4321-i

___
Python tracker 

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



Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Antoon Pardon
On 7/11/19 14:36, Stephen Waldron wrote:
> Hi, I'm new to the group and to Python, so forgive me if I make any faux-pas 
> here. As I can tell, the only way to pass a function as an argument is to 
> reference its name as follows:
>
> def foo1(message):
> print(message)
>
> def foo2(foo, message):
> print("Your function says:")
> foo(message)

No that is not true. "map" is a function that takes a function as its
first argument. But I can do the following if I want to produce the
inverses of a list of numbers.

from operator import truediv
from functools import partial

ls = range(1, 11)

for x in map(partial(truediv, 1), ls):
print(x)

In the code above "partial(truediv, 1)" will produce a function that
will inverse its argument and I don't need to give this function a name
to pass it as an argument in an other function.

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


Re: psutil.boot_time() ... doesn't ?

2019-11-07 Thread R.Wieser
Chris,

> Yes, but even if it's not recorded as a timestamp but as an
> uptime counter, that counter can be referenced against the
> current time in UTC.

Absolutily.   Though the keyword here is "can".  My "could easily imagine"
considers the other possibility.

I guess I should sit down sometime and just flip the date back and forward
(in-and-outof DST), and see how the result of psutil.boot_time() compares to
the thanwhile current time.

Regards,
Rudy Wieser


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


Python 3.8 install

2019-11-07 Thread Daniel

How to install Python 3.8 on top of Python 3.6?

--
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus

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


Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Hi, I'm new to the group and to Python, so forgive me if I make any faux-pas 
here. As I can tell, the only way to pass a function as an argument is to 
reference its name as follows:

def foo1(message):
print(message)

def foo2(foo, message):
print("Your function says:")
foo(message)


>>foo2(foo1, "Hello World!")
Your function says:
Hello World!


This is how it is at the moment, however it may be more agreeable, especially 
if that is the only purpose of the function, for python users to be able to 
define new functions inside of function calls. The way I propose this may occur 
is using similar syntax as control structures, as exampled below:

def foo2(foo):
print("Message to print:", end = " ")
foo()


>>foo2():
print("Hello World!")

Message to print: Hello World!


In this proposal, it should be noted, that unlike control structures, the 
brackets are required for the function call. The "suite" or "annex" is defined 
as a function object by the compiler and passed inside the call. Here are some 
other examples of the proposal.



*Non-Function Arguments with Annexed Functions*
Non-Function Arguments should be placed in the brackets before annexed 
functions, and this should be reflected in the parameter order. If they are 
not, they won't be assigned to, which would cause an error unless a default 
value is given. These parameters could be available for passing in the annexed 
function if mentioned when the paramaeter is called.

def myFoo (num1, num2, foo):
return foo (num1, num2)


>>myFoo(20, 30):
return num1 + num2

50


*Annexing Multiple Functions or Out of Order Annex*
To specify the order in which functions are annexed, or annex multiple 
functions, one could use the parameter name before the specific suite.

class Book:
def __init__(self, name, author):
self.name = name
self.author = author


def doToBooks (bookList, first, then, book = None):

for book in bookList
first(book = book)
then(book = book)

myBooks = [
Book("The Way of the World", "Lucy Cole"),
Book("To Live or To Love", "Georgio Dunham"),
Book("Twelve Days of Success", "Anita Duvette")
]

doToBooks (myBooks):
print(book.name)
then:
print(" - " + book.author + "\n")



>
The Way of The World
 - Lucy Cole

To Live or To Die
 - Georgio Dunham

Twelve Days of Success
 - Anita Duvette



This proposal does not detract from the core appearance and appeal of Python 
while creating an option for users and module makers who want themselves or the 
users of their modules not to have to previously define functions in order to 
use the code. This would make such code more aesthetic and compact, and take 
away the need for defining a new function, name and all, specifically for such 
which ultimately would be used only once as an argument. 
   
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38732] Adding relp support as a new logging handler

2019-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:

Why does this need to be in the stdlib, useful though it may be for some use 
cases? As I understand it, RELP is mainly for communication between rsyslog 
servers, not specifically/especially for client-rsyslog communication. From the 
PyRELP link you posted, that library doesn't seem to support Python 3.x. Also, 
the fact that it relies on an optional OS package (librelp) makes it unsuitable 
for inclusion in the stdlib.

--
resolution:  -> rejected
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



[issue38716] logging: rotating handlers set namer and rotator null

2019-11-07 Thread Vinay Sajip


Change by Vinay Sajip :


--
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



[issue38735] PYTHONPYCACHEPREFIX fails when importing a module from the root ("/")

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

The bug occurs on this line:

if sys.pycache_prefix is not None:
if not _path_isabs(head):
head = _path_join(_os.getcwd(), head)
if head[1] == ':' and head[0] not in path_separators: # < HERE
head = head[2:]
...

I guess that head="/" in your case: so head[1] raises an IndexError.

--
nosy: +vstinner

___
Python tracker 

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



Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-07 Thread Gregory Ewing

Oscar Benjamin wrote:

In Python the original exception message plus traceback is often very
informative (to a programmer!) about the problem.


That's okay, exception chaining preserves the whole traceback if
you want to dig down that far.


Catching and
reraising can mean that you end up crafting an error message somewhere
higher up where the filename isn't known any more.


Well, the idea is to catch it some place where the filename *is*
known. And when reraising, only add to the error message rather
than replacing it altogether, so once the filename is in there
it stays there, even if another catch-and-reraise occurs higher
up.

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


[issue38735] PYTHONPYCACHEPREFIX fails when importing a module from the root ("/")

2019-11-07 Thread Ned Batchelder


New submission from Ned Batchelder :

On the manylinux docker images, the current directory is "/".

If I create a file there and try to import it with PYTHONPYCACHEPREFIX set, I 
get a stack trace:

$ docker run -it --init --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 bash
[root@29d75403d7d1 /]# cat > foo.py
a = 1
[root@29d75403d7d1 /]# /opt/python/cp38-cp38/bin/python
Python 3.8.0 (default, Oct 30 2019, 22:13:22)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.a
1
>>>
[root@29d75403d7d1 /]# PYTHONPYCACHEPREFIX=/opt/pyc 
/opt/python/cp38-cp38/bin/python
Python 3.8.0 (default, Oct 30 2019, 22:13:22)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 991, in _find_and_load
  File "", line 975, in _find_and_load_unlocked
  File "", line 657, in _load_unlocked
  File "", line 562, in module_from_spec
  File "", line 541, in _init_module_attrs
  File "", line 382, in cached
  File "", line 427, in _get_cached
  File "", line 352, in cache_from_source
IndexError: string index out of range
>>>

--
messages: 356188
nosy: nedbat
priority: normal
severity: normal
status: open
title: PYTHONPYCACHEPREFIX fails when importing a module from the root ("/")

___
Python tracker 

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



Re: How execute at least two python files at once when imported?

2019-11-07 Thread Gregory Ewing

Cameron Simpson wrote:
Spencer's modules run unconditional stuff in addition to defining 
classes. That may cause trouble.


It will -- because of the import lock, they won't run simultaneously
in the same process.

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


[issue38733] PyErr_Occurred(): tstate must be non-NULL

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

I merged my change, I close the issue.

The change is a little bit backward incompatible, so I prefer to not backport 
it. PyErr_Occurred() checks tstate==NULL for 9 years, there is no urgency to 
change it :-) It can wait for Python 3.9.

--
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



[issue38733] PyErr_Occurred(): tstate must be non-NULL

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

In 2018 with bpo-26558, I fixed Py_FatalError() to no longer access the current 
exception of the current Python thread state, if the current thread doesn't not 
hold the GIL:

commit 3a228ab17c2a9cffd1a2f15f30d6209768de20a6
Author: Victor Stinner 
Date:   Thu Nov 1 00:26:41 2018 +0100

bpo-26558: Fix Py_FatalError() with GIL released (GH-10267)

Don't call _Py_FatalError_PrintExc() nor flush_std_files() if the
current thread doesn't hold the GIL, or if the current thread
has no Python state thread.


Extract of Py_FatalError() code:

/* Check if the current thread has a Python thread state
   and holds the GIL.

   tss_tstate is NULL if Py_FatalError() is called from a C thread which
   has no Python thread state.

   tss_tstate != tstate if the current Python thread does not hold the GIL.
   */
PyThreadState *tss_tstate = PyGILState_GetThisThreadState();
int has_tstate_and_gil = (tss_tstate != NULL && tss_tstate == tstate);
if (has_tstate_and_gil) {
/* If an exception is set, print the exception with its traceback */
if (!_Py_FatalError_PrintExc(fd)) {
/* No exception is set, or an exception is set without traceback */
_Py_FatalError_DumpTracebacks(fd, interp, tss_tstate);
}
}
else {
_Py_FatalError_DumpTracebacks(fd, interp, tss_tstate);
}

--

___
Python tracker 

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



[issue38733] PyErr_Occurred(): tstate must be non-NULL

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d12d0e7c0fe2b49c40ac4d66365147c619d6c475 by Victor Stinner in 
branch 'master':
bpo-38733: PyErr_Occurred() caller must hold the GIL (GH-17080)
https://github.com/python/cpython/commit/d12d0e7c0fe2b49c40ac4d66365147c619d6c475


--

___
Python tracker 

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



[issue3605] Py_FatalError causes infinite loop

2019-11-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d12d0e7c0fe2b49c40ac4d66365147c619d6c475 by Victor Stinner in 
branch 'master':
bpo-38733: PyErr_Occurred() caller must hold the GIL (GH-17080)
https://github.com/python/cpython/commit/d12d0e7c0fe2b49c40ac4d66365147c619d6c475


--

___
Python tracker 

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



Re: SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-07 Thread Jon Ribbens via Python-list
On 2019-11-07, Veek M  wrote:
> Could someone suggest some introductory reading material that will allow 
> me to use 'telnetlib' with 'ssl' or 'ssltelnet'. 
> (currently using Pan since Knode is dropped on Debian)
>
> I'm trying to write something that will download the NNTP headers over 
> TLS.

As someone else has pointed out, nntplib would be the obvious choice
for this. But even if you don't want to use that, you absolutely
should not be using telnetlib. NNTP is not Telnet and there is no
connection between the two protocols. (Don't get misled by the common
practice of using the command-line telnet client as a convenient way
for connecting to line-based TCP services for testing purposes.)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38733] PyErr_Occurred(): tstate must be non-NULL

2019-11-07 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +16589
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17080

___
Python tracker 

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



[issue3605] Py_FatalError causes infinite loop

2019-11-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +16590
pull_request: https://github.com/python/cpython/pull/17080

___
Python tracker 

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



[issue38734] Python 3.7 and 3.8 in Windows Store do not start under git bash

2019-11-07 Thread Paul Anton Letnes


New submission from Paul Anton Letnes :

Python 3.7 and 3.8 installed from the  Windows Store do not start under git 
bash. Rather, they give some variation of this error message:

bash: /c/Users/pa/AppData/Local/Microsoft/WindowsApps/python: Permission denied

However, the permissions are rwxr-xr-x, or 755 if you prefer. The same error 
occurs if I try to run pip.

How can I run python under git bash? I use python and various pip-installed 
executables (e.g. black) for git hooks, so this has to work for my workflow.

--
components: Windows
messages: 356183
nosy: paul.moore, pletnes, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Python 3.7 and 3.8 in Windows Store do not start under git bash
type: crash
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



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-07 Thread Marco Sulla


Marco Sulla  added the comment:

Anyway there's something strange in string escaping and `inspect.cleandoc()`:

>>> a = """
... \nciao
... bello
... \ ciao
... """
>>> print(inspect.cleandoc(a))
ciao
bello
\ ciao
>>> print("\ ciao")
\ ciao

I expected:

>>> print(inspect.cleandoc(a))

ciao
bello
 ciao
>>> print("\ ciao")
 ciao

--

___
Python tracker 

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



Re: SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-07 Thread Colin McPhail via Python-list



> On 7 Nov 2019, at 03:24, Veek M  wrote:
> 
> Could someone suggest some introductory reading material that will allow 
> me to use 'telnetlib' with 'ssl' or 'ssltelnet'. 
> (currently using Pan since Knode is dropped on Debian)
> 
> I'm trying to write something that will download the NNTP headers over 
> TLS.
> 
> The idea is to 
> 1. telnet to port 119, send 'CAPABILITIES\r\n' using telnetlib
> 2. then switch to TLS using STARTTLS
> 3. I tried just connecting to port 119 using a new TLS connection NOT 
> OVER telnet and it didn't work. Apparently you need to pass the TLS 
> context to telnetlib or vice versa.
> ...

Any reason you're not using nntplib from the Python Standard Library? It 
supports the  STARTTLS command.

If you don't want to use nntplib you could look at its code to see how it works.

-- Colin

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


[issue36876] Global C variables are a problem.

2019-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 9def81aa52adc3cc89554156e40742cf17312825 by Vinay Sajip in branch 
'master':
bpo-36876: Moved Parser/listnode.c statics to interpreter state. (GH-16328)
https://github.com/python/cpython/commit/9def81aa52adc3cc89554156e40742cf17312825


--

___
Python tracker 

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



[issue38733] PyErr_Occurred(): tstate must be non-NULL

2019-11-07 Thread STINNER Victor


New submission from STINNER Victor :

bpo-3605 modified PyErr_Occurred() to return NULL if the current Python thread 
state ("tstate") is NULL:

commit 8e0bdfd1d473ddffaf3501768678f8a970019da8
Author: Jeffrey Yasskin 
Date:   Thu May 13 18:31:05 2010 +

Make PyErr_Occurred return NULL if there is no current thread.  Previously 
it
would Py_FatalError, which called PyErr_Occurred, resulting in a 
semi-infinite
recursion.

Fixes issue 3605.

This change made PyErr_Occurred() inefficient: PyErr_Occurred() was a simple 
attribute read (tstate->curexc_type), and now there is an additional if per 
call.

I recently added _PyErr_Occurred(tstate) which is similar to PyErr_Occurred() 
but requires to pass tstate explicitly. I expected this function to be as 
simple as:

static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
{
return tstate->curexc_type;
}

but the current implementation is:

static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
{
return tstate == NULL ? NULL : tstate->curexc_type;
}


--

PyErr_Occurred() is currently implemented as:

PyObject* _Py_HOT_FUNCTION
PyErr_Occurred(void)
{
PyThreadState *tstate = _PyThreadState_GET();
return _PyErr_Occurred(tstate);
}

_PyThreadState_GET() must only be called with the GIL hold. This macro is 
designed to be efficient: it doesn't check if tstate is NULL.

_PyThreadState_GET() is only NULL if the thread has no Python thread state yet, 
or if the GIL is released.

IMHO PyErr_Occurred() must not be called if the GIL is released.

--
components: Interpreter Core
messages: 356180
nosy: vstinner
priority: normal
severity: normal
status: open
title: PyErr_Occurred(): tstate must be non-NULL
versions: Python 3.9

___
Python tracker 

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



Re: psutil.boot_time() ... doesn't ?

2019-11-07 Thread R.Wieser
Dennis,

> Which is probably... last file system modification time

Nope.  Its from a file it saves at shutdown, and which gets updated once an 
hour (I also thought of that one, but the once-an-hour update threw a wrench 
into it).

> There is no way for a freshly booted system to differentiate between
[snip]

True.   But
1) thats not likely the moment I will be looking at the "has the time been 
updated"
2) The same goes for having NTP (or any other such "wait for it ..." method) 
update the clock.

> Except that "last boot time" is really "booted /n/ minutes ago
> from /now/".

Than thats the point where we disagree.   Boot time is not just a gadget for 
the user to look and gawk at, it has (or /should/ have) its usages.   Like 
allowing someone to determine which files have been altered since last boot.

Besides, all you now get is uptime, just presented differently.  :-(

> http://man7.org/linux/man-pages/man5/crontab.5.html#EXTENSIONS
>
> The main concern is just how soon after reboot that @reboot executes.

Yup.  And in which order the different programs and scripts are ran 

> https://www.cyberciti.biz/faq/linux-execute-cron-job-after-system-reboot/
> has an example with a sleep...

Thanks for those links.  I'll have a look at them.

Regards,
Rudy Wieser


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


[issue38706] What should the error message in the exception raised by assertTrue and assertFalse be?

2019-11-07 Thread Petr Viktorin

Petr Viktorin  added the comment:

Generally, „true“ and „false“ refer to „truthiness“, while the actual ``True`` 
and ``False`` literals should be capitalized. And in monospace font if possible.

I think this is a good convention, but it's quite subtle, and I don't think 
it's explicitly mentioned in the docs.

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue38731] bad input crashes py_compile library

2019-11-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +nanjekyejoannah

___
Python tracker 

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



[issue38732] Adding relp support as a new logging handler

2019-11-07 Thread Ned Deily


Change by Ned Deily :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue38732] Adding relp support as a new logging handler

2019-11-07 Thread Marco


New submission from Marco :

Hello, a pyrelp module was released to send messages over RELP to a RELP 
server, such as rsylog:

   https://github.com/mathias-nyman/pyrelp
   https://github.com/rsyslog/librelp

It should be very useful the possibility to add this feature as a logging 
handler.

A SyslogHandler already exists, but it support only normal TCP. You could add 
the RELP support.

Thank you to consider this.

--
components: Extension Modules
messages: 356178
nosy: falon
priority: normal
severity: normal
status: open
title: Adding relp support as a new logging handler
type: enhancement
versions: Python 3.9

___
Python tracker 

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



OT language barrier, was: How execute at least two python files at once when imported?

2019-11-07 Thread Christian Gollwitzer

Am 06.11.19 um 17:34 schrieb Igor Korot:

On Wed, Nov 6, 2019 at 10:22 AM Spencer Du  wrote:



Sorry if I haven't stated my requirements clearly.

I just wanted a way to import at least two python files in parallel and I 
wanted to know how this can be done or a reason why its bad as stated in 
another post.


This is not a requirements.

Let me rephrase my question - what problem are you trying to solve?

Also, as I said before - I believe there is a language barrier.

Find some python forum in your native language and ask your question there.



Off topic, but how do you conclude that the OP is a non-native English 
speaker or has inferior command of the English language? He sounds very 
English to me, and the name and email address also do not indicate 
non-English origin to me?


My impression was that there IS a language barrier for technical terms, 
but not with English per se - he used the word "import" incorrectly, 
when he meant "run", because he abused "import lala" to run a Python 
program.


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


[issue38731] bad input crashes py_compile library

2019-11-07 Thread Berker Peksag


Change by Berker Peksag :


--
nosy: +berker.peksag
stage:  -> needs patch
type: crash -> behavior
versions: +Python 3.9

___
Python tracker 

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



  1   2   >