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

add encoding comment in nvofbf.py to fix SyntaxError when using Python 2 #4163

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

boegel
Copy link
Member

@boegel boegel commented Jan 5, 2023

(follow-up for #4157)

Without this, eb --list-toolchains is broken when running on top of Python 2 (and probably more):

$ python2 -m easybuild.main --list-toolchains
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/main.py", line 727, in <module>
    main()
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/main.py", line 595, in main
    eb_go, cfg_settings = set_up_configuration(args=args, logfile=logfile, testing=testing)
  File "easybuild/tools/options.py", line 1531, in set_up_configuration
    eb_go = parse_options(args=args)
  File "easybuild/tools/options.py", line 1490, in parse_options
    with_include=with_include)
  File "easybuild/tools/options.py", line 249, in __init__
    super(EasyBuildOptions, self).__init__(*args, **kwargs)
  File "easybuild/base/generaloption.py", line 984, in __init__
    self.postprocess()
  File "easybuild/tools/options.py", line 935, in postprocess
    self._postprocess_list_avail()
  File "easybuild/tools/options.py", line 1220, in _postprocess_list_avail
    msg += list_toolchains(self.options.output_format)
  File "easybuild/tools/docs.py", line 1024, in list_toolchains
    _, all_tcs = search_toolchain('')
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/tools/toolchain/utilities.py", line 68, in search_toolchain
    tc_modules = import_available_modules('easybuild.toolchains')
  File "easybuild/tools/utilities.py", line 152, in import_available_modules
    mod = __import__(modpath, globals(), locals(), [''])
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/toolchains/nvofbf.py", line 28
SyntaxError: Non-ASCII character '\xc3' in file /arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/toolchains/nvofbf.py on line 29, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

What's weird is that the test suite didn't catch this. It should have been caught by the test__list_toolchains test, but somehow that's not the case for the tests being run in GitHub Actions...

$ python2 -O -m test.framework.options  test__list_toolchains
Filtered CommandLineOptionsTest tests using 'test__list_toolchains', retained 1/135 tests: test__list_toolchains
E
======================================================================
ERROR: test__list_toolchains (__main__.CommandLineOptionsTest)
Test listing known compiler toolchains.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/test/framework/options.py", line 674, in test__list_toolchains
    self.eb_main(args, logfile=dummylogfn, raise_error=True)
  File "test/framework/utilities.py", line 341, in eb_main
    raise myerr
  File "/arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/toolchains/nvofbf.py", line 28
SyntaxError: Non-ASCII character '\xc3' in file /arcanine/scratch/gent/vo/000/gvo00002/vsc40023/easybuild/easybuild-framework/easybuild/toolchains/nvofbf.py on line 29, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

----------------------------------------------------------------------
Ran 1 test in 0.143s

FAILED (errors=1)

(hat tip @migueldiascosta)

@boegel boegel added the bug fix label Jan 5, 2023
@boegel boegel added this to the next release (4.7.0) milestone Jan 5, 2023
Copy link
Contributor

@Micket Micket left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel
Copy link
Member Author

boegel commented Jan 5, 2023

I ran some debug CI workflows to try and understand why the encoding issue wasn't triggered in the CI environment, but I'm still not sure.
When I run python -c 'import sys; print(sys.getdefaultencoding())', I get ascii as a result when using Python 2.7 (utf-8 with Python 3.x), as expected.
Yet, the encoding problem isn't triggered by the test__list_toolchains.

Even when setting both $LANG and $LC_ALL to C (default for $LANG is C.UTF-8) in the CI workflow, no encoding problem is being triggered.

I wouldn't block this PR over this though, we can always undo this fix if we want to keep hunting for the reason why this bug isn't being triggered in CI...

Copy link
Contributor

@Micket Micket left a comment

Choose a reason for hiding this comment

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

lgtm

@Micket Micket merged commit 694d7bb into easybuilders:develop Jan 5, 2023
@boegel boegel deleted the nvofpf_encoding branch January 5, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants