Skip to content

Eliminate PY2 legacy from safeinput where it causes lint errors#419

Merged
jonasbardino merged 1 commit intonextfrom
retire/python2-legacy-import-of-cgi-escape-to-also-address-lint-error
Jan 27, 2026
Merged

Eliminate PY2 legacy from safeinput where it causes lint errors#419
jonasbardino merged 1 commit intonextfrom
retire/python2-legacy-import-of-cgi-escape-to-also-address-lint-error

Conversation

@jonasbardino
Copy link
Contributor

Eliminate PY2 legacy from safeinput where it causes lint errors upon any other changes as seen in #417 .

@jonasbardino jonasbardino self-assigned this Jan 26, 2026
@jonasbardino jonasbardino added the refactor Non-functional changes to simplify or clean up label Jan 26, 2026
@jonasbardino jonasbardino marked this pull request as ready for review January 26, 2026 12:43
@jonasbardino jonasbardino requested a review from a team January 26, 2026 12:43
Copy link
Contributor

@albu-diku albu-diku left a comment

Choose a reason for hiding this comment

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

I thikn really we ought to have just done a big sweep for these - remove the constant that is backing all these conditionals, chase down the all he places that import them and axe the lot.

Otherwise given these lint checks run on what has changed we are going to keep on hitting these cases and I think it will be quire painful to address these one by one. I had (maybe have) a branch started locally to do just that but wasn't able to get through chasing it all down when I attempted that.

I won't hold this up, hence the approval, but still think it would be better to just get rid of this stuffonce and for all now it is not needed as compared to a series of such commits.

@jonasbardino
Copy link
Contributor Author

jonasbardino commented Jan 27, 2026

I thikn really we ought to have just done a big sweep for these - remove the constant that is backing all these conditionals, chase down the all he places that import them and axe the lot.

Otherwise given these lint checks run on what has changed we are going to keep on hitting these cases and I think it will be quire painful to address these one by one. I had (maybe have) a branch started locally to do just that but wasn't able to get through chasing it all down when I attempted that.

I won't hold this up, hence the approval, but still think it would be better to just get rid of this stuffonce and for all now it is not needed as compared to a series of such commits.

I don't disagree but I needed the specific fix for the PR. So I also won't object if anyone takes on the task or eliminating all with proper regression testing :-)

The list looks rather short for the PY2 variable itself:

0|.../ku/migrid-sync/migrid-pr9999 > ./codegrep.py PY2
mig/shared/compat.py:PY2 = sys.version_info[0] < 3
mig/shared/compat.py:if PY2:
mig/shared/compat.py:    Force the same to occur on PY2.
mig/shared/compat.py:    if PY2:
mig/shared/compat.py:    if PY2 and StringIO is not None:
mig/shared/fileio.py:            mode = "%sb" % mode  # appended to avoid mode ordering error on PY2
mig/shared/safeinput.py:PY2 = sys.version_info[0] < 3
mig/shared/safeinput.py:if PY2:
mig/shared/safeinput.py:    print = _print  # workaround print as reserved word on PY2
mig/shared/install.py:            user_dict['__WSGI_PY2_COMMENTED__'] = '#'
mig/shared/install.py:            user_dict['__WSGI_PY2_COMMENTED__'] = ''
mig/shared/install.py:        user_dict['__WSGI_PY2_COMMENTED__'] = '#'

but there may be more cases e.g. using sys.version_info[0] directly. I've started eliminating a series of those in #424.

@jonasbardino jonasbardino force-pushed the retire/python2-legacy-import-of-cgi-escape-to-also-address-lint-error branch from ed431fe to 67c8adf Compare January 27, 2026 11:31
@jonasbardino jonasbardino merged commit 9b102e2 into next Jan 27, 2026
7 checks passed
@jonasbardino jonasbardino deleted the retire/python2-legacy-import-of-cgi-escape-to-also-address-lint-error branch January 27, 2026 12:27
@albu-diku
Copy link
Contributor

Made a start on that - see #425.

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

Labels

refactor Non-functional changes to simplify or clean up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants