Skip to content

Cleanup unsupported python code (except for adodbapi)#1990

Merged
mhammond merged 39 commits intomhammond:mainfrom
Avasam:obsolete-python-code
Aug 10, 2023
Merged

Cleanup unsupported python code (except for adodbapi)#1990
mhammond merged 39 commits intomhammond:mainfrom
Avasam:obsolete-python-code

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Dec 7, 2022

This is the second a PR in a series concerning code cleanup. With the final goal to make basic type-checking validation of public methods possible, easing the addition of 3.7+ type annotations.

This cleans-up most unreachable code. Mostly due to unsupported python versions.

Note these changes are for pure python code only. It'd be nice to do the same for c-modules, but I don't have the necessary knowledge or expertise there. I'm sure there's more I could do, if I missed anything, please let me know!

@vernondcole
Copy link
Copy Markdown
Collaborator

vernondcole commented Dec 8, 2022

We have a problem here.
The refactoring of the adodbapi code is extensive. It has needed to be done for a long time, and I have neglected it, so I am thankful for the work. Don't get that wrong.
The problem is: we cannot test it.
Microsoft Azure has recently turned off the Sql Server machine which I have kept running for several years to use for testing. I don't think it has been used anyway, and was a poor arrangement to start with, so it's definitely time for something better.

  1. DO NOT MERGE this PR until we can run a full test of adodbapi.

  2. How can we do that?

Is there some facility local to the CI (or nearby) on which we can maintain, or spin up, a small SQL Server instance? (This could be an Ubuntu machine running a Linux version of Sql Server, but maintaining a Windows based example would be easier.)

@vernondcole
Copy link
Copy Markdown
Collaborator

vernondcole commented Dec 8, 2022 via email

@Avasam
Copy link
Copy Markdown
Collaborator Author

Avasam commented Dec 8, 2022

@vernondcole Thanks for your input! If there are currently untestable areas that would require a lot of work to setup. I can always split up those sections in a different PR so that it's tackled separately. Or let you test all at once since it'll have to be done at some point anyway.

@vernondcole
Copy link
Copy Markdown
Collaborator

vernondcole commented Dec 8, 2022 via email

Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until #1986 lands it will be tricky to look closely, but a very quick look seems great.

I think we should split adodbapi, but the question is, where: @vernondcole in #1986 there are a couple of commits which are tool generated, first of which sorts imports. How do you feel about an untested change which just does this, for example? We could split things at one of the "tool generated" steps which might make things easier - eg, I tend to let black reformat for me without bothering to re-test what it did.

@Avasam Avasam force-pushed the obsolete-python-code branch from b9576d4 to 03400f1 Compare February 19, 2023 23:59
Avasam added a commit to Avasam/pywin32 that referenced this pull request Apr 17, 2023
@Avasam
Copy link
Copy Markdown
Collaborator Author

Avasam commented Apr 18, 2023

I've extracted raw string changes into #2045 as well as bytes-strings into #2046 to reduce changes from this PR.

Avasam added 2 commits April 17, 2023 20:28
.encode on direct strings

Replace uses of str2bytes
@Avasam Avasam marked this pull request as draft July 24, 2023 21:23
@Avasam Avasam changed the title Cleanup unsupported python code Cleanup unsupported python code (except for adodbapi) Aug 6, 2023
@Avasam
Copy link
Copy Markdown
Collaborator Author

Avasam commented Aug 6, 2023

Refactoring of adodbapi code has been completely split off to #2094 so that this here PR can be testable and reviewable sooner.

@Avasam Avasam force-pushed the obsolete-python-code branch from 41998ac to 7510c94 Compare August 6, 2023 16:28
@Avasam Avasam marked this pull request as ready for review August 9, 2023 01:29
Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for persevering!

for IDLE.

Eg, If you have Python 1.5.2 installed, the files in this
<!-- TODO: Is this still accurate? -->
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be reworded to reflect something like "if the files in this directory are newer than the ones shipped with your Python version" or similar.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I would integrate that text. If they are newer, then what?

The current text seems to imply that this directory was based on IDLE from a specific python version (>3.7). What I'm not sure about, is whether saying that Python 3.8 is the version it's based on is accurate. Or if I'm even understanding this message correctly.

Also by "later" does this text mean "newer" ?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was trying to reflect that the files in this dir also exist in IDLE, but may have been released as part of pywin32 before a Python release was made. So yeah, I guess this entire readme can now just say something like "these files have been forked from IDLE" or similar.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I have pushed a wording change suggestion that should not fall out of date.

import code

sys.modules["builtins"].input = Win32RawInput
sys.modules["builtins"].input = Win32Input
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you actually test this?

Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raw_input doesn't exist on python 3. So

import code

sys.modules["builtins"].input = Win32RawInput

was the only code that can run.

Win32Input is no longer used.

The concept of raw input vs regular input doesn't exist in python 3. So the name didn't make sense anymore. So I removed the old unused Win32Input and renamed Win32RawInput to Win32Input

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks, I understood the intent - I was just wondering if you actually checked that, eg, input("enter something:") from the interactive window still actually worked? Sadly I have no windows machine handy at the moment.

Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. No I had not tested this "as a user would" through the app. I've only validated my understanding of small sections.

Now I did, there you go:
image
image
image

Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

t = ts.NewWorkItem(task_name)
t.SetComment("Test a task running as local system acct")
t.SetApplicationName("c:\\python23\\python.exe")
t.SetApplicationName("c:\\Python37\\python.exe")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should really do the same as we did for test_addtask_1.py here - do you mind opening a followup (either an issue or PR)? Not I'm going to be largely offline for 2 weeks.

Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you go: #2099
And thanks for letting me know! Getting this PR merged is a huge step forward, I can start looking at the next steps.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants