[issue46256] Objects __del__ called after module have been removed

2022-01-06 Thread Christopher Vickery


Christopher Vickery  added the comment:

This it very clear and totally consistent with the observed behavior. I can 
think of a couple of workarounds for my app (move the db access from module 
initialization to a function that gets invoked "on demand", or redirect 
sys.stderr to /dev/null just before exiting).

Perhaps the Psycopg team can deal with it more directly.

Many thanks to all for the time and effort taken to make clear what's happening!

--

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



[issue46256] Objects __del__ called after module have been removed

2022-01-05 Thread Christopher Vickery


Christopher Vickery  added the comment:

The app has to open a db connection during module initialization to trigger the 
problem, so I can't provide a self-contained way to reproduce the problem.

The closest I can come is the attached file, format_rules_annotated.py.

With lines 66-69 in place, the problem occurs, even if there are no command 
line arguments, with Python 3.10, but not with Python 3.9. If I comment out 
lines 66-69 there is no problem with either 3.10 or 3.9, even if I add a 
command line argument that causes connections to be opened within functions 
defined within the module. (I added the explicit initialization of the 
institution_names dict so I could test those function calls without accessing 
the db during module initialization.)

FWIW, here is an execution under 3.10 with lines 66-69 commented out:

$ python -m format_rules_annotated -r QCC01:QNS01:PH:35
QCC01:QNS01:PH:35
C- or above in PH 101 at Queensborough, 4.0 credits, transfers to Queens as 
PHYS-11 and PHYS-14, 4.0 credits.
[No "Exception ignored" message appears here because db was not accessed during 
module initialization]
$

--
Added file: https://bugs.python.org/file50542/format_rules_annotated.py

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



[issue46256] Objects __del__ called after module have been removed

2022-01-04 Thread Christopher Vickery


Christopher Vickery  added the comment:

If the attached module is run with no command line arguments, it will reproduce 
the problem without doing anything else. When run using Python 3.9 it does not 
cause the problem. (This module comes from 
https://github.com/cvickery/transfer-app, with an unnecessary import commented 
out.)

--
nosy: +cvickery
Added file: https://bugs.python.org/file50540/format_rules.py

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



[issue37701] shutil.copyfile raises SpecialFileError for symlink to fifo

2021-12-14 Thread Christopher Hunt


Christopher Hunt  added the comment:

> I expect it to fail if follow_symlinks is True, which is the default value. I 
> expect it to succeed with follow_symlinks=False, which should create a 
> shallow copy of just the symlink, regardless of its target.

I agree, thanks for the correction.

--

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



[issue45159] data_received called on protocol after call to pause_reading on ssl transport

2021-09-09 Thread Christopher Brichford


New submission from Christopher Brichford :

An SSL connection created with loop.create_connection may have data_received 
called on its protocol after pause_reading has been called on the transport.

If an application has a protocol whose data_received method calls pause_reading 
on the transport then there is a chance that the data_received method will be 
called again before the application calls resume_reading on the transport.

That existing implementation of pause_reading at:
https://github.com/python/cpython/blob/62fa613f6a6e872723505ee9d56242c31a654a9d/Lib/asyncio/sslproto.py#L335

calls pause_reading on the underlying socket transport, which is correct.  
However, there is a loop in the SSLProtocol's data_received method:
https://github.com/python/cpython/blob/62fa613f6a6e872723505ee9d56242c31a654a9d/Lib/asyncio/sslproto.py#L335

If the loop referenced above has more than one iteration then there is a chance 
that the application protocol's data_received method could call pause_reading 
on the transport.  If that happens on any iteration of the loop other than the 
last iteration, then the SSLProtocol's data_received method will call the 
application protocol's data_received method when it should not.

Stealing uvloop's asyncio ssl implementation would resolve this bug: 
https://bugs.python.org/issue44011

--
components: asyncio
messages: 401553
nosy: asvetlov, chrisb2, yselivanov
priority: normal
severity: normal
status: open
title: data_received called on protocol after call to pause_reading on ssl 
transport
type: behavior
versions: Python 3.10

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



[issue43511] tkinter with Tk 8.6.11 is slow on macOS

2021-03-25 Thread Christopher A. Chavez


Change by Christopher A. Chavez :


--
nosy: +chrstphrchvz

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



[issue42122] macOS complains about how fonts are accessed

2020-12-19 Thread Christopher A. Chavez


Christopher A. Chavez  added the comment:

This was already reported to Tcl/Tk: 
https://core.tcl-lang.org/tk/info/855049e799 . They determined it was caused by 
a bug in macOS 10.15.1. There are workarounds implemented for this in Tcl/Tk 
8.6.10 and the upcoming 8.6.11 releases.

--
nosy: +chrstphrchvz

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



[issue42480] Python Tkinter crashes on macOS 11.1 beta

2020-11-28 Thread Christopher Snowhill


Christopher Snowhill  added the comment:

That command also crashes with the same error. And I already verified with 
otool -L on the tkinter shared object file that it does indeed link the 
/System/Library/Frameworks version of both Tcl and Tk.

In fact, if I remember correctly, Homebrew's entire stance is to import and 
build as little as possible, always preferring to link to system bundled 
frameworks, no matter what. Maybe they'll rethink this one.

--

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



[issue42480] Python Tkinter crashes on macOS 11.1 beta

2020-11-28 Thread Christopher Snowhill


Christopher Snowhill  added the comment:

Sorry about that. I didn't know that Big Sur support wasn't added until 
post-3.9.0. I'll check if Brew has a newer version now, and even if not, if I 
can install a Git version for testing.

Incidentally, the error is occuring inside either the Tk or Tcl frameworks, and 
it's not a version that Brew supplies. Like the system copies of Python 2 and 
3, Brew links its builds against the system Tcl and Tk frameworks, which appear 
to have some bugs in the beta.

Thanks for testing, though.

--

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



[issue42480] Python Tkinter crashes on macOS 11.1 beta

2020-11-28 Thread Christopher Snowhill


Christopher Snowhill  added the comment:

And I can't report it to Homebrew, either, since they refuse to acknowledge bug 
reports against beta versions of the OS. I guess I can bug them when 11.1 
becomes a stable release, by which time I'll probably be on 11.2.

I'll file Feedback with Apple, too, as they're more likely to actually know 
what's going on.

--

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



[issue42480] Python Tkinter crashes on macOS 11.1 beta

2020-11-27 Thread Christopher Snowhill


New submission from Christopher Snowhill :

The Tkinter module, in a freshly built copy of Python 3.9 built by Brew, using 
the latest Xcode 12.3 command line tools, crashes on Big Sur 11.1 beta. It 
emits the following error:

macOS 11 or later required !

I believe I recently read on macOS developer documentation, there is a special 
behavior in the system version reporting now, possibly only taking effect in 
11.1 and newer. Basically, if you query the major version first, you'll get 11 
or higher. If you query the minor version first, it will switch on 
compatibility mode and start reporting either 10.15 or 10.16, I'm not terribly 
sure which, but it does lie and say it's running version 10.

--
components: Tkinter
messages: 381933
nosy: kode54
priority: normal
severity: normal
status: open
title: Python Tkinter crashes on macOS 11.1 beta
type: crash
versions: Python 3.9

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



[issue42394] Exception handling on boolean comparisons

2020-11-17 Thread Christopher Contaxis


New submission from Christopher Contaxis :

Python 3.8.6 will not produce an exception when comparing values in an and/or 
statement that normally produces an exception standalone.

val = 0
low = 1
high = "2"

The following makes sense:

val >= low : False
val <= high : Exception, cant compare int and str
val <= high and val >= low : Exception, cant compare int and str

The following doesn't make sense (doesn't produce an exception):

val >= low and val <= high : False

--
messages: 381289
nosy: CanisUrsa
priority: normal
severity: normal
status: open
title: Exception handling on boolean comparisons
type: behavior
versions: Python 3.8

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



[issue40592] `Shutil.which` incosistent with windows's `where`

2020-10-22 Thread Christopher Marchfelder


Christopher Marchfelder  added the comment:

@steve.dower Your advice did it, is fixed and green! :) Thank you again

--

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



[issue40592] `Shutil.which` incosistent with windows's `where`

2020-10-21 Thread Christopher Marchfelder


Christopher Marchfelder  added the comment:

@steve.dower Added the changes in the PR - could you please re-check? Thank you!

--

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



[issue41862] can not open file in system folder

2020-09-25 Thread Christopher Reilly


New submission from Christopher Reilly :

I am trying to load a Windows dll "ibfs64.dll" located in the 
C:\Windows\System32 folder:

ctypes.windll.LoadLibrary('ibfs64.dll')

When I attempt this call with Python 3.8.5 downloaded from python.org, the call 
fails with 

> FileNotFoundError: Could not find module 'ibfs64.dll' (or one of its 
> dependencies). Try using the full path with constructor syntax.

The function call, however, succeeds in Python 3.7.9 (downloaded from 
python.org). This behavior (3.7.9 works, 3.8.5 does not), has been duplicated 
by another user on two different Windows 10 machines (my machine is also 
Windows 10).

Another piece of information is that this function call also succeeds in 
anaconda environments running Python 3.7.9 and Python 3.8.5.

When I use the dll-diagnostics tracing utility 
(https://pypi.org/project/dll-diagnostics/) with the anaconda-managed Python 
3.8.5 installation, it succeeds:

> DLL Diagnostic Tools version 0.0.3
> Copyright (c) 2019 Adam Rehn
> 
> Parsing module header and detecting architecture... done.
> 
> Identifying the module's delay-loaded dependencies... done.
> 
> Parsed module details: Module:  C:\Windows\System32\ibfs64.dll
> Type:Dynamic-Link Library Architecture:x64
> 
> The module imports 0 delay-loaded dependencies:
> 
> 
> Performing LoadLibrary() trace for C:\Windows\System32\ibfs64.dll...
> Done.
> 
> Summary of LdrLoadDll calls: C:\Windows\System32\ibfs64.dllLoaded
> successfully
> 
> Summary of LdrpLoadDllInternal calls: C:\Windows\System32\ibfs64.dll  
> Loaded successfully NTDLL.DLL Loaded
> successfully
> 
> Summary of LdrpMinimalMapModule calls:
> C:\Windows\System32\ADVAPI32.dll  
> Mapped successfully C:\Windows\System32\ibfs64.dll
> Mapped successfully C:\Windows\System32\msvcrt.dll
> Mapped successfully C:\Windows\System32\RPCRT4.dll
> Mapped successfully C:\Windows\System32\sechost.dll   
> Mapped successfully
> C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.9672_none_88e266cb2fac7c0d\MSVCR80.dll
> Mapped successfully
> 
> Summary of LdrpResolveDllName calls: ibfs64.dll
> C:\Windows\System32\ibfs64.dll MSVCR80.dll   
> C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.9672_none_88e266cb2fac7c0d\MSVCR80.dll

But when I try it with the Python 3.8.5 installed from python.org, it fails:

> DLL Diagnostic Tools version 0.0.3
> Copyright (c) 2019 Adam Rehn
> 
> Parsing module header and detecting architecture... Traceback (most recent 
> call last):
> 
> File "c:\users\chris\appdata\local\programs\python\python38-32\lib\runpy.py", 
> line 194, in _run_module_as_main
> 
> return _run_code(code, main_globals, None,
>  
> File "c:\users\chris\appdata\local\programs\python\python38-32\lib\runpy.py", 
> line 87, in _run_code
> 
> exec(code, run_globals)
> 
> File 
> "C:\Users\Chris\AppData\Local\Programs\Python\Python38-32\Scripts\dlldiag.exe\__main__.py",
>  line 7, in 
> 
> File 
> "c:\users\chris\appdata\local\programs\python\python38-32\lib\site-packages\dlldiag\main.py",
>  line 29, in main
> 
> subcommands[subcommand]['function']()
> 
> File 
> "c:\users\chris\appdata\local\programs\python\python38-32\lib\site-packages\dlldiag\subcommands\trace.py",
>  line 188, in trace
> 
> header = ModuleHeader(args.module)
> 
> File 
> "c:\users\chris\appdata\local\programs\python\python38-32\lib\site-packages\dlldiag\common\ModuleHeader.py",
>  line 14, in __init__
> 
> self._pe = pefile.PE(module, fast_load=True)
> 
> File 
> "c:\users\chris\appdata\local\programs\python\python38-32\lib\site-packages\pefile.py",
>  line 1754, in __init__
> 
> self.__parse__(name, data, fast_load)
> 
> File 
> "c:\users\chris\appdata\local\programs\python\python38-32\lib\site-packages\pefile.py",
>  line 1797, in __parse__
> 
> stat = os.stat(fname)
> 
> FileNotFoundError: [WinError 2] The system cannot find the file specified: 
> 'C:\\Windows\\system32\\ibfs64.dll'

In fact, I can not even open the file in the python.org installation of Python 
3.8.5, while I can in the python.org installation of Python 3.7.9. In other 
words, the command

open(r'C:\Windows\System32\ibfs64.dll','r')

succeeds with the python.org installation of Python 3.7.9, but fails (same 
FileNotFoundError) with version Python 3.8.5. 

What is the anaconda-managed installation doing differently? Why is the Python 
3.7.9 installation from python.org successful while the 3.8.5 installation is 

[issue41419] Path.mkdir and os.mkdir don't respect setgid if its parent is g-s

2020-07-28 Thread Christopher Harrison


New submission from Christopher Harrison :

The setgid bit is not set when creating a directory, even when explicitly 
specified in the mode argument, when its containing directory doesn't have its 
own setgid bit set. When the parent does have the setgid bit, it works as 
expected.

Steps to reproduce:

1. Outside of Python, create a working directory with mode 0770, such that:

   >>> from pathlib import Path
   >>> oct(Path().stat().st_mode)
   '0o40770'

2. Set the umask to 0, to be sure it's not a masking issue:

   >>> import os
   >>> _ = os.umask(0)

3. Create a subdirectory with mode ug+rwx,g+s (2770):

   >>> (test := Path("test")).mkdir(0o2770)
   >>> oct(test.stat().st_mode)
   '0o40770'

   Notice that setgid is not respected.

4. Set setgid to the working directory:

   >>> Path().chmod(0o2770)
   >>> oct(Path().stat().st_mode)
   '0o42770'

   This works as expected.

5. Create another subdirectory with mode ug+rwx,g+s:

   >>> (test2 := Path("test2")).mkdir(0o2770)
   >>> oct(test2.stat().st_mode)
   '0o42770'

   The setgid bit of the new directory is now correctly set.

This also affects os.mkdir.

I have only tested this under Python 3.8.2 and 3.8.3 on a POSIX filesystem. (I 
assume it's not relevant to non-POSIX filesystems.)

--
components: Library (Lib)
messages: 374496
nosy: Xophmeister
priority: normal
severity: normal
status: open
title: Path.mkdir and os.mkdir don't respect setgid if its parent is g-s
versions: Python 3.8

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



[issue40970] Error in Python Datamodel Documentation

2020-06-14 Thread Christopher Yeh


Christopher Yeh  added the comment:

I understand the two uses of the phrase "built-in":

1) to refer to things included with the Python interpreter (e.g. modules in 
sys.builtin_module_names, and built-in functions like len() and ord())
2) to refer to things included with Python that are written in C

However, I find it fairly difficult to distinguish between the two uses in the 
context presented:

> A built-in function object is a wrapper around a C function.  Examples of 
> built-in functions are `len` and `math.sin` (`math` is a standard built-in 
> module).

Within the Python Language Reference (docs.python.org/3/reference), this is 
actually the only case where definition (2) applies, as far as I can tell: 
https://www.google.com/search?q="built-in+module"+site%3Ahttps%3A%2F%2Fdocs.python.org%2F3%2Freference%2F

Also, I am not sure that the parenthetical about `math` being a module written 
in C adds any additional clarity.

--

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



[issue40970] Error in Python Datamodel Documentation

2020-06-13 Thread Christopher Yeh


Christopher Yeh  added the comment:

Here's the output from my terminal comparing the `math` standard library module 
(not always built-in) against the `sys` standard library module (always 
built-in).

On Windows 10 x64, WSL 1, Ubuntu 18.04.02 LTS, Python 3.7.7 installed via 
conda: math is not a built-in module.

$ python
Python 3.7.7 (default, Mar 26 2020, 15:48:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print(math)

>>> print(type(math))

>>> import sys
>>> print(sys)

>>> print(type(sys))



On Windows 10 x64, Python installed directly from Python.org: math is a 
built-in module.

C:\>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print(math)

>>> print(type(math))

>>> import sys
>>> print(sys)

>>> print(type(sys))


--

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



[issue40970] Error in Python Datamodel Documentation

2020-06-13 Thread Christopher Yeh


New submission from Christopher Yeh :

The documentation says the following:

> A built-in function object is a wrapper around a C function.  Examples of 
> built-in functions are `len` and `math.sin` (`math` is a standard built-in 
> module).

However, `math` is not always a built-in module, as can be seen in on my own 
Python installation (Windows 10, WSL 1, Python 3.7.7 installed via conda).

>>> import sys
>>> sys.builtin_module_names
('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', 
'_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', 
'_thread', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 
'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 
'time', 'xxsubtype', 'zipimport')

Therefore, I have submitted a pull request to remove the statement "(`math` is 
a standard built-in module)" from the documentation.

--
assignee: docs@python
components: Documentation
messages: 371473
nosy: chrisyeh, docs@python
priority: normal
pull_requests: 20055
severity: normal
status: open
title: Error in Python Datamodel Documentation
type: enhancement
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

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



Re: Decorators with arguments?

2020-05-25 Thread Christopher de Vidal
Peter Otten, Cameron Simpson, thank you for your detailed replies :-) I
confess, I didn't quite understand all you were saying. (Still only an
intermediate-level programmer.) But Cameron what you said questioning my
use of decorators and maybe a class instead got me thinking. I realized
what I needed was a function within a function. Couldn't have gotten there
without your help. Working code:

#!/usr/bin/env python3
from google.cloud import firestore
import firebase_admin
from firebase_admin import credentials
import json
import mqtt
from time import sleep

def bridge(col_name):
def on_snapshot(col_snapshot, changes, read_time):
data = dict()
for doc in col_snapshot:
serial = doc.id
data[serial] = json.dumps(doc.to_dict()['value'])
for change in changes:
serial = change.document.id
mqtt_topic = col_name + '/outgoing/' + serial
if change.type.name in ['ADDED', 'MODIFIED']:
contents = data[serial]
mqtt.publish(mqtt_topic, contents)
elif change.type.name == 'REMOVED':
mqtt.publish(mqtt_topic, '')


@mqtt.incoming
def mqtt_subscribe(serial, value):
# TODO Passing a None entry to delete from MQTT doesn't trigger
this
#   callback, so it doesn't delete from Firestore. Need this ugly
#   workaround 'clear_mqtt'.
if value == 'clear_mqtt':
value = None
mqtt.publish(col_name + '/incoming/' + serial, None)
mqtt.publish(col_name + '/outgoing/' + serial, None)
db.collection(col_name).document(serial).set({'value': value})


col_watch = db.collection(col_name).on_snapshot(on_snapshot)
mqtt.subscribe(col_name + '/incoming/#', mqtt_subscribe)
return col_watch


cred = credentials.Certificate("certs/firebase.json")
firebase_admin.initialize_app(cred)
db = firestore.Client()
mqtt.connect()
adapters = list()
for collection in ['door_status', 'cpu_temp']:
adapters.append(bridge(collection))
while True:
sleep(1)
for adapter in adapters:
adapter.unsubscribe()

Christopher de Vidal

Would you consider yourself a good person? Have you ever taken the 'Good
Person' test? It's a fascinating five minute quiz. Google it.


On Fri, May 15, 2020 at 9:55 AM Peter Otten <__pete...@web.de> wrote:

> Christopher de Vidal wrote:
>
> > Help please? Creating an MQTT-to-Firestore bridge and I know a decorator
> > would help but I'm stumped how to create one. I've used decorators before
> > but not with arguments.
> >
> > The Firestore collection.on_snapshot() method invokes a callback and
> sends
> > it three parameters (collection_snapshot, changes, and read_time). I need
> > the callback to also know the name of the collection so that I can
> publish
> > to the equivalent MQTT topic name. I had thought to add a fourth
> parameter
> > and I believe a decorator is the right approach but am stumped how to add
> > that fourth parameter. How would I do this with the code below?
> >
> > #!/usr/bin/env python3
> > from google.cloud import firestore
> > import firebase_admin
> > from firebase_admin import credentials
> > import json
> > import mqtt
> >
> >
>
> firebase_admin.initialize_app(credentials.Certificate("certs/firebase.json"))
> > db = firestore.Client()
> > mqtt.connect()
> >
> >
> > def load_json(contents):
> > try:
> > return json.loads(contents)
> > except (json.decoder.JSONDecodeError, TypeError):
> > return contents
> >
> >
> > def on_snapshot(col_name, col_snapshot, changes, read_time):
> > data = dict()
> > for doc in col_snapshot:
> > serial = doc.id
> > contents = load_json(doc.to_dict()['value'])
> > data[serial] = contents
> > for change in changes:
> > serial = change.document.id
> > mqtt_topic = col_name + '/' + serial
> > contents = data[serial]
> > if change.type.name in ['ADDED', 'MODIFIED']:
> > mqtt.publish(mqtt_topic, contents)
> > elif change.type.name == 'REMOVED':
> > mqtt.publish(mqtt_topic, None)
> >
> >
> > # Start repeated code section
> > # TODO Better to use decorators but I was stumped on how to pass
> arguments
> > def door_status_on_snapshot(col_snapshot, changes, read_time):
> > on_snapshot('door_status', col_snapshot, changes, read_time)
> >
> >
> > door_status_col_ref = db.collection('door_status')
> > door_status_col_watch =
> > door_status_col_ref.on_snapshot(door_status_on_snapshot)
> >
> > # Repetition...
> > def cpu_temp_on_snapshot

Decorators with arguments?

2020-05-14 Thread Christopher de Vidal
Help please? Creating an MQTT-to-Firestore bridge and I know a decorator
would help but I'm stumped how to create one. I've used decorators before
but not with arguments.

The Firestore collection.on_snapshot() method invokes a callback and sends
it three parameters (collection_snapshot, changes, and read_time). I need
the callback to also know the name of the collection so that I can publish
to the equivalent MQTT topic name. I had thought to add a fourth parameter
and I believe a decorator is the right approach but am stumped how to add
that fourth parameter. How would I do this with the code below?

#!/usr/bin/env python3
from google.cloud import firestore
import firebase_admin
from firebase_admin import credentials
import json
import mqtt

firebase_admin.initialize_app(credentials.Certificate("certs/firebase.json"))
db = firestore.Client()
mqtt.connect()


def load_json(contents):
try:
return json.loads(contents)
except (json.decoder.JSONDecodeError, TypeError):
return contents


def on_snapshot(col_name, col_snapshot, changes, read_time):
data = dict()
for doc in col_snapshot:
serial = doc.id
contents = load_json(doc.to_dict()['value'])
data[serial] = contents
for change in changes:
serial = change.document.id
mqtt_topic = col_name + '/' + serial
contents = data[serial]
if change.type.name in ['ADDED', 'MODIFIED']:
mqtt.publish(mqtt_topic, contents)
elif change.type.name == 'REMOVED':
mqtt.publish(mqtt_topic, None)


# Start repeated code section
# TODO Better to use decorators but I was stumped on how to pass arguments
def door_status_on_snapshot(col_snapshot, changes, read_time):
on_snapshot('door_status', col_snapshot, changes, read_time)


door_status_col_ref = db.collection('door_status')
door_status_col_watch =
door_status_col_ref.on_snapshot(door_status_on_snapshot)

# Repetition...
def cpu_temp_on_snapshot(col_snapshot, changes, read_time):
on_snapshot('cpu_temp', col_snapshot, changes, read_time)


cpu_temp_col_ref = db.collection('cpu_temp')
cpu_temp_col_watch = cpu_temp_col_ref.on_snapshot(cpu_temp_on_snapshot)
# End repeated code section

# Start repeated code section
door_status_col_watch.unsubscribe()
cpu_temp_col_watch.unsubscribe()
# Repetition...
# End repeated code section

Christopher de Vidal

Would you consider yourself a good person? Have you ever taken the 'Good
Person' test? It's a fascinating five minute quiz. Google it.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue40592] `Shutil.which` incosistent with windows's `where`

2020-05-14 Thread Christopher Marchfelder


Change by Christopher Marchfelder :


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

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



[issue40592] `Shutil.which` incosistent with windows's `where`

2020-05-14 Thread Christopher Marchfelder


Christopher Marchfelder  added the comment:

@steve.dower I would really love to work on this and make my first 
contribution. Never did one, so I would some help doing this one :)

--
nosy: +Christopher Marchfelder

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



I need to create .odt or .rtf documents in Python3. what is the best tool to do this....

2020-01-12 Thread christopher rehm
hi all im new here. i need to create .odt or rtf documents from a python 3 
program. i need a package or library that actually has real documentation and 
examples, using python3 and the tool ( sorry PyRTF3 is a major failure here)
does anyone have any suggestions?

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


Re: [Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Christopher Barker
On Wed, Jan 8, 2020 at 1:24 AM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> But a thought on that -- you may be able to accomplish something similar
>> with conda, "conda constructor", and "conda run". -- or a new tool built
>> from those. The idea is that the first time you ran your "app", it would
>> install its dependencies, and then use them in an isolated environment. But
>> if the multiple apps had the same dependencies, they would share them, so
>> you wouldn't get major bloat on the host machine.
>>
>
> I guess it's time to dig more into anaconda, been
> putting it off, will do.
>

to be clear -- you want to look at "conda", not "Anaconda" -- conda is a
package manager, Anaconda is a distribution created with the conda package
manager.


> but a wheel is just as big as the installed package (at least a zipped
>> version) -- it's essentially the package compressed into a tarball.
>>
>
> I really hope C extentions would become redundent someday
> in Python, which would make Python development real
> Python dev.
>

That's not going to completely happen. Which does not mean that a solution
that doesn't support them isn't still useful for a lot. But it would be
interesting to see how many commonly used packages on PyPi rely on C
extensions (other than the SciPy Stack).


> But: "Unlike “conventional” zipapps, shiv packs a site-packages style
>> directory of your tool’s dependencies into the resulting binary, and then
>> at bootstrap time extracts it into a ~/.shiv cache directory."
>>
>
> Maybe we can have a PYZ directory where the
> packages for each app are extracted then it's not
> a global dump but more specific
>

I'm not sure how that differs from a .shiv directory, which is not global.
But a way to share packages in the "central place for packages" would be
nice. -- maybe how conda does it with hard links?

-CHB


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Christopher Barker
On Wed, Jan 8, 2020 at 1:49 AM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Have a look at this write up about the horror that is zip file name
>> handling.
>>
>> https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/
>>
>> This has been a pain point at work.
>>
>
I'm pretty sure this is a non-issue for this use-case. If you need to open
sip files created by arbitrary other systems, or create zip files that can
be opened by arbitrary other systems, then it's a big mess. But that isn't
the case here.

-CHB


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Re: Enhancing Zipapp

2020-01-07 Thread Christopher Barker
On Mon, Jan 6, 2020 at 10:50 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:


> - More metadata
>

good idea, and simple.


> - Integrity check with hashing
> - Protecting the meta data
>

This could be a big challenge -- and I'm not expert, so have no idea what
the issues are.


> - Bundling 3rd party packages
>

Well, as you state below, that could make it big. but it also could make it
useful -- folks want to use environments of various sorts to keep
dependencies separate, so bundling them all up in an app would be nice.

But a thought on that -- you may be able to accomplish something similar
with conda, "conda constructor", and "conda run". -- or a new tool built
from those. The idea is that the first time you ran your "app", it would
install its dependencies, and then use them in an isolated environment. But
if the multiple apps had the same dependencies, they would share them, so
you wouldn't get major bloat on the host machine.


> Are you aiming for a bundle that can run on multiple platforms? If so,
>> then it’ll have to have a way to bundle multiple compiled extensions and
>> select the right ones at runtime.
>>
>
> According to the discussion on the Python, Be Bold thread, it became
> clear that it will be a pain to generate and will have an unnecessary
> size but sure this a most stable idea
>
> Suggesting instead to include wheels. The wheels are installed. The
> interpreter looks for packages in that app-specific folder
>

but a wheel is just as big as the installed package (at least a zipped
version) -- it's essentially the package compressed into a tarball.

If this Is essentially just zipapp with the ability to bundle dependencies,
>> then you could probably just do some sys.path hackery.
>>
>
> Could you please explain more. Thanks?
>

sure -- in your zip file, you have a "dependencies" directory. the
dependencies get installed there. Then that dir gets added to sys.path at
startup. I'm not so sure o=how to do that inside a zipfile, but it could be
done *somehow*

In any case, thus seems like something you could implement, and then see if
>> people find it useful.
>>
>
> That's a nice idea to have a working demo. I'm not a security
> expert but i'll try!
>

well, you'll need a consult on the security issues -- which you would want
well reviewed anyway ;-)


> Anyone interested in this thread can view this tool
> <https://github.com/linkedin/shiv> built by LinkedIn which
> attempts dependencies bundling.
>

There you go -- you've got half the job done already :-)

But: "Unlike “conventional” zipapps, shiv packs a site-packages style
directory of your tool’s dependencies into the resulting binary, and then
at bootstrap time extracts it into a ~/.shiv cache directory."

which is how they get around the "how to add a dir in a zip file to
sys.path" -- but I'll bet someone could hack that to no be neccesary

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Re: Enhancing Zipapp

2020-01-06 Thread Christopher Barker
I’m a bit unclear on how far this goes: is it just a bit more specific with
more meta-data standards?

Or are you aiming for something that will run without a Python install?

Other issues:

Are you aiming for a bundle that can run on multiple platforms? If so, then
it’ll have to have a way to bundle multiple compiled extensions and select
the right ones at runtime.

If this Is essentially just zipapp with the ability to bundle dependencies,
then you could probably just do some sys.path hackery.

In any case, thus seems like something you could implement, and then see if
people find it useful.

BTW- I’m pretty sure we could simply specify that filenames are utf-8 and
we’d be good to go.

-CHB





On Mon, Jan 6, 2020 at 5:50 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

>
>
> On Tue, 7 Jan 2020, 01:57 Barry Scott,  wrote:
>
>>
>>
>> Please cover the pro's and con's of the alernatives that have been raised
>> as comments
>> on this idea, as is usually done for a PEP style document.
>>
>
> Thanks, i don't have much experience writing peps and
> if i don't bug you may i ask what "alternatives" refer to?
>
> Also beware that zip file format does not include the encoding of the
>> files that are in the
>> zip file.
>
>
> For the encoding of the contents, well since we are
> packaging python code files, it's handling will be the same
> as handling outside the zip file. It's handling is the
> same as how zipapp handles things.
>
> This means that for practical purposes only ASCII filenames are portable
>> across
>> systems. Is this limitation a problem for this proposal?
>>
>
> If we are talking about filenames, then i guess
> ascii filenames are the way to go as you'd
> unnecessarily break things otherwise.
>
>> ___
> Python-ideas mailing list -- python-id...@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-id...@python.org/message/RVGFMDP3PG6TXFQGH7ISRLYM4FS5CO64/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-11-17 Thread Christopher Hunt


Christopher Hunt  added the comment:

Any other concerns here?

--

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-09-13 Thread Christopher Hunt


Christopher Hunt  added the comment:

> I believe the mentality behind multiprocessing.Process triggering an exit 
> code of 1 when sys.exit() is invoked inside its process is to indicate a 
> non-standard exit out of its execution.

Can I ask what this is based on? I did a pretty good amount of digging but 
didn't find any justification for it. It just seems like a simple oversight to 
me.

> There may yet be other side effects that could be triggered by having a 
> sys.exit(0) translate into an exit code of 0 from the Process's process -- 
> and we might not notice them with the current tests.

This is definitely a behavior change and will break any code that currently 
relies on `sys.exit(None)` or `sys.exit()` exiting with a non-zero exit code 
from a multiprocessing.Process. The fact that all documentation indicates that 
`sys.exit(None)` or `sys.exit()` results in a 0 exit code in normal Python 
(with no documentation on it related to multiprocessing) makes me think that 
any code relying on this behavior is subtly broken, however. Any impacted user 
can update their code and explicitly pass 1 to `sys.exit`, which should be 
forward and backwards compatible.

> Was there a particular use case that motivates this suggested change?

I have a wrapper library that invokes arbitrary user code and attempts to 
behave as if that code was executed in a vanilla Python process, to include 
propagating the correct exit code.

Currently I have a workaround here: 
https://github.com/chrahunt/quicken/blob/2dd00a5f024d7b114b211aad8a2618ec8f101956/quicken/_internal/server.py#L344-L353,
 but it would be nice to get rid of it in 5-6 years if this fix gets in and the 
non-conformant Python versions fall out of support. :)

--

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



[issue37870] os.path.ismount returns false for disconnected CIFS mounts in Linux

2019-08-15 Thread Matt Christopher


New submission from Matt Christopher :

I've got a case where we mount a CIFS filesystem and then later the actual 
backing filesystem is deleted (but the mount remains on the machine).

When running from a shell, this is the behavior which I see after the backing 
CIFS filesystem has gone away:
root@1b20608623a246f1af69058acdfbfd3006:/fsmounts# ll
ls: cannot access 'cifsmountpoint': Input/output error
total 8
drwxrwx--- 3 _user _grp 4096 Aug 15 15:46 ./
drwxrwx--- 8 _user _grp 4096 Aug 15 15:46 ../
d? ? ??  ?? cifsmountpoint/
root@1b20608623a246f1af69058acdfbfd3006:/fsmounts# stat -c "%d" 
cifsmountpoint
stat: cannot stat 'cifsmountpoint': Input/output error

Running mount -l shows this:
///c7e868cd-3047-4881-b05b-a1a1d087dbf5 on /fsmounts/cifsmountpoint 
type cifs 
(rw,relatime,vers=3.0,cache=strict,username=,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=52.239.160.104,file_mode=0777,dir_mode=0777,soft,persistenthandles,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)

In the Python code that I see posixpath.py has this snippet:
try:
s1 = os.lstat(path)
except (OSError, ValueError):
# It doesn't exist -- so not a mount point. :-)
return False

The problem is that the comment: "# It doesn't exist -- so not a mount point. 
:-)" assumes a particular kind of OSError - in reality not every OS error means 
that it doesn't exist. In this case we're getting OSError with errno == 5, 
which is:
OSError: [Errno 5] Input/output error: 

Now, I'm not entirely sure what (if anything) the ismount function is supposed 
to be doing here... but returning false seems incorrect. This IS a mount, and 
you can see so via mount -l.
I am aware that there are other libraries (i.e. psutil.disk_partitions) which 
can help me to detect this situation but I was surprised that ismount was 
saying false here. It seems like it should possibly just raise, or maybe 
there's a fancy way to check mounts if lstat fails.

This looks kinda related to https://bugs.python.org/issue2466 (although this is 
already fixed and not exactly the same problem it's a similar class of issue)

--
messages: 349833
nosy: Matt Christopher
priority: normal
severity: normal
status: open
title: os.path.ismount returns false for disconnected CIFS mounts in Linux
type: behavior
versions: Python 3.6

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



[issue37745] 3.8b3 - windows install gui/ inconsistent options

2019-08-08 Thread Christopher Brousseau


Christopher Brousseau  added the comment:

First, I'd like to say **thank you** all the work you and the team here do for 
Python, and Python on Windows.  I really appreciate the thoughtful feedback on 
these ideas.  

Following up on items in this thread:

> do you mean we change "Install launcher for all users" to "Install py 
> launcher for all users"?
yes - that is correct, good clarification

> long term comments
I see - okay, perhaps we should defer this point to think about it in context 
of a PR (per below).  I really like the idea of not requiring complicated leaps 
of understanding for every type of user.

The main idea I'm thinking about on this first screen: the Default and 
Customize options are complete/self contained actions - but there there are 
more choices below that could apply to either Default or Customized 
installations.  When a user clicks on Install Now, the installation starts 
immediately, so the user may not configure these two checkboxes.  

The Customize workflow allows the user to back out all the way to the first 
screen, so it's easy for a user to back up to the beginning if they want to.

Maybe this is an order of operations question. Perhaps the checkboxes should be 
above Install Now or Customize, so there is a linear flow of decisions:  
configure, then execute.  

Another idea, using UAC perhaps the Default could be 'install py launcher for 
all users' and not add to PATH.

However, it seems like there may be a few additional requirements.  One 
requirement being Default users need the ability optionally install for all 
users because of Admin privilege issues, secondly the ability to add Python to 
PATH.  A third requirement is these two choices be available and obvious to 
both installation paths.  Are these correct?



> test for admin privileges
I did not know that testing for this was not possible - learned something - 
thanks!


>To clarify, we add an "Install py launcher for all users" checkbox on screen 3 
>and remove it from screen 2? What gets removed from screen 3 to make space for 
>it?

Correct - that wording seems right.  On the space question, it seems like there 
is space below "Download Debug binaries" so the list from "Associate files" 
through "Download Debug binaries" could be shifted down without requiring 
anything to be deleted.  


> 1. changing current "py launcher" checkbox to "upgrade py launcher"
> But this is incorrect. If you don't select the checkbox, you don't get the 
> launcher. It's a choice to have > or not-have, not a choice to upgrade or 
> not-upgrade.

Got it - I was responding to the grey text below the current checkbox that 
reads "Upgrades the global py launcher from the previous version".
Would it be correct to label this checkbox as "install py launcher"?


> other suggestions discussed in this thread.
> e.g. 2. moving "for all users" to next line down - looks like we have space, 
> etc.
> This is feasible, but not high priority. PRs welcome.

Agree - this is low priority.  I will look into doing PR for this, and have to 
get setup to submit patches etc. so perhaps this is for future release if PR 
accepted.

--

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



[issue37745] 3.8b3 - windows install gui/ inconsistent options

2019-08-07 Thread Christopher Brousseau


Christopher Brousseau  added the comment:

Ah - I didn't realize the nuances here - thank you for clearing that up for me. 
 Understand the design goal of keeping window size and using only checkboxes - 
simple.  Also agree some text changes may help, here are some suggestions for 
your consideration:

screen 1 - install python
recommend we change "install launcher" to "install py launcher" to be explicit.

Long term - it would be cleaner if the user had only 'default' and customize 
installation on this screen, with all configurations either bundled under 
Default, or moved to other screens for 'Customized' installs.  We could add 
notes under default that we're installing python for all users, py launcher, 
adding Python to PATH, etc.

If a user does not have admin privileges, it may not be helpful to them to 
present choices they can't install.  For a default install - we could test if 
user has admin privileges and install for all users, or fall back to 'user' 
only install.

screen 2 - optional features
recommend we move "for all users" to screen 3, since this screen is about 
features to add, while the following screen is about how they are configured on 
the system.  

If this isn't possible in this release, consider 
1. changing current "py launcher" checkbox to "upgrade py launcher"
2. moving "for all users" to next line down - looks like we have space
3. changing "for all users" to "py launcher for all users"

screen 3 - advanced options
two recommendations:
1. change "install for all users" to "install python for all users"
2. insert checkbox for "install py launcher for all users" as 2nd item in list. 
 This would then be directly above the existing "Associate files with Python" 
checkbox

--

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



[issue37767] TTK Treeview alternating row color not working

2019-08-05 Thread Christopher Caputo


New submission from Christopher Caputo :

The default installation of Python3.7 on all my Win10 machines has a ttk theme 
file that disables treeview alternating row colors. The specific file for me is 
"vistaTheme.tcl" located at "C:\Program Files\Python37\tcl\tk8.6\ttk". In the 
#Treeview section of the file the "ttk::style map Treeview" line needed to be 
changed from:

ttk::style map Treeview \
-background [list disabled $colors(-frame)\
{!disabled !selected} $colors(-window) \
selected SystemHighlight] \
-foreground [list disabled $colors(-disabledfg) \
{!disabled !selected} black \
selected SystemHighlightText]

Changed to:

ttk::style map Treeview
-background [list selected SystemHighlight]
-foreground [list selected SystemHighlightText]

Essentially all the "disabled" parts needed to be removed.

--
components: Tkinter
messages: 349071
nosy: Mookiefer
priority: normal
severity: normal
status: open
title: TTK Treeview alternating row color not working
type: behavior
versions: Python 3.7

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



[issue37745] 3.8b3 - windows install gui/ inconsistent options

2019-08-02 Thread Christopher Brousseau


New submission from Christopher Brousseau :

When installing 3.8.0b3 64-bit into Win 10 using the gui following the 
`customize installation` path, there are duplicate and inconsistent options on 
three different screens for the `install for all users` checkbox.

Observed Behavior:
1. first screen (Install Python) - `install launcher for all users` is marked 
as checked as default
2. second screen (Optional Features) - 
2.1 `for all users` is also marked as checked if first screen marked.  if 
second screen marked - this is unchecked.
2.2 layout of this checkbox is above a comment that relates only to the "py 
launcher" checkbox.  would be more clear for user if `for all users` was 
located below "py launcher", or removed from this screen (per note below)
3. third screen (Advanced Options) - `Install for all users` is UNchecked in 
all cases, even if first & second screens are checked.

Expected Behavior:
1. if first screen is checked, all follow on screens are also checked
2. feature options only appear on one screen, or at a minimum, checkbox label 
is exactly the same on all screens

Additional Questions for the team:
1. Should all install customizations be removed from first screen, set as 
default options and just listed as descriptions under the `Install Now` default?
2. Should `for all users` option be removed from the 2nd screen (Optional 
Features)?  It seems more like an "advanced option" than a feature.

Screenshots (this site appears to only allow one file)
first: https://imgur.com/a/0a45CBh
second: https://imgur.com/a/6ZV16bV
third:  https://imgur.com/a/stRTh25

Link to binary used for this:
https://www.python.org/ftp/python/3.8.0/python-3.8.0b3-amd64.exe

--
components: Installation, Windows
files: python_3.8b3_screen02_optional_features_2019-08-02_9-56-02.png
messages: 348907
nosy: Christopher Brousseau, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: 3.8b3 - windows install gui/ inconsistent options
type: behavior
versions: Python 3.8
Added file: 
https://bugs.python.org/file48527/python_3.8b3_screen02_optional_features_2019-08-02_9-56-02.png

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



[issue37701] shutil.copyfile raises SpecialFileError for symlink to fifo

2019-07-28 Thread Christopher Hunt


Christopher Hunt  added the comment:

Likewise when the destination is a symlink - though in that case the value of 
`follow_symlinks` should probably not matter.

--

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



[issue37701] shutil.copyfile raises SpecialFileError for symlink to fifo

2019-07-28 Thread Christopher Hunt


New submission from Christopher Hunt :

Currently shutil.copyfile raises SpecialFileError when src is a link to a fifo. 
To reproduce:

import os
import shutil
import tempfile


d = tempfile.mkdtemp()
fifo = os.path.join(d, 'fifo')
link_to_fifo = os.path.join(d, 'link-to-fifo')
copy_of_link_to_fifo = os.path.join(d, 'copy-of-link-to-fifo')


os.mkfifo(fifo)
os.symlink(fifo, link_to_fifo)
shutil.copyfile(link_to_fifo, copy_of_link_to_fifo)

Example output:

Traceback (most recent call last):
  File "repro.py", line 14, in 
shutil.copyfile(link_to_fifo, copy_of_link_to_fifo)
  File "/home/chris/.pyenv/versions/3.7.2/lib/python3.7/shutil.py", line 
115, in copyfile
raise SpecialFileError("`%s` is a named pipe" % fn)
shutil.SpecialFileError: `/tmp/user/1000/tmpxhigll5g/link-to-fifo` is a 
named pipe

I would have expected this to copy the symlink without complaint. Raising a 
SpecialFileError would be OK if `follow_symlinks` was False.

--
components: Library (Lib)
messages: 348597
nosy: chrahunt
priority: normal
severity: normal
status: open
title: shutil.copyfile raises SpecialFileError for symlink to fifo
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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



[issue37700] shutil.copyfile does not raise SpecialFileError for socket files

2019-07-28 Thread Christopher Hunt


Christopher Hunt  added the comment:

See also: the comment from 
https://github.com/python/cpython/blob/e1b900247227dad49d8231f1d028872412230ab4/Lib/shutil.py#L245:

> # XXX What about other special files? (sockets, devices...)

--

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



[issue37700] shutil.copyfile does not raise SpecialFileError for socket files

2019-07-28 Thread Christopher Hunt


New submission from Christopher Hunt :

Currently shutil.copyfile only raises SpecialFileError for named pipes. When 
trying to use the function to copy a socket file, the exception raised depends 
on the platform, for example:

macOS: "[Errno 102] Operation not supported on socket: 
'/Users/guido/src/mypy/dmypy.sock'"
HP-UX: "[Errno 223] Operation not supported: 'example/foo'"
Solaris: "[Errno 122] Operation not supported on transport endpoint: 
'example/foo'"
AIX: "[Errno 64] Operation not supported on socket: '../../example/foo'"
Linux: "[Errno 6] No such device or address: 'example/foo'"

This can be reproduced like:

import os
import shutil
import socket
import tempfile

d = tempfile.mkdtemp()
src = os.path.join(d, "src")
dest = os.path.join(d, "dest")
sock = socket.socket(socket.AF_UNIX)
sock.bind(src)

shutil.copyfile(src, dest)

Making shutil.copyfile raise SpecialFileError for socket files would improve 
the interface of this function since the same class of error could be ignored. 
This is mostly useful with shutil.copytree, which defaults to copyfile for its 
copy function.

--
components: Library (Lib)
messages: 348595
nosy: chrahunt
priority: normal
severity: normal
status: open
title: shutil.copyfile does not raise SpecialFileError for socket files
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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



[issue32082] atexit module: allow getting/setting list of handlers directly

2019-07-04 Thread Christopher Hunt


Christopher Hunt  added the comment:

Updated link to workaround referenced in the original issue: 
https://github.com/sagemath/sage/blob/b5c9cf037cbce672101725f269470135b9b2c5c4/src/sage/cpython/atexit.pyx

--
nosy: +chrahunt

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



[issue34796] Tkinter scrollbar issues on Mac.

2019-06-16 Thread Christopher A. Chavez


Christopher A. Chavez  added the comment:

> Apparently, the current ttk.Scrollbar on the 8.6.8 we currently deliver 
> should sort of work.

I'm not sure if that is the case, though I have not tested with 8.6.8 (I do not 
currently have access to High Sierra or earlier). Based on a comment by the 
developer (Marc Culler) in https://core.tcl-lang.org/tk/tktview?name=0d63621b6c 
it sounds like the Ttk scrollbar is a completely new implementation for 8.6.10, 
whereas before (8.6.9.1? 8.6.8?) any code requesting a Ttk scrollbar on Aqua 
normally got a non-Ttk scrollbar instead.

--

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



[issue34796] Tkinter scrollbar issues on Mac.

2019-06-16 Thread Christopher A. Chavez


Christopher A. Chavez  added the comment:

I have not successfully reproduced the issue here with tkinter 3.7.3 using 
8.6.9.1 or recent core-8-6-branch on macOS Mojave.

I understand the reporter of this issue believed this was not an upstream Tk 
issue. However there's a recently opened upstream ticket relating to scrollbars 
on Aqua which may be of interest: 
https://core.tcl-lang.org/tk/info/8476b757811b3694

At the moment, one of the Tk Aqua developers appears to advise against using 
the normal (non-Ttk) scrollbar at all on macOS because it has never worked 
properly and likely will not be fixed, and instead suggests using the new Ttk 
scrollbar implementation, which should be available in 8.6.10.

--

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



[issue34796] Tkinter scrollbar issues on Mac.

2019-06-16 Thread Christopher A. Chavez


Change by Christopher A. Chavez :


--
nosy: +chrstphrchvz

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



[issue35792] Specifying AbstractEventLoop.run_in_executor as a coroutine conflicts with implementation/intent

2019-04-20 Thread Christopher Hunt


Christopher Hunt  added the comment:

For impl.1:

> (very breaking change)

should be

> (very breaking change, mitigated some by the fact that the implementation 
> will warn about the unawaited future)

--

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



[issue35792] Specifying AbstractEventLoop.run_in_executor as a coroutine conflicts with implementation/intent

2019-04-19 Thread Christopher Hunt


Christopher Hunt  added the comment:

My use case is scheduling work against an executor but waiting on the results 
later (on demand).

If converting `BaseEventLoop.run_in_executor(executor, func, *args)` to a 
coroutine function, I believe there are two possible approaches (the discussion 
that started this 
[here](https://stackoverflow.com/questions/54263558/is-asyncio-run-in-executor-specified-ambiguously)
 only considers [impl.1]):

impl.1) `BaseEventLoop.run_in_executor` still returns a future, but we must 
await the coroutine object in order to get it (very breaking change), or
impl.2) `BaseEventLoop.run_in_executor` awaits on the result of `func` itself 
and returns the result directly

In both cases the provided `func` will only be dispatched to `executor` when 
the coroutine object is scheduled with the event loop.

For [impl.1], from the linked discussion, there is an example of user code 
required to get the behavior of schedule immediately and return future while 
still using `BaseEventLoop.run_in_executor`:

async def run_now(f, *args):
loop = asyncio.get_event_loop()
started = asyncio.Event()
def wrapped_f():
loop.call_soon_threadsafe(started.set)
return f(*args)
fut = loop.run_in_executor(None, wrapped_f)
await started.wait()
return fut

however this wrapper would only be possible to use in an async function and 
assumes the executor is running in the same process - synchronous functions 
(e.g. an implementation of Protocol.data_received) would need to use an 
alternative `my_run_in_executor`:

def my_run_in_executor(executor, f, *args, loop=asyncio.get_running_loop()):
return asyncio.wrap_future(executor.submit(f, *args), loop=loop)

either of these would need to be discovered by users and live in their code 
base.

Having to use `my_run_in_executor` would be most unfortunate, given the purpose 
of `run_in_executor` per the PEP is to be a shorthand for this exact function.

For [impl.2], we are fine if the use case allows submitting and awaiting the 
completion of `func` in the same location, and no methods of asyncio.Future 
(e.g. `add_done_callback`, `cancel`) are used. If not then we still need to 
either:

soln.1) use `my_run_in_executor`, or
soln.2) wrap the `BaseEventLoop.run_in_executor` coroutine 
object/asyncio.Future with `asyncio.ensure_future`

[soln.1] is bad for the reason stated above: this is the function we are trying 
to avoid users having to write.

[soln.2] uses the low-level function `asyncio.ensure_future` because both of 
the suggested alternatives (per the docs) `asyncio.create_task` and 
`BaseEventLoop.create_task` throw a `TypeError` when provided an 
`asyncio.Future` as returned by the current implementation of 
`BaseEventLoop.run_in_executor`. This will have to be discovered by users and 
exist in their code base.

--

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



Re: The Mailing List Digest Project

2019-03-26 Thread Christopher Barker
 On Tue, Mar 26, 2019 at 8:32 AM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Great! will see sphinx but if i find the html hard to customise, i'll drop
> it.
>

Sphinx has theming support, plus you can do custom CSS if you want. But
Highly discourage you from worrying about formatting — decent structure is
good enough, and content is what matters.

Search feature and tags coming.
>

Sphinx has search built in.

also, currently i'm formatting the mails rather than an article, i don't
> know if a real summary of the topic preferable ...
>

These mailing lists are really big, and the threads are long and scattered,
and they are archived and searchable already.

So I think the real value would be article-style summaries (with links to
the threads).

For Python-Ideas, I’m thinking kind of a mini rejected PEP ...

-CHB

>





> Abdur-Rahmaan Janhangeer
> Mauritius
>
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Mailing List Digest Project

2019-03-26 Thread Christopher Barker
On Mon, Mar 25, 2019 at 10:01 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> As proposed on python-ideas, i setup a repo to turn mail threads into
> articles.
>

Thanks for doing this — I find myself frequently telling people about past
relevant threads on this list - it will be great to have a single place to
point people. It can be hard to find stuff in the archives if you’re not
sure what to search for.

here is the repo
>
> https://github.com/Abdur-rahmaanJ/py-mailing-list-summary
>
> i included a script to build .md to .html
>

Maybe Sphinx and  RST instead? For consistency with other Python docs?

But markup is far less important than content.

-CHB

(with syntax highlighting) here is the index
>
> https://abdur-rahmaanj.github.io/py-mailing-list-summary/
>
> included 3 articles as a start
>
> if you want to contribute an article, just follow existing .md format and
> put it in the .md folder
>
> planning to go across ideas, list and dev
>
> i can tell you, it's a really enjoyable experience.
>
> psst. we can enhance some html later
>
> --
> Abdur-Rahmaan Janhangeer
> Mauritius
>
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25872] multithreading traceback KeyError when modifying file

2019-02-26 Thread Christopher Unkel


Change by Christopher Unkel :


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

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



[issue35960] dataclasses.field does not preserve empty metadata object

2019-02-10 Thread Christopher Hunt


Change by Christopher Hunt :


--
keywords: +patch, patch, patch
pull_requests: +11831, 11832, 11833
stage:  -> patch review

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



[issue35960] dataclasses.field does not preserve empty metadata object

2019-02-10 Thread Christopher Hunt


Change by Christopher Hunt :


--
keywords: +patch, patch
pull_requests: +11831, 11832
stage:  -> patch review

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



[issue35960] dataclasses.field does not preserve empty metadata object

2019-02-10 Thread Christopher Hunt


Change by Christopher Hunt :


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

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



[issue35960] dataclasses.field does not preserve empty metadata object

2019-02-10 Thread Christopher Hunt

New submission from Christopher Hunt :

The metadata argument to dataclasses.field is not preserved in the resulting 
Field.metadata attribute if the argument is a mapping with length 0.

The docs for dataclasses.field state:

> metadata: This can be a mapping or None. None is treated as an empty dict. 
> This value is wrapped in MappingProxyType() to make it read-only, and exposed 
> on the Field object.

The docs for MappingProxyType() state:

> Read-only proxy of a mapping. It provides a dynamic view on the mapping’s 
> entries, which means that when the mapping changes, the view reflects these 
> changes.

I assumed that the mapping provided could be updated after class initialization 
and the changes would reflect in the field's metadata attribute. Indeed this is 
the case when the mapping is non-empty, but not when the mapping is initially 
empty.

For example:

$ python
Python 3.8.0a1+ (heads/master:9db56fb8fa, Feb 10 2019, 19:54:10)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dataclasses import field
>>> d = {}
>>> v = field(metadata=d)
>>> d['i'] = 1
>>> v.metadata
mappingproxy({})
>>> v = field(metadata=d)
>>> v.metadata
mappingproxy({'i': 1})
>>> d['j'] = 2
>>> v.metadata
mappingproxy({'i': 1, 'j': 2})

In my case I have a LazyDict into which I was trying to save partial(callback, 
field). I could not have the field before it was initialized so I tried:

d = {}
member: T = field(metadata=d)
d['key'] = partial(callback, field)

and it failed same as above.

As a workaround, one can set a dummy value in the mapping prior to calling 
dataclasses.field and then remove/overwrite it afterwards.

--
components: Library (Lib)
messages: 335184
nosy: chrahunt
priority: normal
severity: normal
status: open
title: dataclasses.field does not preserve empty metadata object
type: behavior
versions: Python 3.7, Python 3.8

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



[issue27035] Cannot set exit code in atexit callback

2019-01-21 Thread Christopher Hunt


Change by Christopher Hunt :


--
nosy: +chrahunt
versions: +Python 3.7

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



[issue35792] Specifying AbstractEventLoop.run_in_executor as a coroutine conflicts with implementation/intent

2019-01-20 Thread Christopher Hunt


New submission from Christopher Hunt :

Currently AbstractEventLoop.run_in_executor is specified as a coroutine, while 
BaseEventLoop.run_in_executor is actually a non-coroutine that returns a Future 
object. The behavior of BaseEventLoop.run_in_executor would be significantly 
different if changed to align with the interface . If run_in_executor is a 
coroutine then the provided func will not actually be scheduled until the 
coroutine is awaited, which conflicts with the statement in PEP 3156 that it 
"is equivalent to `wrap_future(executor.submit(callback, *args))`".

There has already been an attempt in bpo-32327 to convert this function to a 
coroutine. We should change the interface specified in `AbstractEventLoop` to 
indicate that `run_in_executor` is not a coroutine, which should help ensure it 
does not get changed in the future without full consideration of the impacts.

--
components: asyncio
messages: 334109
nosy: asvetlov, chrahunt, yselivanov
priority: normal
severity: normal
status: open
title: Specifying AbstractEventLoop.run_in_executor as a coroutine conflicts 
with implementation/intent
type: behavior
versions: Python 3.7

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-01-12 Thread Christopher Hunt


Change by Christopher Hunt :


--
pull_requests: +11143, 11144
stage:  -> patch review

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-01-12 Thread Christopher Hunt


Change by Christopher Hunt :


--
pull_requests: +11143, 11144, 11145
stage:  -> patch review

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-01-12 Thread Christopher Hunt


Change by Christopher Hunt :


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

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-01-12 Thread Christopher Hunt


Change by Christopher Hunt :


--
versions:  -Python 2.7, Python 3.4, Python 3.5, Python 3.6

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



[issue35727] sys.exit() in a multiprocessing.Process does not align with Python behavior

2019-01-12 Thread Christopher Hunt


New submission from Christopher Hunt :

When a function is executed by a multiprocessing.Process and uses sys.exit,
the actual exit code reported by multiprocessing is different than would be
expected given the Python interpreter behavior and documentation. For example,
given:

from functools import partial
from multiprocessing import get_context
import sys


def run(ctx, fn):
p = ctx.Process(target=fn)
p.start()
p.join()
return p.exitcode


if __name__ == '__main__':
ctx = get_context('fork')
print(run(ctx, partial(sys.exit, 2)))
print(run(ctx, partial(sys.exit, None)))
print(run(ctx, sys.exit))

ctx = get_context('spawn')
print(run(ctx, partial(sys.exit, 2)))
print(run(ctx, partial(sys.exit, None)))
print(run(ctx, sys.exit))

ctx = get_context('forkserver')
print(run(ctx, partial(sys.exit, 2)))
print(run(ctx, partial(sys.exit, None)))
print(run(ctx, sys.exit))

when executed results in

$ python exit.py
2
1
1
2
1
1
2
1
1


but when Python itself is executed we see different behavior

$ for arg in 2 None ''; do python -c "import sys; sys.exit($arg)"; echo $?; 
done
2
0
0

The documentation states

> sys.exit([arg])
> ...
> The optional argument arg can be an integer giving the exit status
> (defaulting to zero), or another type of object.

The relevant line in multiprocessing 
(https://github.com/python/cpython/blame/1cffd0eed313011c0c2bb071c8affeb4a7ed05c7/Lib/multiprocessing/process.py#L307)
seems to be from the original pyprocessing module itself, and I could
not locate an active site that maintains the repository to see if there
was any justification for the behavior.

--
components: Library (Lib)
files: multiprocessing-exitcode-3.7.1.patch
keywords: patch
messages: 333531
nosy: chrahunt
priority: normal
severity: normal
status: open
title: sys.exit() in a multiprocessing.Process does not align with Python 
behavior
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: 
https://bugs.python.org/file48045/multiprocessing-exitcode-3.7.1.patch

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



[issue33578] cjkcodecs missing getstate and setstate implementations

2018-11-01 Thread Christopher Thorne


Change by Christopher Thorne :


--
pull_requests: +9600

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



Re: python3.7 error PYQT5 - NameError: name 'self' is not defined

2018-09-21 Thread Christopher Mullins
>
> Hi when I disconnect the internet I get an error NameError: name 'self' is
> not defined. I really dont get it.. thanks all. Is that a bug? or my fault?

Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 93, in secret
> print(ping('google.com'))
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 72, in ping
> conn.connect((addr, 80))
> socket.gaierror: [Errno 11001] getaddrinfo failed
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File
> "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 917, in _bootstrap_inner
> self.run()
>   File
> "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 865, in run
> self._target(*self._args, **self._kwargs)
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 95, in secret
> self.pushButton.setDisabled(True)
> NameError: name 'self' is not defined


Looks like `self` is supposed to be referring to an instance of the class
`Ui_AlonStockMarketApp` (which has the pushButton attribute) but you've
defined the secret function outside of that class.  Try defining that
function inside your class.

HTH,
Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34470] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-24 Thread Christopher Knorowski


Christopher Knorowski  added the comment:

This also happens in python 3.7. following a similar procedure.

On Wed, Aug 22, 2018 at 9:01 PM Zachary Ware  wrote:

>
> Zachary Ware  added the comment:
>
> Python 2.7 is nearing end-of-life, its installer scheme is no longer used
> on any other branch, and the maintainer of that installer retired some
> years ago.  If you provide a patch, we can take a look and possibly merge
> it for you, but it's unlikely that this will be picked up by a maintainer
> without a patch to review.
>
> If you would like to try patching it, all the necessary files should be in
> 2.7/Tools/msi, and you can feel free to ask questions here if you get
> stuck.  Good luck!
>
> --
> components: +Windows
> nosy: +paul.moore, steve.dower, tim.golden, zach.ware
> priority: normal -> low
> type: compile error -> behavior
>
> ___
> Python tracker 
> <https://bugs.python.org/issue34470>
> ___
>

--

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



[issue34470] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-22 Thread Christopher Knorowski


New submission from Christopher Knorowski :

Steps to repeate (windows 10)

msiexec.exe /i python-2.7.15.amd64.msi ALL_USERS=0 
TARGETDIR=C:\Users\Public\python /qr

(fresh install works without issue)

rm -r C:\Users\Public\python

(On reinstall scripts folder and all site-packages are not copied ie. no Pip or 
easy_install)

msiexec.exe /i python-2.7.15.amd64.msi ALL_USERS=0 
TARGETDIR=C:\Users\Public\python /qr

--
components: Installation
messages: 323921
nosy: cdknorow
priority: normal
severity: normal
status: open
title: windows msi in headless mode fails to install Script directory on 
reinstall if the python folder was deleted but not uninstalled
type: compile error
versions: Python 2.7

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



[issue34469] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-22 Thread Christopher Knorowski


Change by Christopher Knorowski :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

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



[issue34469] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-22 Thread Christopher Knorowski


Christopher Knorowski  added the comment:

Steps to repeate (windows 10)

msiexec.exe /i python-2.7.15.amd64.msi ALL_USERS=0 
TARGETDIR=C:\Users\Public\python /qr

(fresh install works without issue)

rm -r C:/Users/Public/python

msiexec.exe /i python-2.7.15.amd64.msi ALL_USERS=0 
TARGETDIR=C:\Users\Public\python /qr

(Scripts folder and all site-packages are not copied ie. no Pip or easy_install)

--

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



[issue34469] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-22 Thread Christopher Knorowski


Christopher Knorowski  added the comment:

Steps to repeate (windows 10)

msiexec.exe /i python-2.7.15.amd64.msi TARGETDIR=C:/Users/Public/python /qr

(fresh install works without issue)

rm -r C:/Users/Public/python

msiexec.exe /i python-2.7.15.amd64.msi TARGETDIR=C:/Users/Public/python /qr

(Scripts folder and all site-packages are not copied ie. no Pip or easy_install)

--

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



[issue34469] windows msi in headless mode fails to install Script directory on reinstall if the python folder was deleted but not uninstalled

2018-08-22 Thread Christopher Knorowski


New submission from Christopher Knorowski :

Steps to repeate (windows 10)

msiexec.exe /i python-2.7.15.amd64.msi TARGET_DIR=C:/Users/Public/python /qr

(fresh install works without issue)

rm -r C:/Users/Public/python

msiexec.exe /i python-2.7.15.amd64.msi TARGET_DIR=C:/Users/Public/python /qr

(Scripts folder and all site-packages are not copied ie. no Pip or easy_install)

--
components: Installation
messages: 323918
nosy: cdknorow
priority: normal
severity: normal
status: open
title: windows msi in headless mode fails to install Script directory on 
reinstall if the python folder was deleted but not uninstalled
type: compile error
versions: Python 2.7

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



[issue34309] Embedding Python; Py_Initialize / Py_Finalize cycles

2018-08-02 Thread Christopher Schramm


Change by Christopher Schramm :


--
nosy: +cschramm

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



[issue33912] [EASY] test_warnings: test_exec_filename() fails when run with -Werror

2018-06-20 Thread Christopher Frederickson


Change by Christopher Frederickson :


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

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



[issue33578] cjkcodecs missing getstate and setstate implementations

2018-06-07 Thread Christopher Thorne


Christopher Thorne  added the comment:

Thanks Naoki, that simplifies things a lot.

I've updated the PR with a new test case for ISO-2022-JP and a corresponding 
implementation for the encoder state methods.

--

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



[issue33578] cjkcodecs missing getstate and setstate implementations

2018-06-05 Thread Christopher Thorne


Christopher Thorne  added the comment:

Ah, good find. I suppose that means `MultibyteCodec_State` and `pending` are 
both needed to fully capture state, as is done in `decoder.getstate`/`setstate` 
by returning a tuple of both. Unfortunately `encoder.getstate` is defined to 
return an integer, and because `MultibyteCodec_State` can occupy 8 bytes, and 
`pending` can occupy 2 bytes (MAXENCPENDING), we get a total of 10 bytes which 
I think exceeds what a PyLong can represent.

Returning either `pending` or `MultibyteCodec_State` seems infeasible because 
`setstate` will not know how to process it, and both may be needed together.

Some alternatives could be:

1. If we are restricted to returning an integer, perhaps this integer could be 
an index that references a state in a pool of encoder states stored internally 
(effectively a pointer). Managing this state pool seems quite complex.

2. encoder.getstate could be redefined to return a tuple, but obviously this is 
a breaking change. Backwards compatibility could be somewhat preserved by 
allowing setstate to accept either an integer or tuple.

3. Remove `PyObject *pending` from `MultibyteStatefulEncoderContext` and change 
encoders to only use `MultibyteCodec_State`. Not sure how feasible this is.

I think approach 2 would be simplest and matches the decoder interface. 

Does anyone have any opinions or further alternatives?

--

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



[issue33578] cjkcodecs missing getstate and setstate implementations

2018-05-19 Thread Christopher Thorne

New submission from Christopher Thorne <libctho...@gmail.com>:

The cjkcodecs module provides support for various Chinese/Japanese/Korean 
codecs through its MultibyteIncrementalDecoder and MultibyteIncrementalEncoder 
classes.

While working with one of these cjkcodecs (euc-jp), I came across an issue 
where calling TextIOWrapper.tell() was causing a decode error on a valid euc-jp 
file:

>>> with open("/tmp/test", "w", encoding="euc-jp") as f:
... f.write("AB\nうえ\n")
...
6
>>> with open("/tmp/test", "r", encoding="euc-jp") as f:
... f.readline()
... f.tell()
... f.readline()
... f.readline()
...
'AB\n'
4
'うえ\n'
Traceback (most recent call last):
  File "", line 5, in 
UnicodeDecodeError: 'euc_jp' codec can't decode byte 0xa4 in position 0: 
incomplete multibyte sequence

Without the tell(), there is no problem:

>>> with open("/tmp/test", "w", encoding="euc-jp") as f:
... f.write("AB\nうえ\n")
...
6
>>> with open("/tmp/test", "r", encoding="euc-jp") as f:
... f.readline()
... f.readline()
... f.readline()
...
'AB\n'
'うえ\n'
''

After looking at _io_TextIOWrapper_tell_impl in textio.c, I understood that 
tell() is not as trivial as one might expect as it is using a "reconstruction 
algorithm" [1] to account for buffered chunk reads. By default, TextIOWrapper 
reads from its underlying stream in chunks of 8092 bytes and then decodes and 
buffers this data for speed efficiency. As a result, TextIOWrapper.tell() can't 
just call tell() on the underlying stream because the stream's tell() will 
usually be too far ahead. Thus, a reconstruction algorithm is used to calculate 
how many bytes of the buffered chunk have actually been read so far by the user.

The reconstruction algorithm could be trivial for single byte codecs - just 
track the number of characters read so far, e.g. each time read() is called. 
However, for multibyte codecs where the number of bytes representing a 
character is not uniform nor reported by the decoder, the character count alone 
isn't sufficient. What CPython does for this is jump to a "snapshot" point 
where the decoder is in a clean state (i.e. not halfway through a multibyte 
read) and feeds it bytes to generate characters, counting as it goes, until the 
number of characters it tracked from user reads are generated. From this, it 
knows the number of bytes it took to reach the point the user is at and can 
calculate the correct tell() value.

Now this is where the problem comes in: the reconstruction algorithm depends on 
a reliable way to detect when the decoder is in a "clean state". The getstate 
method [2], which returns any pending data the decoder has, is used for this. 
However, in the case of cjkcodecs, the getstate implementation is missing. This 
can be seen in the following example:

>>> import codecs
>>> decoder = codecs.getincrementaldecoder('euc_jp')()
... decoder.decode(b'\xa4\xa6') # Decode a complete input sequence
'う'
>>> decoder.getstate() # There should be no state here (working)
(b'', 0)
>>> decoder.decode(b'\xa4') # Decode first half of a partial input sequence
''
>>> decoder.getstate() # There should be state here (not working)
(b'', 0)

Internally, however, the cjkcodecs do hold state. They just don't expose it.

This leads to unexpected results in the reconstruction algorithm, such as the 
tell() bug demonstrated above.

It appears decoder.setstate [3], encoder.getstate [4], encoder.setstate [5], 
are also not implemented for the cjkcodecs. This leads to other issues in code 
that assumes their implementaton is present (e.g. TextIOWrapper.seek).

I will attach a PR shortly with some tests and proposed implementations. This 
is my first time working with the CPython codebase, so apologies if I've 
overlooked anything.

Finally, here is a somewhat related issue with a mention of the same tell() bug 
at the end: https://bugs.python.org/issue25863
However, the main problem identified in that report requires further changes 
than just adding getstate as it's caused by the more fundamental issue of 
encoder and decoder state not being kept in sync.
(Also, I have added the reporter of that issue to the nosy list for this one as 
I assume they have some familiarity with this bug)

[1] https://docs.python.org/3/library/io.html#id3
[2] 
https://docs.python.org/3/library/codecs.html#codecs.IncrementalDecoder.getstate
[3] 
https://docs.python.org/3/library/codecs.html#codecs.IncrementalDecoder.setstate
[4] 
https://docs.python.org/3/library/codecs.html#codecs.IncrementalEncoder.getstate
[5] 
https://docs.python.org/3/library/codecs.html#codecs.IncrementalEncoder.setstate

--
components: IO, Tests
messages: 317106
nosy: libcthorne, martin.panter
pr

Re: Flask: request vs Request

2018-03-12 Thread Christopher Mullins
>
> Could you please give some context when you reply, TIA
>

Whoops, thanks for the reminder Mark.

So what for the Request is used  for then?


In general when you see that something in Python starts with a capital
letter, that indicates a class. Check out the relevant section of the PEP8
coding style [1], this is a good reference to have on hand.  (This
generalization doesn't apply to builtin types which follow a separate
convention, also outlined in [1] -- and of course there are a numerous
exceptions.)

This holds for your variable in question "request" which is an instance of
the Request class.  Check out [2] for more information on this.  PyCharm
tries to do its best but I've had this problem too.  You can always open up
a python REPL and look at the object yourself:

>>> import flask
>>> r = flask.Request
>>> r

>>> dir(r)

and so on.  When I'm working in python I like to keep one of these open for
this purpose.

HTH,
Chris

[1] https://www.python.org/dev/peps/pep-0008/#class-names
[2] http://flask.pocoo.org/docs/0.12/api/#incoming-request-data
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-10 Thread Christopher Mullins
In the code you linked, I don't see where the *R*equest is used. The
request variable is setup by flask when you annotate the function with the
resource endpoint and POST method. It contains the content of the request
which can be converted to json if that content type was specified.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psychocomputational analysis toolkit in Python?

2018-03-08 Thread Christopher Mullins
> Would it be possible to emulate a minimally functional brain-to-brain
coupling system entirely in Python?

I don't know what that would entail, but the links I shared have a mailing
list and a very responsive gitter, both of which would be great places to
ask about that!  (You're welcome to ask here of course, but this being the
general python mailing list, it's a shot in the dark.)  Good luck!

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


Re: psychocomputational analysis toolkit in Python?

2018-03-08 Thread Christopher Mullins
You might find MNE useful, and if what you're doing happens to fit
somewhere in their package you could contribute to it -- they're a good
group to work with.

https://www.martinos.org/mne/stable/index.html
https://github.com/mne-tools/mne-python
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32216] Document PEP 557 Data Classes (dataclasses module)

2018-02-03 Thread Christopher Barker

Christopher Barker <chris.bar...@noaa.gov> added the comment:

Thanks Raymond. Can a draft be put in a gitHub repo so we can all help out?

--

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



[issue32216] Document PEP 557 Data Classes

2017-12-18 Thread Christopher Barker

Christopher Barker <chris.bar...@noaa.gov> added the comment:

It was suggested that I could contirbute to the docs of dataclasses in this 
issue. Which confuses me, as there doesn't appear to be any content here to 
comment on. But what the heck:

As I've been annoyingly persistent about on the python-dev list, I think we 
need to be quite careful about making type hints appear to be a requirement for 
using dataclasses. In order to counter this, we could:

* have the first couple example be type-less:

@dataclass
class C:
a: ...   # field without a default
b: ... = 0 # field with a default

or something like that.

Then purposely introduce "how to add type hints" a bit down in the docs.

--
nosy: +Chris.Barker

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



Re: connect four (game)

2017-11-25 Thread Christopher Reimer
On Nov 25, 2017, at 9:16 AM, Ian Kelly  wrote:
> 
>> On Sat, Nov 25, 2017 at 10:02 AM, Chris Angelico  wrote:
>>> On Sun, Nov 26, 2017 at 3:36 AM, Ian Kelly  wrote:
 On Sat, Nov 25, 2017 at 6:00 AM, bartc  wrote:
 Where are your unittests for these unittests?
>>> 
>>> No, the point of having unit tests is to build confidence that the
>>> code in question works correctly. It's *possible* that the code is
>>> broken, and that the test is also broken in a way that hides the
>>> brokenness of the code, but this is much less likely than the case
>>> where just the code is broken. This is also the reason why the
>>> philosophy of test-drive development stipulates that one should write
>>> the test *first*, run it and watch it fail (this ensures that the test
>>> is actually testing *something*) and then and only then write the code
>>> to make the test pass.
>> 
>> To be fair, TDD doesn't actually prove that the test isn't broken. It
>> only protects you against one class of error: tests that actually
>> aren't testing anything. Proponents of TDD will argue that this class
>> of error is quite common; true or not, it's still only one particular
>> kind of failure. It's definitely possible for tests to be wrong in
>> such a way that they don't detect faulty code.
>> 
>> So what do we do? WE TEST BY HAND. Ultimately, unit testing is a tool,
>> not a magic wand. It's up to us to actually put it to use to improve
>> code quality.
> 
> Certainly. I wasn't trying to advocate for TDD here, which I don't
> even practice regularly myself.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

For anyone who is interested, "Test-Driven Development with Python: Obey the 
Testing Goat: Using Django, Selenium, and JavaScript" by Harry J.W. Percival. 
The second edition came out this year. A good introduction to unit and function 
testing.

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


Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Christopher Reimer
On Nov 21, 2017, at 5:36 AM, Rustom Mody  wrote:
> 
>> On Tuesday, November 21, 2017 at 5:27:42 PM UTC+5:30, Ned Batchelder wrote:
>>> On 11/20/17 9:50 AM, Stefan Ram wrote:
>>> Ned Batchelder  writes:
 Also, why set headers that prevent the Python-List mailing list from
 archiving your messages?
>>>   I am posting to a Usenet newsgroup. I am not aware of any
>>>   "Python-List mailing list".
>>> 
>>>   I am posting specifically to the Usenet, because I am aware
>>>   of it's rules and I like it and wish to support it.
>>> 
>>>   I do not post to a "mailing list" because I do not know which
>>>   rules apply for mailing lists and whether mailing lists in
>>>   general or any specific mailing list is an environment that I
>>>   like or wish to support.
>>> 
>> 
>> The dual nature of this online community has long been confusing and 
>> complicated.  It's both a newsgroup and a mailing list.  Add in Google 
>> Groups, and you really have three different faces of the same content.
>> 
>> The fact is, posting to comp.lang.python means that your words are also 
>> being distributed as a mailing list. Because of your messages' headers, 
>> they are not in the archive of that list 
>> (https://mail.python.org/pipermail/python-list/2017-November/thread.html), 
>> or in Google Groups 
>> (https://groups.google.com/forum/#!topic/comp.lang.python/0ejrtZ6ET9g). 
>> It makes for odd reading via those channels.
>> 
>> I don't understand the motivation for limiting how words are 
>> distributed, but others on this list also do it. For example, Dennis Lee 
>> Bieber's messages are not in the Python-List archives either. If 
>> something is worth saying, why not let people find it later?
> 
> To which I would add:
> Setting headers is hardly a working method.
> Somebody quotes Stefan or Dennis and they are on the archives
> And some quote including emails some not
> etc
> -- 
> https://mail.python.org/mailman/listinfo/python-list

A troll tried to prove that I was too retarded to program in Python by claiming 
that I asked a question on this list in the archives that could have been 
answered by searching the web. The funny thing is that none of the links that 
the troll provided answered my question.

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


Re: converting numbers into words (Posting On Python-List Prohibited)

2017-11-09 Thread Christopher Reimer
On Nov 9, 2017, at 3:45 AM, John Ladasky  wrote:
> 
>> On Wednesday, November 8, 2017 at 11:40:18 PM UTC-8, Lawrence D’Oliveiro 
>> wrote:
>>> On Thursday, November 9, 2017 at 7:51:35 PM UTC+13, r16...@rguktrkv.ac.in 
>>> wrote:
>>> 
>>> How can I covert numbers into word like ex:-123 One hundred twenty three?
>> 
>> Here’s  one I 
>> did earlier, in Algol 68.
>> 
>> Conversion to Python is left as an exercise for the reader.
> 
> I think that gives away rather more than I wanted the student to see.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I thought the classic homework problem was to convert an Arabic numeral into a 
Roman numeral. Bonus points for correctly converting any number above 12 and/or 
copyright year from any old movie. Most students have seen Roman numerals on 
clocks (1-12).

Maybe that's too hard for today's kids with digital clocks.

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


Keep or drop index.html from Django?

2017-10-28 Thread Christopher Reimer
Greetings,

When I set up my static website using Pelican several years ago, many URLs 
ended with index.html. Now that I'm looking at Django, I got a small set of 
URLs working with and without index.html to point to the correct pages.

I read somewhere that the Django philosophy was to keep the URLs as clean as 
possible (i.e., no *.html at the end). I can go either way with this. What's 
the best practice for this?

Thank you,

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


Re: Python noob having a little trouble with strings

2017-10-27 Thread Christopher Reimer
On Oct 27, 2017, at 1:49 AM, Peter J. Holzer  wrote:
> 
> BTW, I find it hard to believe that PyCharm for the Mac "comes with"
> Python 2.6. Python 2.6 is quite old. The Linux version isn't bundled
> with a python interpreter and just uses whatever is already installed on
> the machine. I guess it's the same for the Mac: Your version of MacOS
> happens to include Python 2.6, so this is what PyCharm uses.

I find it hard to believe that a professor would recommend downloading an IDE 
at the start of an intro class. Students usually start off with a text editor.

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


Re: Application and package of the same name

2017-10-21 Thread Christopher Reimer
On Oct 21, 2017, at 6:08 AM, David Stanek  wrote:

> This is actually a common pattern I see when teaching the language. For
> example, when a student wants to test out a package like requests many
> seem to initially want to create a requests.py module. Then they become
> very confused when they get an AttributeError on requests.get().

For my web scraper program, I'm using "requestor.py" for requests. :)

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


Can't find latest version of 3.4.x on download page

2017-10-18 Thread Christopher Reimer
Greetings,

I'm setting up different test environments for tox. I can't find Windows 
installer for the latest version of Python 3.4 on the download page.

Versions 3.4.5 to 3.4.7 only have the source files available.

Version 3.4.4 is the last version with Windows installers.

Testing on Python 3.4 might be moot for my program. It choked on a starred 
expression in a unit test. The starred expression got changed in Python 3.5 and 
my unit tests pass in Python 3.5/3.6. I don't think I can live without that 
feature. 

Thank you,

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


Re: Best practise for passing time as arguments

2017-10-14 Thread Christopher Reimer
On Oct 14, 2017, at 10:44 AM, Thomas Jollans  wrote:
> 
>> On 14/10/17 19:34, Stefan Ram wrote:
>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>> a post. Use whatever is appropriate in the special case
>>> given, or - to write a general library -, learn the design
>>> of a good existing library, like Time4J, first.
>> 
>>  Though in many cases, an ISO 8601 time string 
>>  represented by a (named )Python tuple should
>>  be sufficient for a time stamp.
>> 
>>  E.g., ( year, month, day, hour, minute, seconds,
>>  zone_offset ).
>> 
> 
> Python provides a datetime (also: date, time, timedelta) type. Use it.
> 
> https://docs.python.org/3/library/datetime.html
> 
> When working with time zones, the standard library needs a little help.
> Luckily, there's a module for that. https://pypi.python.org/pypi/pytz
> 
> -- Thomas
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I wrote a blog post about muddling through the timestamp problem, showing 
examples for datetime, slice-and-dice text, and pytz. Since I was dealing with 
time zone-specific timestamps, I went with pytz in the end.

https://www.kickingthebitbucket.com/2017/04/04/the-python-time-zone-rabbit-hole/

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Christopher Reimer
On Oct 11, 2017, at 9:07 AM, Bill  wrote:
> 
> Grant Edwards wrote:
>> On 2017-10-11, Bill  wrote:
>> 
>> 
>>> [...] I'm not here to "cast stones", I like Python. I just think
>>> that you shouldn't cast stones at C/C++.
>> Not while PHP exists.  There aren't enough stones in the world...
>> 
> 
> PHP seems (seemed?) popular for laying out web pages.  Are their vastly 
> superior options? I'm a little naive in this matter, thus my question.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

AFAIK, JavaScript frameworks has largely replaced PHP. I personally use Pelican 
to generate static web pages and use JavaScript sparingly.

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


Re: How to determine lowest version of Python 3 to run?

2017-10-06 Thread Christopher Reimer
On Oct 6, 2017, at 12:58 PM, Stephan Houben <stephan...@gmail.com.invalid> 
wrote:
> 
> Op 2017-10-06, Christopher Reimer schreef <christopher_rei...@icloud.com>:
> 
>> So I got tox and tox-docker installed. When I went to install Docker
>> for Windows, it wouldn't work because Hyper-V wasn't available on
>> Windows 10 Home. After paying Microsoft $99 for the privilege, I got
>> Windows 10 Pro installed and Docker started working. I've read that
>> all the cool programming kids are using Docker these days. I certainly
>> hope it was worth the cost. O_o
> 
> You could have just used a Linux VM in Virtualbox for $0, and run Docker
> in that.
> 
> Stephan
> -- 
> https://mail.python.org/mailman/listinfo/python-lists 

My $200 Dell laptop couldn't handle that combo and it would add an extra layer 
of complexity to my programming setup.

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


Re: How to determine lowest version of Python 3 to run?

2017-10-06 Thread Christopher Reimer
On Oct 5, 2017, at 3:34 PM, Christopher Reimer <christopher_rei...@icloud.com> 
wrote:
> 
>> On Oct 5, 2017, at 1:11 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote:
>> 
>>> On 10/05/2017 04:23 AM, Christopher Reimer wrote:
>>> 
>>> I'm leaning towards installing the latest minor version of each available 
>>> major version, running tox to run the unit tests against each one, and 
>>> seeing what blows up.
>> 
>> Perhaps you can use the service of Travis (travis-ci.org) to avoid 
>> installing the Python
>> versions yourself. They have lots of older versions available to run tests 
>> on.
>> 
>> Irmen
>> -- 
>> https://mail.python.org/mailman/listinfo/python-list
> 
> Travis might be a bit of an overkill for my project. Someone suggested docker 
> containers and there is a docker plugin for tox that looks promising.
> 
> Chris R. 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

So I got tox and tox-docker installed. When I went to install Docker for 
Windows, it wouldn't work because Hyper-V wasn't available on Windows 10 Home. 
After paying Microsoft $99 for the privilege, I got Windows 10 Pro installed 
and Docker started working. I've read that all the cool programming kids are 
using Docker these days. I certainly hope it was worth the cost. O_o

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


Re: How to determine lowest version of Python 3 to run?

2017-10-05 Thread Christopher Reimer
On Oct 5, 2017, at 1:11 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote:
> 
>> On 10/05/2017 04:23 AM, Christopher Reimer wrote:
>> 
>> I'm leaning towards installing the latest minor version of each available 
>> major version, running tox to run the unit tests against each one, and 
>> seeing what blows up.
> 
> Perhaps you can use the service of Travis (travis-ci.org) to avoid installing 
> the Python
> versions yourself. They have lots of older versions available to run tests on.
> 
> Irmen
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Travis might be a bit of an overkill for my project. Someone suggested docker 
containers and there is a docker plugin for tox that looks promising.

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


Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 3:49 AM, Leam Hall  wrote:
> 
> Folks on IRC have suggested using virtualenv to test code under different 
> python versions. Sadly, I've not found a virtualenv tutorial I understand. 
> Anyone have a link to a good one?
> 
> The next step will be to figure out how to package a project; a good tutorial 
> URL would be appreciated on that, too.
> 
> Thanks!
> 
> Leam
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I'm looking at tox that will automatically set up virtualenv for running unit 
tests under different versions of Python. 

https://tox.readthedocs.io/en/latest/

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


How to determine lowest version of Python 3 to run?

2017-10-04 Thread Christopher Reimer
Greetings,

I've always installed the latest and greatest version of Python 3 to develop my 
own programs. I'm planning to release a program to the public. I could toss in 
a note that the program runs on the latest version of Python 3.6 but I haven't 
tested on earlier versions (i.e., 3.4 and 3.5). AFAIK, I haven't written any 
version-specific code.

How do I determine the lowest version of Python to run?

I'm leaning towards installing the latest minor version of each available major 
version, running tox to run the unit tests against each one, and seeing what 
blows up.

Thank you, 

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


Re: How best to initialize in unit tests?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 6:07 AM, Skip Montanaro  wrote:
> 
> Suppose you want to test a package (in the general sense of the word,
> not necessarily a Python package). You probably have specific unit
> tests, maybe some doctests scattered around in doc strings. Further,
> suppose that package requires you call an initialize function of some
> sort. Where does that go? I know about setUp and setUpClass methods in
> unittest.TestCase. Is order of execution of doctests deterministic
> across modules (say, when tests are run through nosetests)?
> 
> In my case, I didn't know what order things would be called, so I
> added a call to initialize() at the start of every doctest and added a
> setUpClass class method to all my TestCase subclasses. Just in case.
> It worked okay because my initialize function can be called multiple
> times. What about situations where it can only be called once? Do you
> have to define some sort of super_initialize() function for your tests
> which guarantees that your initialize function is called precisely
> once?
> 
> This all seems rather messy. I'm open to better ways to do this, but
> as I've only had one cup of coffee this morning, no spark of insight
> has zapped my frontal cortex as yet.
> 
> Thx,
> 
> Skip
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Seems like you’re overthinking this. You should be able to unit test any part 
of your code in isolation. If not, you need to refactor your code. I generally 
don’t use test classes in pytest.

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


Re: Spacing conventions

2017-09-27 Thread Christopher Reimer
On Sep 27, 2017, at 12:50 AM, Bill  wrote:
> 
> Ever since I download the MyCharm IDE a few days ago, I've been noticing all 
> sort of "spacing  conventions (from PEP) that are suggested.  How do folks 
> regard these in general?
> 
> For instance,  the conventions suggest that
> 
> if x>y :
> pass
> 
> should be written
> if x > y:
>pass
> 
> Personally, I like seeing a space before the colon (:).   And then in
> 
> my_list = [ i for i in range(0, 10) ]
> it complains about my extra space inside of the brackets.
> 
> If you are teaching beginning students, do you expect them to try to follow 
> these sorts of conventions?  Is it perfectly fine to let "taste" guide you 
> (I'm just trying to get a feel for the philosophy here)?   I also notice 
> "break" and exception handling is used much more in Python than in C++, for 
> instance.  I was taught "break" and "continue" led to "unstructured 
> code"--but that was a while back.  I can still see their use  causing 
> potential trouble in (really-long) real-world code.
> 
> Bill
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I came across a Python script on Github that did what I needed except for some 
trivial modifications to make it Python 3 compatible. I did consider 
contributing changes to make the script Python 2 and 3 compatible. However, the 
script was written an idiosyncratic, anti-PEP8 style that was hard to match and 
the author previously rejected all Python 3 contributions. Forking the script 
to make it Python 2/3 compatible *and* PEP8 compliant would require too much 
effort on my part, especially since I needed to use the script only once.

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


Re: errors with json.loads

2017-09-20 Thread Christopher Reimer
> On Sep 20, 2017, at 5:03 PM, Stefan Ram <r...@zedat.fu-berlin.de> wrote:
> 
> Dennis Lee Bieber <wlfr...@ix.netcom.com> writes:
>> After removing all the \xa0 bytes
>> and trying to decode it I get...
> 
>  I did the same here, before I read your post.
>  I got the same results, but did not post them.
> 
>  Someone has posted programs with \xA0 (NBSP IIRC)
>  at the start of lines of the soure here before, in:
> 
> From: Christopher Reimer <christopher_rei...@yahoo.com>
> Newsgroups: comp.lang.python
> Subject: Setting property for current class from property in an different 
> class...
> Date: Wed, 6 Sep 2017 19:24:40 -0700
> Message-ID: <mailman.144.1504751085.2733.python-l...@python.org>
> 
>  , and when I removed them, I was able to execute the
>  source from his post from 2017-Sep-06 without errors.
> 
>  So I was feeling to lazy to bother this time.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I had a NBSP in my code?! News to me...

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


Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread Christopher Reimer
> On Sep 19, 2017, at 9:09 AM, justin walters  
> wrote:
> 
> On Tue, Sep 19, 2017 at 8:59 AM, Grant Edwards 
> wrote:
> 
>>> On 2017-09-19, Rhodri James  wrote:
 On 19/09/17 16:00, Stefan Ram wrote:
 D'Arcy Cain  writes:
> of course, I use calculators and computers but I still understand the
> theory behind what I am doing.
 
   I started out programming in BASIC. Today, I use Python,
   the BASIC of the 21st century. Python has no GOTO, but when
   it is executed, its for loop eventually is implemented using
   a GOTO-like jump instruction. Thanks to my learning of BASIC,
   /I/ can have this insight. Younger people, who never learned
   GOTO, may still be able to use Python, but they will not
   understand what is going on behind the curtains. Therefore, for
   a profound understanding of Python, everyone should learn BASIC
   first, just like I did!
>>> 
>>> Tsk.  You should have learned (a fake simplified) assembler first, then
>>> you'd have an appreciation of what your processor actually did.
>>> 
>>> :-)
>> 
>> Tsk, Tsk.  Before learning assembly, you should design an instruction
>> set and implement it in hardare.  Or at least run in in a VHDL
>> simulator.  [Actually, back in my undergrad days we used AHPL and
>> implemented something like a simplified PDP-11 ISA.]
>> 
>> Alternatively, you should design an instruction set and implement it
>> using microcode and AM2900 bit-slice processors.
>> 
>> --
>> Grant Edwards   grant.b.edwardsYow! Could I have a drug
>>  at   overdose?
>>  gmail.com
>> 
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>> 
> 
> Even Assembly is easy nowadays:
> https://fresh.flatassembler.net/index.cgi?page=content/1_screenshots.txt
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Is assembly still a thing today? 

I wanted to take assembly in college but I was the only student who showed up 
and the class got cancelled. I dabbled with 8-but assembly as a kid. I can't 
imagine what assembly is on a 64-bit processor.

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


Re: Old Man Yells At Cloud

2017-09-17 Thread Christopher Reimer
> On Sep 17, 2017, at 2:19 PM, Ned Batchelder  wrote:
> 
>> On 9/16/17 1:38 AM, Steve D'Aprano wrote:
>> /rant on
>> 
>> So apparently everyone who disagrees that Python should be more like 
>> Javascript
>> is an old greybeard fuddy-duddy yelling "Get off my lawn!" to the cool kids 
>> --
>> and is also too stupid to know how dumb they are.
>> 
>> "Hi, I've been programming in Python for what seems like days now, and here's
>> all the things that you guys are doing wrong. I insist that you fix them
>> immediately, it doesn't matter how much code it will break, that's not
>> important. What is important is that Javascript programmers like me shouldn't
>> be expected to learn anything new or different when they program with 
>> Python."
>> 
>> /rant off
>> 
>> And no, for once it wasn't Ranting Rick.
> 
> The thing that struck me about the interaction (on Python-Ideas, btw) was 
> that Javascript actually is adding new language features at an impressive 
> pace, and many of them seem very Pythonic.  But they sometimes choose 
> different syntax.
> 
> For example, their "spread" operator is ..., where Python uses *:
> 
> new_list = [new_start, *old_list, new_end]
> 
> vs:
> 
> new_array = [new_start, ...old_array, new_end]
> 
> Making Python more like Javascript (in this case) would have required 
> breaking existing Python programs. Javascript could have use * as the spread 
> operator without breaking anyone. But they didn't, and I wonder if anyone 
> petitioned them to keep compatibility with Python to easy the plight of the 
> multi-lingual programmer.
> 
> --Ned.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I came across a blog post that pointed out that those who advocate for a 
particular JavaScript framework probably know enough JavaScript for the 
framework but not enough JavaScript to figure out a problem with the framework. 
Since frameworks are an abstraction of JavaScript, you really need to know 
JavaScript to avoid getting stuck with a framework. I know enough JavaScript to 
get the JQuery eye candy to work and I'm confused by all the frameworks 
available. I picked up a JavaScript ebook to familiarize myself with the 
language. This isn't the same JavaScript that I learned in the early 2000's. 

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


Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-14 Thread Christopher Reimer
> On Sep 13, 2017, at 10:12 PM, Paul Rubin  wrote:
> 
> Ben Finney  writes:
>>> I've never seen one.
>> who has told you... they are working on a Python 3 code base.
> 
> Just because they've told me about it doesn't mean I saw it personally.
> The ones I've seen, including new ones, are Python 2.
> 
> Some people here use Py3 but I haven't heard (or don't remember) enough
> about what they're working on, to know if those are py3 codebases of any
> size.  If they say yes, I'll take their word for it, but this is a
> self-selected group of course.
> 
>> That simply isn't true, unless you think it more likely everyone who
>> discusses their Python 3 code base is lying.
> 
> People discuss Python language issues here a lot, but don't discuss as
> much about code bases.
> 
> I know when I install a new OS (currently Debian 9 which was released
> a month or so ago) and type "python" on the command line, I get Py2.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

FreeNAS 11 (based on FreeBSD) has Python 3.6.1 installed and uses Django for 
the web interface.

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


Re: Merge pdf files using information from two files

2017-09-08 Thread Christopher Reimer
> On Sep 8, 2017, at 1:21 PM, accessnew...@gmail.com wrote:

> Ideas as to how to accomplish this?

Export your spreadsheets as Comma Separated Values (CSV) files and use the CSV 
module to read/write those files.

https://docs.python.org/3/library/csv.html

Chris R. 

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


Re: Setting property for current class from property in an different class...

2017-09-07 Thread Christopher Reimer via Python-list

On 9/6/2017 9:26 PM, Christopher Reimer wrote:


On Sep 6, 2017, at 9:14 PM, Stefan Ram <r...@zedat.fu-berlin.de> wrote:

  I can run this (your code) without an error here (Python 3.6.0),
  from a file named "Scraper1.py":

I'll check tomorrow. I recently switched from 3.5.x to 3.6.1 in the PyCharm 
IDE. It's probably FUBAR in some obscure way.


I uninstalled Python 3.6.0 (32-bit) and Python 3.6.1 (64-bit), installed 
Python 3.6.2 (64-bit), and everything now works.


Thanks,

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


  1   2   3   4   5   6   7   8   >