Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pywin32 issue(s) under Python 3.6.1 #748

Closed
ghost opened this issue Mar 27, 2017 · 17 comments
Closed

pywin32 issue(s) under Python 3.6.1 #748

ghost opened this issue Mar 27, 2017 · 17 comments

Comments

@ghost
Copy link

ghost commented Mar 27, 2017

It appears that changes in Python 3.6.1 have broken at least one feature in pywin32 220. I suspect that specifically it is this: https://bugs.python.org/issue29100

While arguably a maintenance release of Python should not be introducing such breaking changes - and so a ticket should also be raised there - it looks like perhaps this has just exposed an existing issue in pywin32, where previously the relevant Python API was more permissive.

Here is an example of the problem:

> import getpass, sspi, sspicon, win32security
> client_name = getpass.getuser()
> auth_info = (client_name, 'wherever.com', None)
> pkg_info = win32security.QuerySecurityPackageInfo('Kerberos')
> win32security.AcquireCredentialsHandle(
>     client_name, pkg_info['Name'],
>     sspicon.SECPKG_CRED_OUTBOUND,
>     None, auth_info)                             
                                                                            
ValueError: year 30828 is out of range

I think that AcquireCredentialsHandle() is returning a 'never expires' timestamp, which is out of the range of Python's datetime. Perhaps this case should be represented as datetime.max?

Reported by: m-parry

Original Ticket: pywin32/bugs/748

@ghost
Copy link
Author

ghost commented May 3, 2017

This is currently breaking SSPI support on Windows in my AsyncSSH package, and I don't see any obvious workaround I can put in. The issue appears to affect the Python C API that pywin32 is using.

Original comment by: rfrederick

@ghost
Copy link
Author

ghost commented Jun 13, 2017

This also breaks requests-kerberos: https://github.com/requests/requests-kerberos

Original comment by: akapocsi

@ghost ghost assigned ghost and unassigned ghost Oct 24, 2017
@berseus
Copy link

berseus commented Nov 27, 2017

This breaks requests-negotiate-sspi as well: brandond/requests-negotiate-sspi#12

@dhirschfeld
Copy link

As a user of requests-negotiate-sspi I'm affected by this so am just posting here so I get notified of any updates...

@dhirschfeld
Copy link

I just saw a comment stating that a new release was imminent so I'm putting in a final plug for this issue in the hope that a fix makes it in to the new release!

@mhammond
Copy link
Owner

Should be fixed by #07202650

@mhammond
Copy link
Owner

hrm - github didn't link the above commit - let's try 0720265 :)

@dhirschfeld
Copy link

To automatically link (and close) this issue from the commit message you need to prefix the issue number with one of the recognised keywords - e.g.

Closes #748
Fixes #748
...etc...

@wenqiangwang
Copy link

It seems the issue is still there.
I installed pywin32 222 and tried the following code:

import requests
from requests_negotiate_sspi import HttpNegotiateAuth
r = requests.get('https://xxx', auth=HttpNegotiateAuth())

Still got the following error:

  File "C:\Python\lib\site-packages\win32\lib\sspi.py", line 111, in __init__
    None, auth_info)
ValueError: year 30828 is out of range

@dhirschfeld
Copy link

dhirschfeld commented Jan 23, 2018

That's strange since it definitely works for me.

Are you sure you're running the latest? You can find out programmatically, in the exact same python session where you got the exception just run the below commands:

import win32api
fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\')
fixed_file_info['FileVersionLS'] >> 16

Not sure if there's an easier way to get the version - I found that snippit on SO.

@mhammond
Copy link
Owner

It's probably pywintypesxx.dll that matters here:

import pywintypes, win32api
fixed_file_info = win32api.GetFileVersionInfo(pywintypes.file, '\')
fixed_file_info['FileVersionLS'] >> 16
222

@mhammond
Copy link
Owner

(sob - my markup foo is poor - pywintypes.__file__)

@wenqiangwang
Copy link

wenqiangwang commented Jan 24, 2018

You are correct Mark. My win32api is 222 but pywintypes is 220. Do you know how to update it to 222?

I found that I have both pywin32 (222) and pypiwin32 (220) installed. Do you know what's the difference between them?

>>> import win32api
>>> fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\')
>>> fixed_file_info['FileVersionLS'] >> 16
222
>>> import pywintypes
>>> fixed_file_info = win32api.GetFileVersionInfo(pywintypes.__file__, '\\')
>>> fixed_file_info['FileVersionLS'] >> 16
220

@mhammond
Copy link
Owner

I suspect the correct version is in the lib\site-packages\pywin32_system32 directory, and for some reason the post-install script failed to copy it to the system32 (or SysWow64, depending on 64 vs 32 bit) directory.

Running python Scripts\pywin32_postinstall.py -install from an elevated command prompt should do the right thing.

@wenqiangwang
Copy link

wenqiangwang commented Jan 25, 2018

Its the case. Mark. But I just wonder with pypiwin32 I don't need to run another except for 'pip install pypiwin32'. Is it possible to update the pypiwin32 module to 222 too? requests-negotiate-sspi depends on it.

@mhammond
Copy link
Owner

I think @xoviat just converted the existing installers. Best I can tell, wheel doesn't have any postinstall script support, although maybe I missed it.

@wenqiangwang
Copy link

It worked. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants