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

Explicitly use backports.configparser #6542

Merged
merged 1 commit into from Sep 21, 2018

Conversation

Projects
None yet
4 participants
@wisechengyi
Copy link
Contributor

wisechengyi commented Sep 21, 2018

Problem

Currently PYTHONCASEOK=1 would cause import configparser to load the system configparser instead of the backported one, causing

$ PYTHONCASEOK=1  ./pants -V
Exception caught: (<type 'exceptions.AttributeError'>)
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 75, in <module>
    main()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 71, in main
    PantsLoader.run()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 67, in run
    cls.load_and_execute(entrypoint)
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 60, in load_and_execute
    entrypoint_main()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_exe.py", line 38, in main
    PantsRunner(exiter, start_time=start_time).run()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_runner.py", line 35, in run
    bootstrap_options = options_bootstrapper.get_bootstrap_options()
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 171, in get_bootstrap_options
    self.construct_and_set_bootstrap_options()
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 162, in construct_and_set_bootstrap_options
    next_item = producer.send([filecontent_for(f) for f in files])
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 109, in produce_and_set_bootstrap_options
    pre_bootstrap_config = Config.load_file_contents(config_files_products)
  File "/Users/me/workspace/pants/src/python/pants/option/config.py", line 57, in load_file_contents
    return cls._meta_load(opener, file_contents, seed_values)
  File "/Users/me/workspace/pants/src/python/pants/option/config.py", line 89, in _meta_load
    parser.read_file(ini)

Exception message: ConfigParser instance has no attribute 'read_file'

Solution

Use explicit from backports import configparser

Result

$ PYTHONCASEOK=1  ./pants -V
1.10.0rc0
@Eric-Arellano
Copy link
Contributor

Eric-Arellano left a comment

Interesting. Not sure why this is happening but looks good.

Once we drop Python 2 we can go back to import configparser

@stuhood
Copy link
Member

stuhood left a comment

Great find. Thanks Yi!

@stuhood stuhood added this to the 1.10.x milestone Sep 21, 2018

@wisechengyi wisechengyi merged commit 59d1632 into pantsbuild:master Sep 21, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@wisechengyi wisechengyi deleted the wisechengyi:configparser branch Sep 21, 2018

wisechengyi added a commit that referenced this pull request Sep 21, 2018

Explicitly use backports.configparser (#6542)
### Problem

Currently `PYTHONCASEOK=1` would cause `import configparser` to load the system configparser instead of the backported one, causing

```
$ PYTHONCASEOK=1  ./pants -V
Exception caught: (<type 'exceptions.AttributeError'>)
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 75, in <module>
    main()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 71, in main
    PantsLoader.run()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 67, in run
    cls.load_and_execute(entrypoint)
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_loader.py", line 60, in load_and_execute
    entrypoint_main()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_exe.py", line 38, in main
    PantsRunner(exiter, start_time=start_time).run()
  File "/Users/me/workspace/pants/src/python/pants/bin/pants_runner.py", line 35, in run
    bootstrap_options = options_bootstrapper.get_bootstrap_options()
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 171, in get_bootstrap_options
    self.construct_and_set_bootstrap_options()
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 162, in construct_and_set_bootstrap_options
    next_item = producer.send([filecontent_for(f) for f in files])
  File "/Users/me/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 109, in produce_and_set_bootstrap_options
    pre_bootstrap_config = Config.load_file_contents(config_files_products)
  File "/Users/me/workspace/pants/src/python/pants/option/config.py", line 57, in load_file_contents
    return cls._meta_load(opener, file_contents, seed_values)
  File "/Users/me/workspace/pants/src/python/pants/option/config.py", line 89, in _meta_load
    parser.read_file(ini)

Exception message: ConfigParser instance has no attribute 'read_file'
```

### Solution

Use explicit `from backports import configparser`

### Result
```
$ PYTHONCASEOK=1  ./pants -V
1.10.0rc0
```
@wisechengyi

This comment has been minimized.

Copy link
Contributor

wisechengyi commented Sep 21, 2018

cherry-picked to 1.10.x. cc @ity

@ity ity removed the needs-cherrypick label Sep 26, 2018

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