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

Question on usage of PURE_PYTHON #283

Closed
perrinjerome opened this issue Sep 30, 2024 · 2 comments · Fixed by zopefoundation/zope.proxy#71
Closed

Question on usage of PURE_PYTHON #283

perrinjerome opened this issue Sep 30, 2024 · 2 comments · Fixed by zopefoundation/zope.proxy#71

Comments

@perrinjerome
Copy link

perrinjerome commented Sep 30, 2024

PROBLEM REPORT or QUESTION

It's not clear to me what is the "convention" over using PURE_PYTHON.

The github actions are generated with PURE_PYTHON=1 set only for "Run tests with C extensions" step:

PURE_PYTHON: 1

The tox.ini is generated to set environment variable PURE_PYTHON=1 for "pure" cases and PURE_PYTHON=0 for "non pure"

{% set testenv_setenv = ['pure: PURE_PYTHON=1', '!pure-!pypy3: PURE_PYTHON=0'] + testenv_setenv %}

Some code, for example testZopeSecurityPolicy from AccessControl just check os.environ.get('PURE_PYTHON'), which is true in python if PURE_PYTHON is set to "0".

In some other places, for example this zope.index test use int(os.environ.get('PURE_PYTHON', '0')).

What I did:

Run AccessControl tests with tox -e py

What I expect to happen:

C code and python code to be tested

What actually happened:

Only python code is tested because of os.environ.get('PURE_PYTHON')

What version of Python and Zope/Addons I am using:

N/A


I'm not sure what is the best fix, probably packages can be changed to use int(os.environ.get('PURE_PYTHON', '0')) everywhere ?

@dataflake
Copy link
Member

This is an issue with the package in question, in this case AccessControl, and should be filed there. Clearly, any test that considers the environment variable to have a truth value when it is set to a string "0" is bad.

@perrinjerome
Copy link
Author

perrinjerome added a commit to zopefoundation/AccessControl that referenced this issue Sep 30, 2024
Setting to 0 should be equivalent to not setting the variable.

Refs zopefoundation/meta#283
perrinjerome added a commit to zopefoundation/AccessControl that referenced this issue Sep 30, 2024
Setting to 0 should be equivalent to not setting the variable.

Refs zopefoundation/meta#283
perrinjerome added a commit to zopefoundation/AccessControl that referenced this issue Sep 30, 2024
Setting to 0 should be equivalent to not setting the variable.

Refs zopefoundation/meta#283
perrinjerome added a commit to zopefoundation/AccessControl that referenced this issue Sep 30, 2024
Setting to 0 should be equivalent to not setting the variable.

Refs zopefoundation/meta#283
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 a pull request may close this issue.

2 participants