What's the enum for a button press event in pygobject 3?

2020-07-30 Thread Chris Green
I am going round and round in steadily increasing frustration trying
to find the constants for button events in Pygobject/Gtk 3.

I have the following imports:-

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk


The old GTK 2 code had (I think):-

if (event.type == gtk.gdk.BUTTON_PRESS):


So what is BUTTON_PRESS in the new version, I simply can't find a
straightforward description of it or example of its use.


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


How to find code that causes a 'deprecated' warning?

2020-07-30 Thread Chris Green
I am getting the following warning from a program I have just
converted from gtk 2 to gtk 3 :-

(abook:58240): Gtk-WARNING **: 12:01:58.064: Theme parsing error:
gtk.css:66:28: The :prelight pseudo-class is deprecated. Use :hover
instead.

How do I find what is causing the warning?  I'm not using the prelight
pseudo-class directly in my code anywhere.

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


Re: How to find code that causes a 'deprecated' warning?

2020-07-30 Thread Peter Otten
Chris Green wrote:

> I am getting the following warning from a program I have just
> converted from gtk 2 to gtk 3 :-
> 
> (abook:58240): Gtk-WARNING **: 12:01:58.064: Theme parsing error:
> gtk.css:66:28: The :prelight pseudo-class is deprecated. Use :hover
> instead.
> 
> How do I find what is causing the warning?  I'm not using the prelight
> pseudo-class directly in my code anywhere.

>From reading the message I would guess that the culprit is the file gtk.css, 
line 66 specifically ;)


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


Issue with Python installation for a beginner Python coder.

2020-07-30 Thread Sarvesh Poddar via Python-list
Hi,
I re-installed Python in my Windows system as the earlier one was not able to 
import modules. But now I am not able to open IDLE after multiple tries. 
Can you guys help me? I am a beginner and tried out a lot of solutions provided 
on the internet and it's just not getting fixed.
Please help. I look forward to it. 
PS : Falling in love with Python, slow and steady! 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to diagnose import error when importing from .so file?

2020-07-30 Thread Christian Gollwitzer

Am 29.07.20 um 23:01 schrieb Chris Green:

Even more annoying is that most of what's in pyscand.so is constants,
there's only a couple of functions in there, so there's very little to
it really.

If there are really only constants, you could import it into Python 2 
and dump the content e.g. as a JSON file to read it in under Python 3.


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


questions re: calendar module

2020-07-30 Thread o1bigtenor
Greetings

I regularly work in planning through multiple years at once.
This means that I like to have a lot of stuff available in a calendar
function.
Python seems to be locked when I need to display more than 1 year at a
time.

I don't see a way to display something like 3 years worth of calendar
starting at a point 23 months from now.
(I see how to display 1 year at a time but not multiple years.)

Is there a way to do this?

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


Re: What's the enum for a button press event in pygobject 3?

2020-07-30 Thread MRAB

On 2020-07-30 11:09, Chris Green wrote:

I am going round and round in steadily increasing frustration trying
to find the constants for button events in Pygobject/Gtk 3.

I have the following imports:-

 import gi
 gi.require_version('Gtk', '3.0')
 from gi.repository import Gtk
 from gi.repository import Gdk


The old GTK 2 code had (I think):-

 if (event.type == gtk.gdk.BUTTON_PRESS):


So what is BUTTON_PRESS in the new version, I simply can't find a
straightforward description of it or example of its use.



I believe it's:

Gdk.EventType.BUTTON_PRESS

There's documentation here:

https://lazka.github.io/pgi-docs/#Gdk-3.0/enums.html#Gdk.EventType.BUTTON_PRESS
--
https://mail.python.org/mailman/listinfo/python-list


pip 20.2 release, plus changes coming in 20.3

2020-07-30 Thread Sumana Harihareswara
On behalf of the Python Packaging Authority, I am pleased to announce 
that we have just released pip 20.2, a new version of pip. You can 
install it by running python -m pip install --upgrade pip.


The highlights for this release are:

   - The beta of the next-generation dependency resolver is available
   - Faster installations from wheel files
   - Improved handling of wheels containing non-ASCII file contents
   - Faster `pip list` using parallelized network operations
   - Installed packages now contain metadata about whether they were
   directly
   requested by the user (PEP 376’s REQUESTED file)

The new dependency resolver is *off by default* because it is *not yet
ready for everyday use*. The new dependency resolver is significantly
stricter and more consistent when it receives incompatible instructions,
and reduces support for certain kinds of constraints files, so some
workarounds and workflows may break. Please test it with the
`--use-feature=2020-resolver` flag. Please see our guide on how to test 
and migrate, and how to report issues

.

We are preparing to change the default dependency resolution behavior 
and make the new resolver the default in pip 20.3 (in October 2020).


This release also partially optimizes pip’s network usage during
installation (as part of a Google Summer of Code project by McSinyx
). 
Please test it with `pip install --use-feature=2020-resolver 
--use-feature=fast-deps` and report bugs to the issue tracker

. This
functionality is *still experimental* and *not ready for everyday use*.

You can find more details (including deprecations and removals) in the
changelog .

As with all pip releases, a significant amount of the work was 
contributed by pip’s user community. Huge thanks to all who have 
contributed, whether through code, documentation, issue reports and/or 
discussion. Your help keeps pip improving, and is hugely appreciated.


Specific thanks go to Mozilla (through its Mozilla Open Source Support
 Awards) and to the Chan Zuckerberg
Initiative  DAF, an advised fund of
Silicon Valley Community Foundation, for their funding that enabled
substantial work on the new resolver.


--
Sumana Harihareswara
pip project manager via contract with PSF
Changeset Consulting
https://changeset.nyc
--
https://mail.python.org/mailman/listinfo/python-list


Re: What's the enum for a button press event in pygobject 3?

2020-07-30 Thread Chris Green
MRAB  wrote:
> On 2020-07-30 11:09, Chris Green wrote:
> > I am going round and round in steadily increasing frustration trying
> > to find the constants for button events in Pygobject/Gtk 3.
> > 
> > I have the following imports:-
> > 
> >  import gi
> >  gi.require_version('Gtk', '3.0')
> >  from gi.repository import Gtk
> >  from gi.repository import Gdk
> > 
> > 
> > The old GTK 2 code had (I think):-
> > 
> >  if (event.type == gtk.gdk.BUTTON_PRESS):
> > 
> > 
> > So what is BUTTON_PRESS in the new version, I simply can't find a
> > straightforward description of it or example of its use.
> > 
> > 
> I believe it's:
> 
> Gdk.EventType.BUTTON_PRESS
> 
> There's documentation here:
> 
> https://lazka.github.io/pgi-docs/#Gdk-3.0/enums.html#Gdk.EventType.BUTTON_PRESS

Brilliant, thank you, just what I needed.

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


Re: How to find code that causes a 'deprecated' warning?

2020-07-30 Thread Chris Green
Peter Otten <[email protected]> wrote:
> Chris Green wrote:
> 
> > I am getting the following warning from a program I have just
> > converted from gtk 2 to gtk 3 :-
> > 
> > (abook:58240): Gtk-WARNING **: 12:01:58.064: Theme parsing error:
> > gtk.css:66:28: The :prelight pseudo-class is deprecated. Use :hover
> > instead.
> > 
> > How do I find what is causing the warning?  I'm not using the prelight
> > pseudo-class directly in my code anywhere.
> 
> >From reading the message I would guess that the culprit is the file gtk.css, 
> line 66 specifically ;)
> 
Oops, yes! :-)  I guess that came with the [x]ubuntu installation,
it's in ~/.config/gtk-3.0/gtk.css so I deny any responsibility for it!

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


Re: Winreg

2020-07-30 Thread Barry Scott
You left python list off your reply.

> On 29 Jul 2020, at 23:38, R Pasco  wrote:
> 
> Hi, Barry,
> 
> On Wed, Jul 29, 2020 at 5:12 PM Barry  > wrote:
> 
> > On 29 Jul 2020, at 19:50, R Pasco  > > wrote:
> > 
> > I'm running python 3.8 on Windows 8.1 x64. Running the following code
> > produces no errors but does not add a key, name or value. I had no problems
> > doing this using _wirreg under python 2.7. Any insight will be helpful.
> 
> How do you check that the key is present?
> 
> I'm using regedit.exe to try to view it. 
> 
> Are you aware that there is one registry for 32 bit code and a separate 
> registry for 64 bit code.
> 
> Only vaguely. Are the "separate" registries really 64 and 32 views of the one 
> and only Registry ? That is, using Winreg ?
> Some examples use "winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_32KEY" as the 
> access mode. Not sure what this does.
> I am using python 64-bit, so what should the argument value "access=" be set 
> to in the call to "winreg.CreateKeyEx()" ?

Yes they are views.

I cannot remember the details, but I suggest that you look up the details on 
microsoft's MSDN for the info you need.

Searching for KEY_WOW64_32KEY takes you into thoses docs for example.

Barrry

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


Gtk.TextBuffer problem on converting from GTK+ 2 to GTK+ 3

2020-07-30 Thread Chris Green
I'm converting a program from Python 2 gtk+ 2 to Python 3 and gtk+ 3.
It's mostly gone reasonably smoothly but I can't get multi-line text
entry to work.

The class that provides text entry (both single and multi-line) is:-

# 
# 
# Field on the GUI 
# 
class guiField:
widget = None
lines = 1
# 
# 
# Initialise the field 
# 
def __init__(self, lines=1):
self.lines = lines
if (self.lines > 1):
self.buffer = Gtk.TextBuffer()
self.view = Gtk.TextView()
self.view.set_size_request(-1, 24 * lines)
self.view.set_accepts_tab(False)
# self.widget = self.view 
self.widget = Gtk.ScrolledWindow()
self.widget.add(self.view)
self.widget.set_policy(Gtk.PolicyType.AUTOMATIC, 
Gtk.PolicyType.AUTOMATIC)
self.widget.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
else:
self.widget = Gtk.Entry()
# 
# 
# get text from field 
# 
def get_text(self):
if (self.lines > 1):
[start, end] = self.buffer.get_bounds()
print(self.buffer.get_text(start, end, False))
return self.buffer.get_text(start, end, False)
else:
return self.widget.get_text()
# 
# 
# put text into a field 
# 
def set_text(self, text):
if (self.lines > 1):
self.buffer.set_text(text) 
else: 
self.widget.set_text(text) 


The single line Gtk.Entry widgets work fine, text gets loaded, I can
change it and save it.

The multi-line Gtk.TextBuffer ones refuse to work at all, no errors or
anything but text won't load into them or save out of them.  They used
to work fine in gtk+ 2.

Text loaded into the Gtk.TextBuffer using set_text() doesn't appear,
the text boxes are empty even though the 'text' parameter does have a
string in it (I've checked with a print()).  I can enter text using
the keyboard but that text isn't retrieved by the get_text() method.

What am I doing wrong?  Virtually nothing has changed in this part of
my code between gtk+ 2 and gtk+ 3, just the import and gtk to Gtk and
a couple of enum formats.

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


Re: Gtk.TextBuffer problem on converting from GTK+ 2 to GTK+ 3

2020-07-30 Thread MRAB

On 2020-07-30 17:23, Chris Green wrote:

I'm converting a program from Python 2 gtk+ 2 to Python 3 and gtk+ 3.
It's mostly gone reasonably smoothly but I can't get multi-line text
entry to work.

The class that provides text entry (both single and multi-line) is:-

 #
 #
 # Field on the GUI
 #
 class guiField:
 widget = None
 lines = 1
 #
 #
 # Initialise the field
 #
 def __init__(self, lines=1):
 self.lines = lines
 if (self.lines > 1):
 self.buffer = Gtk.TextBuffer()
 self.view = Gtk.TextView()
 self.view.set_size_request(-1, 24 * lines)
 self.view.set_accepts_tab(False)
 # self.widget = self.view
 self.widget = Gtk.ScrolledWindow()
 self.widget.add(self.view)
 self.widget.set_policy(Gtk.PolicyType.AUTOMATIC, 
Gtk.PolicyType.AUTOMATIC)
 self.widget.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
 else:
 self.widget = Gtk.Entry()
 #
 #
 # get text from field
 #
 def get_text(self):
 if (self.lines > 1):
 [start, end] = self.buffer.get_bounds()
 print(self.buffer.get_text(start, end, False))
 return self.buffer.get_text(start, end, False)
 else:
 return self.widget.get_text()
 #
 #
 # put text into a field
 #
 def set_text(self, text):
 if (self.lines > 1):
 self.buffer.set_text(text)
 else:
 self.widget.set_text(text)


The single line Gtk.Entry widgets work fine, text gets loaded, I can
change it and save it.

The multi-line Gtk.TextBuffer ones refuse to work at all, no errors or
anything but text won't load into them or save out of them.  They used
to work fine in gtk+ 2.

Text loaded into the Gtk.TextBuffer using set_text() doesn't appear,
the text boxes are empty even though the 'text' parameter does have a
string in it (I've checked with a print()).  I can enter text using
the keyboard but that text isn't retrieved by the get_text() method.

What am I doing wrong?  Virtually nothing has changed in this part of
my code between gtk+ 2 and gtk+ 3, just the import and gtk to Gtk and
a couple of enum formats.

You're creating a TextBuffer and a TextView, but I don't see any code 
that ties them together. How would the view know to display the contents 
of the buffer?

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


Re: why is requests 2.24 behaving differently on different Win10Pro PCs?

2020-07-30 Thread Barry


> On 29 Jul 2020, at 23:06, nhpython  wrote:
> 
> python 3.6+
> requests 2.24
> 2- windows 10 Pro version 2004, build 19041.388
> 1- kubuntu 18.04
> 1-suse leap 15.2
> 
> Questions
> 1. how do I begin to diagnose the source of the problem?
> 2. Has anyone experienced this behavior?
> 
> 
> I have 4 PCs running the same code. On 3 they work, but 1 fails. 
> 
> I have 2 win10Pros running the same code on the same network on the same 
> subnet, which uses "requests.get()" 1 PC works fine; the code executes 
> perfectly, but the other FAILS. (statusCode = 200, but the website doesn't 
> send webpage) 
> 
> The error response from the website:
> 
> We've detected unusual activity from your computer network
> To continue, please click the box below to let us know you're not a robot. 
> Why did this happen?
> Please make sure your browser supports JavaScript and cookies and that you 
> are not blocking them from loading. For more information you can review our 
> Terms of Service and Cookie Policy.
> 
> BTW, I tried reverting back to "urllib.request" and the same problem appears. 
> 1 PC works the other fails.
> I even tried "HTMLsession" which renders javascript. Same problem.
> 
Sounds like the service you are accessing has a rate limit or other form of 
defence.
And your requests are triggering the defences. What happens if you browse to 
the site?

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

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


Winreg

2020-07-30 Thread R Pasco
 I can't find instructions for the proper way to reply to 'python list'. Is
it simply a matter of keeping the message title identical to the original
message and emailing again to [email protected] ? I'll reply both ways
to test this.

Yes, it's the 64/32-bit views that got me stuck. I think I've got it mostly
figured out. The key HKEY_LOCAL_MACHINE:SOFTWARE requires KEY_WOW64_64KEY
to be 'OR'ed. Winreg gives no indication of this requirement, but the
Windows doc "Redirected, Shared, and Reflected Keys Under WOW64" does
specifically mention  HKEY_CURRENT_USER :SOFTWARE as needing this added
access.

By the way, I'm running python X64, so the program is a "64 bit"
application. Strangely, the KEY_WOW64_32KEY access rights param also works
identically.

To sum it up the pertinent code, so far, is:
==
# Be able to test creating both WOW64 and non-WOW64 key paths.
if 1 :
hive = winreg.HKEY_LOCAL_MACHINE
hivename = 'HKEY_LOCAL_MACHINE'
else :
hive = winreg.HKEY_CURRENT_USER
hivename = 'HKEY_CURRENT_USER'
#
parent_keypath = 'Software'   # Both hives happen to have this top
level key.
newsubkey = 'AAA New Leaf Key, Process PID={}' .format( os.getpid() )

# Note keys created in HKEY_LOCAL_MACHINE::SOFTWARE will be viewed in
RegEdit
#   at HKEY_LOCAL_MACHINE:SOFTWARE\*Wow6432Node*\{newsubkey}.
CreateKeyEx
#   access rights must be set to [winreg.KEY_ALL_ACCESS |
winreg.KEY_WOW64_64KEY]
# -OR-
#   [winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_32KEY] (??? Why does this
also work ?)
#
newsubkeyPath = os.path.join( parent_keypath, newsubkey )

valuename = 'NewString'
value = 'New String Value'

with winreg.ConnectRegistry( None, hive ) as hivehndl :

with winreg.OpenKeyEx( hivehndl, parent_keypath ) as
parentpath_hndl :

with winreg.CreateKeyEx( parentpath_hndl, newsubkey, 0,
# winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY ) as
newkeyhndl :
winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_32KEY ) as
newkeyhndl :

winreg.SetValueEx( newkeyhndl, valuename, 0, winreg.REG_SZ,
value )

#end
==

Thanks for all the help.
Ray Pasco
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Non IDE development strategy - what do others do that's fairly simple?

2020-07-30 Thread Marco Sulla
What you want is a branch, I guess.

https://www.mercurial-scm.org/wiki/Branch

For simplicity, I suggest you have two different directories: one for the
development branch and the other for the production branch.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Winreg

2020-07-30 Thread Barry Scott
Use the Reply or Reply-To-All feature of your email program and it will do the 
rest for you.

Barry


> On 30 Jul 2020, at 20:14, R Pasco  wrote:
> 
> I can't find instructions for the proper way to reply to 'python list'. Is
> it simply a matter of keeping the message title identical to the original
> message and emailing again to [email protected] ? I'll reply both ways
> to test this.
> 
> Yes, it's the 64/32-bit views that got me stuck. I think I've got it mostly
> figured out. The key HKEY_LOCAL_MACHINE:SOFTWARE requires KEY_WOW64_64KEY
> to be 'OR'ed. Winreg gives no indication of this requirement, but the
> Windows doc "Redirected, Shared, and Reflected Keys Under WOW64" does
> specifically mention  HKEY_CURRENT_USER :SOFTWARE as needing this added
> access.
> 
> By the way, I'm running python X64, so the program is a "64 bit"
> application. Strangely, the KEY_WOW64_32KEY access rights param also works
> identically.
> 
> To sum it up the pertinent code, so far, is:
> ==
># Be able to test creating both WOW64 and non-WOW64 key paths.
>if 1 :
>hive = winreg.HKEY_LOCAL_MACHINE
>hivename = 'HKEY_LOCAL_MACHINE'
>else :
>hive = winreg.HKEY_CURRENT_USER
>hivename = 'HKEY_CURRENT_USER'
>#
>parent_keypath = 'Software'   # Both hives happen to have this top
> level key.
>newsubkey = 'AAA New Leaf Key, Process PID={}' .format( os.getpid() )
> 
># Note keys created in HKEY_LOCAL_MACHINE::SOFTWARE will be viewed in
> RegEdit
>#   at HKEY_LOCAL_MACHINE:SOFTWARE\*Wow6432Node*\{newsubkey}.
> CreateKeyEx
>#   access rights must be set to [winreg.KEY_ALL_ACCESS |
> winreg.KEY_WOW64_64KEY]
># -OR-
>#   [winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_32KEY] (??? Why does this
> also work ?)
>#
>newsubkeyPath = os.path.join( parent_keypath, newsubkey )
> 
>valuename = 'NewString'
>value = 'New String Value'
> 
>with winreg.ConnectRegistry( None, hive ) as hivehndl :
> 
>with winreg.OpenKeyEx( hivehndl, parent_keypath ) as
> parentpath_hndl :
> 
>with winreg.CreateKeyEx( parentpath_hndl, newsubkey, 0,
># winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY ) as
> newkeyhndl :
>winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_32KEY ) as
> newkeyhndl :
> 
>winreg.SetValueEx( newkeyhndl, valuename, 0, winreg.REG_SZ,
> value )
> 
>#end
> ==
> 
> Thanks for all the help.
> Ray Pasco
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Gtk.TextBuffer problem on converting from GTK+ 2 to GTK+ 3

2020-07-30 Thread Chris Green
MRAB  wrote:
> > 
> > What am I doing wrong?  Virtually nothing has changed in this part of
> > my code between gtk+ 2 and gtk+ 3, just the import and gtk to Gtk and
> > a couple of enum formats.
> > 
> You're creating a TextBuffer and a TextView, but I don't see any code 
> that ties them together. How would the view know to display the contents 
> of the buffer?

Absolutely right, thank you. I should have spotted that.  I think the
Gtk.TextView contructor used to take a buffer parameter but the
version 3 one doesn't so I had removed it. Hence, as you say, no code
tying them together.  I've simply changed to:-

self.view = Gtk.TextView.new_with_buffer(self.buffer)

... and all is well again.


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


Re: Winreg

2020-07-30 Thread dn via Python-list

On 31/07/2020 07:25, Barry Scott wrote:

Use the Reply or Reply-To-All feature of your email program and it will do the 
rest for you.



I can't find instructions for the proper way to reply to 'python list'. Is
it simply a matter of keeping the message title identical to the original
message and emailing again to [email protected] ? I'll reply both ways
to test this.


Be aware, using "Reply" (only) in at least some 
email-clients/webmail-apps will result in the reply going only to the 
previous-sender cf to the list.

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


replying to the mailing list (was: Winreg)

2020-07-30 Thread Cameron Simpson
On 30Jul2020 20:25, Barry Scott  wrote:
>Use the Reply or Reply-To-All feature of your email program and it will do the 
>rest for you.

Plain "reply" is often only "reply-to-author" for many mailers. I use 
"reply-to-all" myself, and edit the headers if that seems excessive.  
Some mailers (eg mutt) also have a "list-reply" operation, which should 
also be correct, arguably more correct.

>> On 30 Jul 2020, at 20:14, R Pasco  wrote:
>> I can't find instructions for the proper way to reply to 'python 
>> list'. Is
>> it simply a matter of keeping the message title identical to the original
>> message and emailing again to [email protected] ? I'll reply both ways
>> to test this.

Using the same subject is _not_ enough. Messages are connected together 
with the "In-Reply-To:" header, which is automatically set by your 
mailer's "reply" function (regardless of the flavour mentioned above).

So please just reply to the relevant list message, and make sure the 
list address ([email protected]) is in the resulting to/cc.

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


Re: Winreg

2020-07-30 Thread Eryk Sun
On 7/30/20, R Pasco  wrote:

>   access rights must be set to [winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY

It's a bad practice to request more access than you require, at the
very least because the request may fail with access denied for no good
reason.

KEY_ALL_ACCESS includes all applicable standard rights (WRITE_OWNER,
WRITE_DAC, READ_CONTROL, DELETE) and all key rights (KEY_QUERY_VALUE,
KEY_SET_VALUE, KEY_CREATE_SUB_KEY, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY,
KEY_CREATE_LINK). For an existing key, do you need to change the
owner, read and modify the security, delete the key, set a symlink,
etc? It looks like you just need to set a value, i.e. KEY_SET_VALUE.

>   winreg.KEY_WOW64_32KEY] (??? Why does this also work ?)

By default a 64-bit process doesn't see redirected keys, but if you
need to access them, use KEY_WOW64_32KEY in the desired access.
Normally a 32-bit process under WOW64 sees redirected keys, and if you
need to access the non-redirected keys, use KEY_WOW64_64KEY.

Note that KEY_WOW64_64KEY and KEY_WOW64_32KEY access modes only affect
runtime redirection. As with the standard MAXIMUM_ALLOWED access mode,
they're not assignable rights that can be granted or denied in a key
object's access control list.

>  with winreg.ConnectRegistry( None, hive ) as hivehndl

There is no need to call ConnectRegistry here. By default, predefined
handles are resolved to local key handles. Also, if you actually need
to access a remote machine, note that it's nonsensical to try to
connect to HKEY_CURRENT_USER. The API allows it, but why would one
assume that the remote machine will have a profile for the current
user's SID? The remote system will most likely just connect to a
handle for the default user profile.

> The key HKEY_LOCAL_MACHINE:SOFTWARE requires KEY_WOW64_64KEY
> to be 'OR'ed. Winreg gives no indication of this requirement, but the
> Windows doc "Redirected, Shared, and Reflected Keys Under WOW64" does
> specifically mention  HKEY_CURRENT_USER :SOFTWARE as needing this added
> access.

At the machine level, the software hive is stored on disk at
"%SystemRoot%\System32\config\SOFTWARE" and mounted at
"\REGISTRY\MACHINE\SOFTWARE". For a WOW64 process, by default there is
extensive runtime redirection of keys in this hive to the subkeys
"WOW6432Node" and "Classes\WOW6432Node".

At the user level, there are two hives mounted. The user profile is
stored on disk at "%USERPROFILE%\NTUSER.DAT" and mounted at
"\REGISTRY\USER\", where "" is the string form of the user's
security identifier (e.g. "S-1-5-21"). For
a WOW64 process, there is no redirection of subkeys that are
physically stored in this hive.

The user's software classes hive is stored on disk at
"%LOCALAPPDATA%\Microsoft\Windows\UsrClass.dat" and mounted at
"\REGISTRY\USER\_Classes". In the user profile, the
"Software\Classes" key is a symbolic link to the latter. For a WOW64
process, some subkeys in the classes hive are redirected to subkeys in
"WOW6432Node" (i.e. "Software\Classes\WOW6432Node"). It's just a
limited subset, including "CLSID", "DirectShow", "Interface", "Media
Type", and "MediaFoundation".

---

One never sees "\REGISTRY\MACHINE" and "\REGISTRY\USER" in the
registry API because it's designed to always use the "RootDirectory"
handle in the native NT object attributes [1]. For local access, the
API maps real handles for "\REGISTRY\MACHINE" and "\REGISTRY\USER" to
the predefined pseudo-handles HKEY_LOCAL_MACHINE and HKEY_USERS.
Similarly, HKEY_CURRENT_USER is mapped to a handle for
"\REGISTRY\USER\", where "" is the string form of the user's
security identifier. For remote access via RegConnectRegistryW (i.e.
winreg.ConnectRegistry), the predefined handles are mapped to
remote-procedure-call (RPC) handles that proxy real key handles on the
remote system.

[1] 
https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_object_attributes
-- 
https://mail.python.org/mailman/listinfo/python-list