Giter VIP home page Giter VIP logo

pywin32's Introduction

pywin32

CI PyPI - Version PyPI - Python Version PyPI - Downloads License - PSF-2.0


This is the readme for the Python for Win32 (pywin32) extensions, which provides access to many of the Windows APIs from Python.

See CHANGES.txt for recent notable changes.

Docs

The docs are a long and sad story, but there's now an online version of the helpfile that ships with the installers (thanks @ofek!). Lots of that is very old, but some is auto-generated and current. Would love help untangling the docs!

Support

Feel free to open issues for all bugs (or suspected bugs) in pywin32. pull-requests for all bugs or features are also welcome.

However, please do not open github issues for general support requests, or for problems or questions using the modules in this package - they will be closed. For such issues, please email the python-win32 mailing list - note that you must be subscribed to the list before posting.

Binaries

Binary releases are deprecated. While they are still provided, find them here

Installing via PIP

You should install pywin32 via pip - eg,

python -m pip install --upgrade pywin32

There is a post-install script (see below) which should not be run inside virtual environments; it should only be run in "global" installs.

For unreleased changes, you can download builds made by github actions - choose any "workflow" from the main branch and download its "artifacts")

Installing globally

Outside of a virtual environment you might want to install COM objects, services, etc. You can do this by executing:

python Scripts/pywin32_postinstall.py -install

From the root of your Python installation.

If you do this with normal permissions it will be global for your user (a few files will be copied to the root of your Python install and some changes made to HKCU). If you execute this from an elevated process, it will be global for the machine (files will be copied to System32, HKLM will be changed, etc)

Running as a Windows Service

To run as a service, you probably want to install pywin32 globally from an elevated command prompt - see above.

You also need to ensure Python is installed in a location where the user running the service has access to the installation and is able to load pywintypesXX.dll and pythonXX.dll. In particular, the LocalSystem account typically will not have access to your local %USER% directory structure.

Troubleshooting

If you encounter any problems when upgrading like the following:

The specified procedure could not be found
Entry-point not found

It usually means one of 2 things:

  • You've upgraded an install where the post-install script has previously run. So you should run it again:

    python Scripts/pywin32_postinstall.py -install

    This will make some small attempts to cleanup older conflicting installs.

  • There are other pywin32 DLLs installed in your system, but in a different location than the new ones. This sometimes happens in environments that come with pywin32 pre-shipped (eg, anaconda?).

    The possible solutions here are:

    • Run the "post_install" script documented above.
    • Otherwise, find and remove all other copies of pywintypesXX.dll and pythoncomXX.dll (where XX is the Python version - eg, "39")

Building from source

Install Visual Studio 2019 (later probably works, but options might be different), select "Desktop Development with C++", then the following options:

  • Windows 10 SDK (latest offered I guess? At time of writing, 10.0.18362)
  • "C++ for MFC for ..."
  • ARM build tools if necessary.

(the free compilers probably work too, but haven't been tested - let me know your experiences!)

setup.py is a standard distutils build script, so you probably want:

python setup.py install

or

python setup.py --help

Some modules need obscure SDKs to build - setup.py should succeed, gracefully telling you why it failed to build them - if the build actually fails with your configuration, please open an issue.

Release process

The following steps are performed when making a new release - this is mainly to form a checklist so @mhammond doesn't forget what to do :)

  • Ensure CHANGES.txt has everything worth noting. Update the header to reflect the about-to-be released build and date, commit it.

  • Update setup.py with the new build number.

  • Execute make.bat, wait forever, test the artifacts.

  • Upload .whl artifacts to pypi - we do this before pushing the tag because they might be rejected for an invalid README.md. Done via py -3.? -m twine upload dist/*XXX*.whl.

  • Commit setup.py (so the new build number is in the repo), create a new git tag

  • Upload the .exe installers to github.

  • Update setup.py with the new build number + ".1" (eg, 123.1), to ensure future test builds aren't mistaken for the real release.

  • Make sure everything is pushed to github, including the tag (ie, git push --tags)

  • Send mail to python-win32

pywin32's People

Contributors

arihant2math avatar avasam avatar biswa96 avatar bobince avatar cristifati avatar elbakramer avatar jaraco avatar jborean93 avatar joankaradimov avatar konserw avatar kxrob avatar larsimmisch avatar lincolnpuzey avatar mhammond avatar nczeczulin avatar niyas-sait avatar ofek avatar rassilon avatar rupole avatar sreicheltptv avatar stevenwinfield avatar thopiekar avatar timgates42 avatar tjguk avatar tonyroberts avatar trentm avatar vasily-v-ryabov avatar vernondcole avatar wkschwartz avatar wxinix-2022 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywin32's Issues

reading SQL dates before the epoch creates strange results

Insert* a date before 1970-01-01 00:00:00.000 GMT
into a database and try reading it from Python using the
odbc driver.

* This will probably require using something other than
Python. I haven't tested inserting such dates, only
reading them.

The bug probably exists because mktime returns -1 for
dates that it can't represent. I whipped up the following
untested patch which will turn all unrepresentable dates
into the epoch. This is much better than returning
random data from memory.

I don't know enough about the driver to suggest a
better way to do this.

diff -ur win32-orig/src/odbc.cpp win32/src/odbc.cpp
--- win32-orig/src/odbc.cpp 1997-06-13
10:37:06.000000000 -0500
+++ win32/src/odbc.cpp 2003-06-28
17:00:06.000000000 -0500
@@ -427,7 +427,11 @@
gt.tm_hour = dt->hour;
gt.tm_min = dt->minute;
gt.tm_sec = dt->second;
- return dbiMakeDate(PyInt_FromLong(mktime(&gt)));
+ time_t t = mktime(&gt);
+ // Set dates outside of time_t's range to the epoch.
+ if (t == (time_t)-1)
+ t = 0;
+ return dbiMakeDate(PyInt_FromLong(t)));
}

static PyObject *rawCopy(const void *v, int sz)

Reported by: rlaager

Original Ticket: "pywin32/bugs/29":https://sourceforge.net/p/pywin32/bugs/29

Manual Uninstallation Procedure

Due to the fact that the installation failed in the case
where the target directory contained a space, I now
have a half-installed copy of the Win32 extensions and
no installation log available for uninstallation.

Please provide me with the correct procedure for manual
uninstallation of this broken version of the utility such
that I may avoid future registry corruption.

Reported by: nobody

Original Ticket: "pywin32/feature-requests/1":https://sourceforge.net/p/pywin32/feature-requests/1

ASP Response.End is flakey

From email:
Anyone else seeing this?

PythonWin 2.1.1 / win32all 1.5.1 / Win 2k Server

*** Script 1 ***
<%@language="Python"%>

Before End

<%
Response.End()
%>

After End

*** Output ***
Before End After End

*** Script 2 ***
<%@language="Python"%>

Before End

<%
Response.end()
%>

After End

*** Output ***

Before End

*** Script 3 ***
<%@language="Python"%>
<%
Response.end()
%>

After End

*** Output ***
HTTP/1.1 500 Server Error

--
Yes, I too have found it to be the case in the past
(haven't checked
recently) that Response.End() does not in fact end the
response in
python under asp.

Reported by: mhammond

Original Ticket: "pywin32/bugs/7":https://sourceforge.net/p/pywin32/bugs/7

Can't configuring the tools menu bar

I usually run PythonWin with the debugger tool bar
present. However, there does not seem to be any way of
enabling it when PythonWin is loaded. (I.e., the View |
Toolbars | Debugging can not be selected by default.)

Somewhat related is an inconsistency in the
documentation that is embedded in the default.cfg file. It
says that I can define my own .cfg file and using the
Tools | Options | Editor set PythonWin to start with my
configuration file. There is no place that I can set the
startup configuration file in the Editor page.

That said, the product is terrific! Thanks.

Reg. Charney
[email protected]

Reported by: rcharney

Original Ticket: "pywin32/bugs/14":https://sourceforge.net/p/pywin32/bugs/14

win32api etc should alias code moved to the core

win32pipe.popen and win32api.Reg* should be removed
from the source-tree, and dynamically load the versions
in Python itself. This way bugs fixed in the core are
reflected here magically. Eg, see
https://sourceforge.net/tracker/index.php?func=detail&aid=722413&group\_id=5470&atid=105470

I would rather spend the effort aliasing _winreg than
duplicating the fix in win32api. However, this will
almost certainly mean win32api.error should subclass
os.WindowsError.

Reported by: mhammond

Original Ticket: "pywin32/bugs/8":https://sourceforge.net/p/pywin32/bugs/8

Defective LFN Handling in Version 1.53 Installer

Summary:
Using the win32all-153.exe installer on Windows XP
SP1 to install the extensions when the base version of
Python resides in a directory path containing spaces
results in an Access Violation.

Testing Methodology / Error Reproduction:
The installer crashed while attempting to register some
of the COM components it installs when I attempted to
use the installer to add the Win32 components when
Python was installed into "C:\Program Files\python23"
but functioned perfectly when Python was installed
in "C:\python23".

Possible Cause:
I have observed that various Windows installer utilites
perform improper conversion between LFN and non-LFN
versions of file and path names used during installation.
Perhaps a defective filename string causes the COM
component registration procedures to fail. I would first
attempt installing patches and updates for the installer
generation utility to see if the errors in its LFN handling
improve. It can with a high surety be stated that said
upgrade would likely result in a resolution of the issue.

Reported by: nobody

Original Ticket: "pywin32/bugs/3":https://sourceforge.net/p/pywin32/bugs/3

memory leak wrapping object having _typelib_guid_ attribute

Problem experimented using win32all build 152, Python
2.2.2.
The attached .zip file contains:

A) TestServer.tlb that defines the IPippo interface
B) CPippo.py that implements IPippo referring the typelib
using _com_interfaces and _typelib_guid_ attributes
C) PyPippo.py that implements IPippo using
_public_method_ attribute
D) CTest.py that reproduce the problem using CPippo
E) PyTest.py that is the same as CTest.py but use
PyPippo and doesn't have the leak
F) universal.py as modified by me to reduce the size of
the leak. My changes are only a workaround to reduce
the leak in my specific use (only one interface for
object, no lcid and typelib version support). Moreover I
think that with this change the performances are
improved as well.

The steps to reproduce the problem are:

1. COM registrations
1.1 python regtlb.py TestServer.tlb
1.2 python CPippo.py
1.3 python CTest.py

2. Test to highlight the leak (it use CPippo class)
2.1 python CTest.py

Reported by: ababini

Original Ticket: "pywin32/bugs/25":https://sourceforge.net/p/pywin32/bugs/25

non-admin install issues

Just to let you know, I installed Python 2.2 with the
advanced non-admin install option, which puts some dlls
in the Python subtree instead of in the Windows system
folder, and the Win32 Extensions install program gave
me an error because it could not find a dll.

I reinstalled Python 2.2 with the regular admin
install, and the Win32 Extensions installed just fine.

Reported by: mhammond

Original Ticket: "pywin32/bugs/19":https://sourceforge.net/p/pywin32/bugs/19

Modification made to have enum working under .NET

In order to get enum working with .NET wrapped enum, I
had to modify the code of __getitem__ from class
CDispatch in dynamic.py.

Indeed the "for" loop tries to access all index until it gets
an IndexError but when trying to access an non-existent
index under .NET, I got this error from mscorlib:

(-2147352567, "Une exception s'est produite.",
(0, 'mscorlib', "L'index \xe9tait hors limites. Il ne doit pas
\xeatre n\xe9gatif et doit \xeatre inf\xe9rieur \xe0 la taille
de la collection.\r\nNom du param\xe8tre\xa0: index",
None, 0, -2146233086), None)

The error message translated is: "index out of bounds. It
must not be negative or less than the collection size.
Parameter name: index"

In order to get the for loop working, I modified the code
to raise an IndexError and it works.

Hope it will help

Reported by: marcengel

Original Ticket: "pywin32/patches/1":https://sourceforge.net/p/pywin32/patches/1

Calling com server w/VB "Call" changes 1st param's value

python version: 2.2.2
win32all version: 152
platform: win2k server with WSH 5.6

description:
I have a pythoncom server (using DynamicPolicy) with a
function that takes a single parameter. Calling that
function from VB/VBScript using "Call" (ignoring the
return value) causes the passed parameter to be set to
the return value of that function. If I assign the return
value to a VB variable the parameter's value doesn't
change:

'Python COM server
class Object:
def _dynamic_(self, name, lcid, wFlags, args):
return getattr( self, string.lower(name) )(*args)
def func1(self, S1):
pass

'Called From VBScript
Call obj.func1(param) 'Bad, param gets set to Null
rval = obj.func1(param) 'OK, param retains its value

I'm at a loss as to why this is. The only difference I can
see at the policy level is wFlags, with one style it's 3
(DISPATCH_METHOD | DISPATCH_PROPERTYGET)
and the other it's 1 (DISPATCH_METHOD)

Attached is a zip containing a pythoncom server, a
VBScript test file and a batch (cmd) file to run the test.
Please let me know if I've done something incorrectly.

Reported by: ryangroe

Original Ticket: "pywin32/bugs/15":https://sourceforge.net/p/pywin32/bugs/15

closing edit window results in error loop

Not always repeatable: make changes in an edit window.
click the close box. Say Yes to Save Changes? Result
Traceback (most recent call last):
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\framework\editor\document.py",
line 83, in OnSaveDocument
self._DocumentStateChanged()
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\framework\editor\document.py",
line 175, in _DocumentStateChanged

pywin.debugger.currentDebugger.UpdateDocumentLineStates(self)
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\debugger\debugger.py",
line 880, in UpdateDocumentLineStates
doc.MarkerDeleteAll( MARKER_BREAKPOINT )
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\scintilla\document.py",
line 117, in MarkerDeleteAll
self.GetEditorView().SCIMarkerDeleteAll(marker)
AttributeError: SCIMarkerDeleteAll
win32ui: OnSaveDocument() virtual handler (<bound
method SyntEditDocument.OnSaveDocument of
<pywin.framework.editor.color.coloreditor.SyntEditDocument
instance at 0x01885A68>>) raised an exception
Traceback (most recent call last):
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\framework\dbgcommands.py",
line 140, in OnUpdateAddBreakpoints
cmdui.SetCheck(doc.MarkerAtLine(lineNo,
pywin.framework.editor.color.coloreditor.MARKER_BREAKPOINT)
!= 0)
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\scintilla\document.py",
line 121, in MarkerAtLine
markerState =
self.GetEditorView().SCIMarkerGet(lineNo-1)Traceback
(most recent call last):
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\framework\dbgcommands.py",
line 108, in OnAdd
rc = d.set_break(pathName, lineNo)
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\debugger\debugger.py",
line 519, in set_break
self.SetLineState(filename, lineno,
LINESTATE_BREAKPOINT)
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\debugger\debugger.py",
line 867, in SetLineState
if not doc.MarkerCheck(lineNo, marker):
File
"P:\Python22\\lib\site-packages\Pythonwin\pywin\scintilla\document.py",
line 105, in MarkerCheck
markerState = v.SCIMarkerGet(lineNo)
AttributeError: SCIMarkerGet
win32ui: Error in Command Message handler for command
ID 16004, Code 0
then loops endlessly back to the last Traceback...

Reported by: ramrom

Original Ticket: "pywin32/bugs/34":https://sourceforge.net/p/pywin32/bugs/34

Some patch to add support for Wizard97

I have patched some source files in
the ./pywin32/pythonwin directory to add the support for
the new Wizard97 style.
including these:
pythonppage.cpp pythonppage.h
pythonpsheet.cpp pythonpsheet.h
win32prop.cpp win32prop.h
win32uimodule.cpp

also below because of some bugs found in these files:
win32assoc.cpp
win32bitmap.cpp win32bitmap.h
win32ctlList.h

attached is the diff file.

Reported by: qinlj

Original Ticket: "pywin32/patches/4":https://sourceforge.net/p/pywin32/patches/4

importing win32com.client causes python to crash

Windows XP Professional SP1 - English
.NET framework not installed
python-2.2.3
win32all-152

Open an interactive python session, then execute the
following import statement:

import win32com.client

This causes the python interpreter to crash
with "memory could not be read" error (system error
dialog appears).

Google search: +"import win32com.client" +crash

Tons of error reports can be found. Strange, sometimes
unpredictable behaviour reported. This bug (?) broke
significant part of existing win32all codebase. Some
forum posts suggested, that win32all-150 with python-
2.2.2 did not crash (this is a "workaround", but should
be tested).

- Complex -

Reported by: complex

Original Ticket: "pywin32/bugs/31":https://sourceforge.net/p/pywin32/bugs/31

Error handling: not playing nice with Tkinter? (W98)

When PythonWin is executing a TKInter script and
something goes wrong, things apparently get left in
queue for the next (correct) execution. This causes
weirdness in the GUI interaction eventually leading
PythonWin to crash.

Not 100% sure it's PyWin and not TkInter's problem,
but I started with the more likely suspect IMO.

TO REPRODUCE:
1. start PythonWin
2. New python script
3. Paste in Example 3.1 from
<http://www.pythonware.com/library/tkinter/introducti
on/hello-again.htm> (a TkInter "Hello World" example).

4. Add some line that's guaranteed to error,
like "import dummy", BEFORE the call to root.mainloop
()
5. Save the file somewhere not in the Python path, e.g.
under a subdir of My Documents .
6. Run with an <F5>

OBSERVE: normal exception message in interactive
window.

6. Fix the "problem" by deleting the bogus import line.
7. Run again with <F5>

ACTUAL RESULT: Now you get two TKInter dialog
boxes! Pressing Quit on the 2nd one doesn't really
quit, and pressing a few more buttons (e.g. Quit on
the first, Hello on the second, Quit on the second -- I
think that was my order) will cause an error:

Runtime Error!

Program <path to pythonwin> PYTHONWIN.EXE

abnormal program termination

EXPECTED RESULT: PythonWin should be robust
enough to handle this. I think. :-)

If possible, it should clear out the queue of windows so
the first dialog never gets displayed. Certainly they
shouldn't both display at the same time.

Reported by: philipreed

Original Ticket: "pywin32/bugs/22":https://sourceforge.net/p/pywin32/bugs/22

Installer has wrong version info in pyd files

Just wanted to alert you to a small problem with the
win32all 152 binary build for Python 2.2. The Windows
version information appears to be incorrect or at least
inconsistent with win32all 150 for Python 2.2. The 150
binaries are versioned 2.2.0.150, but the 152 binaries
are versioned 2.1.0.152. This caused my installation
of 152 over 150 to NOT replace the binaries, since they
appear to be older from a versioning perspective. All
of the win32 binaries appear to be affected.

Reported by: mhammond

Original Ticket: "pywin32/bugs/18":https://sourceforge.net/p/pywin32/bugs/18

If Event not starting with "On" are not handle properly

I have a .NET assembly that generates an Event.

The event name is Started. I got the following exception:

com_error: (-2147352567, 'Exception occurred.',
(0, '', 'Unknown name.', None, 0, -2147352570), None)

The problem is that when calling MakePy on the TLB, it
generates the event name as"OnStarted" and
not "Started" in _dispid_to_func_

If the event name in C# assembly event interface
is "OnStarted" than everything works fine.

I don't know if this is specific to .NET interoperabilty or
not.

I never noticed it with COM connection points

Reported by: marcengel

Original Ticket: "pywin32/bugs/28":https://sourceforge.net/p/pywin32/bugs/28

Reference count bug in ODBC

The following code crashes -

import odbc
db = odbc.odbc('frank/Adminstrator')

def update():
c = db.cursor()
try:
c.execute("insect into fmtest values ('rubbish')")
return ['success']
except:
return ['fail']

print update()

The update routine tries to insert a record into the
database. If it fails (it will in the example as the
command is invalid), MSW pops up a box with the
message "Python.exe has generated errors and will be
closed by Windows", and the dos box displays the
message "<refcnt 0 at ....>".

The error only occurs if the return type is a list, and if
the function returns from the "except" clause.

Reported by: chagford

Original Ticket: "pywin32/bugs/26":https://sourceforge.net/p/pywin32/bugs/26

GetObject fails under Win32all-153

GetObject fails to retrieve an instance of an object when
a moniker is used.
For example, when working with WMI the following
will fail :-

>>> import win32com.client
>>> o = win32com.client.GetObject("winmgmts:")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\site-
packages\win32com\client\__init__.py", line 73, in
GetObject
return Moniker(Pathname, clsctx)
File "C:\Python23\lib\site-
packages\win32com\client\__init__.py", line 88, in
Moniker
moniker, i, bindCtx =
pythoncom.MkParseDisplayName(Pathname)
com_error: (-2147221020, 'Invalid syntax', None, None)

I believe there is a bug in the implementation of
MkParseDisplayName - possible corruption of passed
moniker string.

Reported by: aka_kool

Original Ticket: "pywin32/bugs/21":https://sourceforge.net/p/pywin32/bugs/21

Memory Leak

There is a memory leak associated with events delivered
through the IConnectionPoint interface. The leak
occurs when a ByRef VARIANT parameter is passed
through the interface as an inout parameter.

The culprit appears to be oleargs.cpp, specifically the
routine PythonOleArgHelper::MakeObjToVariant, which
is called to replace the original VARIANT with the
returned one. In the case VT_VARIANT | VT_BYREF,
with bCreateBuffers as false, the routine calls
VariantClear(var), which only clears the referencing
VARIANT and not the referenced one. This call should
be VariantClear(V_VARIANTREF(var)), which will clear
memory held by the referenced VARIANT before the
subsequent call to PyCom_VariantFromPyObject
simply overwrites that VARIANT.

The code as written depends on V_VARIANTREF(var) to
remain valid after calling VariantClear(var), which seems
a dangerous assumption.

Note that this repair follows the same logic as is used in
the existing code for the VT_BSTR | VT_BYREF case,
in which SysFreeString(*V_BSTRREF(var)) is called, for
the reason that VariantClear(var) wouldn't free the
indirectly referenced BSTR.

Reported by: shacktoms

Original Ticket: "pywin32/bugs/17":https://sourceforge.net/p/pywin32/bugs/17

installation without administrator rights

On windows XP, the installation fails if the user installing the
package is not administrator. This is because the
installation tries to modify some keys in the registry which
cannot be modified by a normal user.

It would be good if the installation could be updated to allow
a normal user to install the package (the python package
allows this)

Reported by: khadrin

Original Ticket: "pywin32/feature-requests/3":https://sourceforge.net/p/pywin32/feature-requests/3

Right-click grep menu broken

In previous versions of PythonWin I could left click,
then right click on a result line in a grep window and
choose to edit the file. In the current (win32all build
152) right click in grep always displays the same menu
(Try Again, Cut, Copy, Paste, Select all, Save tesults.)

BTW it also bugged me that I had to left click first to
select the line, then right click.

Reported by: mhammond

Original Ticket: "pywin32/bugs/2":https://sourceforge.net/p/pywin32/bugs/2

incorrect import util in dynamic.py

Line 195 of dynamic.py imports util, but this isn't found
(well, here!) unless this is replaced with "from win32com
import util".

I can't seem to access anon cvs from sf at the moment,
so can't check more recent that this. Apologies if you
already have fixed this.

Reported by: anadelonbrin

Original Ticket: "pywin32/bugs/27":https://sourceforge.net/p/pywin32/bugs/27

PyHANDLE destructor triggers a SystemError

This code is in PyHANDLE.cpp:

/*static*/ void PyHANDLE::deallocFunc(PyObject *ob)
{
// Call virtual method Close
((PyHANDLE *)ob)->Close();
PyErr_Clear(); // can not leave pending exceptions
in destructors.
delete (PyHANDLE *)ob;
}

If this is called because an unrelated exception
occurred, it incorrectly clears the exception.

For example, suppose I have Python code that calls a
Python function f1(). This function successfully
creates a PyHANDLE, stores it in a local varaible, and
then raises an unrelated exception. The caller, f2(),
catches the exception. At this point, the PyHANDLE
still exists because the traceback object has a
reference to it (indirectly). Now suppose f2() throws
an exception. The previous traceback object is now
released (replaced by the new traceback). The PyHANDLE
object is decref'd and freed. PyHANDLE::deallocFunc()
is called. The exception that f2() threw is now cleared.

This results in a SystemError. The attached test case
reproduces it.

I think it should be

if (!((PyHANDLE *)ob)->Close())
PyErr_Clear();

but I'm not sure.

Reported by: jorend

Original Ticket: "pywin32/bugs/9":https://sourceforge.net/p/pywin32/bugs/9

Strange exception handling in win32api registry fns

Hi,

The registry handling methods in win32api seem to have
problems with
the Python exception handling. It took me some time,
but I have
managed to isolate the problem to a simple program. But
the problem is
more severe in more complicated situations, and there
it seems to
happen with most (or all) registry methods
(win32api.Reg...()).

The methods of _winreg module do not exhibit this
problem. For now, I
am using _winreg. However, it would be nice if the
problem could be
tracked down inside the win32api's source code and be
fixed.

regards,

Hung Jung Lu

#----------------------------------------------------------------------
# OS used: Windows XP
#
# Python 2.1
# program works correctly: correct exception
message displayed
#
# Python 2.2.2 (win32all build 152)
# (a) In Pythonwin intractive window, you get
# SystemError: error return without exception set
# (b) When running with python.exe, it crashes
#
# Python 2.3b1 (win32all build 153)
# (a) In Pythonwin intractive window, you get
# SystemError: error return without exception set
# (b) When running with python.exe, program exits
silently,
# which is not the correct behavior
#
# Comments:
# (a) equivalent _winreg module methods do not have
problem.
# (b) problem seems to happen with most, or all,
win32api.Reg...()
# methods, not in this particular example, but
in more
# complicated programs (involving classes)
#

import win32con
import win32api

def reg_operation():
hkey =
win32api.RegCreateKey(win32con.HKEY_CURRENT_USER,
r'Software\Spam')
x = 3/0 # or a statement like: raise 'error'

try: reg_operation()
except: x = 5/0 # or a statement like: raise 'error'

Reported by: mhammond

Original Ticket: "pywin32/bugs/13":https://sourceforge.net/p/pywin32/bugs/13

makepy crash on protected typelib registry key

If a typelib registry key is protected from the logged
on user, makepy aborts:
File
"E:\Python22\lib\site-packages\win32com\client\selecttlb.py",
line 68, in EnumTlbs
key2 =
win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT,
"Typelib\%s" % (iid))
error: (5, 'RegOpenKeyEx', 'Access is denied.')

This happened on Win NT 4 logged on as administrator. A
simple modification to the code to ignore such keys
will allow the user to get a list of permitted keys
instead of aborting. See attachment. I added lines 75
(try) and 118 (except) to ignore protected keys

Reported by: ramrom

Original Ticket: "pywin32/bugs/10":https://sourceforge.net/p/pywin32/bugs/10

Naming Convention Inconsistent for Installation Log File

Summary:
A minor typographical / naming convention error removal
of the Win32 extensions.

Problem:
The installer mistakenly copies the installation log into
Python23\Lib\site-packages\W32INST.LOG instead of
INSTALL.LOG which causes it to fail when attempting
to uninstall the Win32 extensions.

Potential Fix:
Either the location of the install log or the call to the
uninstaller placed in the registry should be modified to
correct this, or potentially both.

Reported by: nobody

Original Ticket: "pywin32/bugs/4":https://sourceforge.net/p/pywin32/bugs/4

Installing a service gets interactive mode wrong.

The procedure "InstallService" in "win32serviceutil.py" has
a parameter "bRunInteractive" meant to allow an installed
service the ability to interact with the screen. This
parameter is not handled correctly, and moreover, there is
no commandline access to the parameter.

At the very least, a true value for the parameter should
cause SERVICE_INTERACTIVE_PROCES to be or'ed into
the *service* type not the *startup* type (as the current
code does). This can be found in MS's documentation of
CreateService.

I've included a patch (on the version of win32serviceutil.py
in Python2.2) which does the above as well as adds a
simular parameter to ChangeServiceConfig. Moreover it
introcudes a new command line arg --interactive which
allows a command line option to set the flag on both
service installation and update.

I hope you find it useful.

Gary Herron

Reported by: herron

Original Ticket: "pywin32/bugs/12":https://sourceforge.net/p/pywin32/bugs/12

Explorer Shell Extensions

Hope this is not a silly request. I wonder if a way of
implementing Explorer Shell Extensions could be provided
so that they could be built with Python without having
to resort to C/C++.

For background on this request, you can look at the first
hit on a search on comp.lang.python for "shell
extension".

Your work and help is much apreciated.

Reported by: rrm1

Original Ticket: "pywin32/feature-requests/7":https://sourceforge.net/p/pywin32/feature-requests/7

win32 can't find python 2.2.3

Seems win32-extentions can't find my python 2.2.3
installation, it says python 2.2.3 isn't installed.

when i run the setup i got the screen that has two
buttons and a warning (no python installation found).

When i run python from commandline it displays 2.2.3 so
i guess the error is not correct.

Anyway... there are two buttons called "Continue
anyway" and "exit". So normally i just can click continue
anyway, but that doesn't work out, the button just
doesn't do a damned thing and just stays on screen as
it is. So i guess this is a bug ?

Best Regards,

Patrick Bielen

Reported by: pbielen

Original Ticket: "pywin32/bugs/23":https://sourceforge.net/p/pywin32/bugs/23

isInitialBreakpoint not initialised

In build 152 pywin.debugger.brk() is not working,
because Debugger is without isInitialBreakpoint attribute.

import pywin.debugger
g = pywin.debugger.GetDebugger()

if not hasattr(g, 'isInitialBreakpoint'):
g.isInitialBreakpoint = None

pywin.debugger.brk()
print '1'
print '2'
print '3'

Reported by: janezj

Original Ticket: "pywin32/bugs/16":https://sourceforge.net/p/pywin32/bugs/16

Potential crash in win32clipboard.SetClipboardData

Consider the following:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class crasher(object): pass
...
>>> obj = crasher()
>>> import win32clipboard
>>> win32clipboard.OpenClipboard()
>>> win32clipboard.EmptyClipboard()
>>> win32clipboard.SetClipboardData(0, obj)

(Python Crashes -- same thing happens under 2.3a2).

The problem appears to be the assumption (in py_set_clipboard_data) that a non-NULL tp_as_buffer implies a valid bf_getreadbuffer. This is not true; in particular, tp_as_buffer is always non-NULL for new-style classes.

I'd suggest using PyObject_AsReadBuffer instead of directly manipulating tp_as_buffer.

Reported by: glchapman

Original Ticket: "pywin32/bugs/6":https://sourceforge.net/p/pywin32/bugs/6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.