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

Default encoding for I/O operations should be UTF-8 #244

Merged
merged 12 commits into from
Jan 9, 2024
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

### Bug Fixes

- Fixed `create_data_set` to accept "FBA", "FBM", "VBA", "VBM" as valid recfm [#240](https://github.com/zowe/zowe-client-python-sdk/issues/240)
- Fixed an issue with `list_jobs` user correlator parameter [#242](https://github.com/zowe/zowe-client-python-sdk/issues/242)
- Return response instead of raw from streamed requests [#245](https://github.com/zowe/zowe-client-python-sdk/pull/245)
- Fixed `Files.create_data_set` to accept "FBA", "FBM", "VBA", "VBM" as valid recfm [#240](https://github.com/zowe/zowe-client-python-sdk/issues/240)
- Fixed an issue with `Jobs.list_jobs` user correlator parameter [#242](https://github.com/zowe/zowe-client-python-sdk/issues/242)
- Fixed default encoding for I/O operations to be UTF-8 on Windows [#243](https://github.com/zowe/zowe-client-python-sdk/issues/243)

### Enhancements

- Next Breaking: Updated core SDK method `RequestHandler.perform_streamed_request` to return response object instead of raw buffer. [#245](https://github.com/zowe/zowe-client-python-sdk/pull/245)

## `1.0.0-dev12`

Expand Down
4 changes: 2 additions & 2 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
def download_dsn(self, dataset_name, output_file):
"""Retrieve the contents of a dataset and saves it to a given file."""
raw_response = self.get_dsn_content_streamed(dataset_name)
with open(output_file, "w") as f:
with open(output_file, "w", encoding="utf-8") as f:

Check warning on line 520 in src/zos_files/zowe/zos_files_for_zowe_sdk/files.py

View check run for this annotation

Codecov / codecov/patch

src/zos_files/zowe/zos_files_for_zowe_sdk/files.py#L520

Added line #L520 was not covered by tests
shutil.copyfileobj(raw_response, f)

def download_binary_dsn(self, dataset_name, output_file, with_prefixes=False):
Expand Down Expand Up @@ -564,7 +564,7 @@
def upload_file_to_uss(self, input_file, filepath_name, encoding=_ZOWE_FILES_DEFAULT_ENCODING):
"""Upload contents of a given file and uploads it to UNIX file"""
if os.path.isfile(input_file):
in_file = open(input_file, "r")
in_file = open(input_file, "r", encoding="utf-8")

Check warning on line 567 in src/zos_files/zowe/zos_files_for_zowe_sdk/files.py

View check run for this annotation

Codecov / codecov/patch

src/zos_files/zowe/zos_files_for_zowe_sdk/files.py#L567

Added line #L567 was not covered by tests
file_contents = in_file.read()
response_json = self.write_to_uss(filepath_name, file_contents)
else:
Expand Down
6 changes: 3 additions & 3 deletions src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
A JSON containing the result of the request execution
"""
if os.path.isfile(jcl_path):
jcl_file = open(jcl_path, "r")
jcl_file = open(jcl_path, "r", encoding="utf-8")

Check warning on line 270 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L270

Added line #L270 was not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added encoding="utf-8" for all open()` ☺️

file_content = jcl_file.read()
jcl_file.close()
return self.submit_plaintext(file_content)
Expand Down Expand Up @@ -397,7 +397,7 @@
_output_file = os.path.join(output_dir, _job_name, _job_id, "jcl.txt")
_data_spool_file = self.get_jcl_text(_job_correlator)
_dataset_content = _data_spool_file["response"]
_out_file = open(_output_file, "w")
_out_file = open(_output_file, "w", encoding="utf-8")

Check warning on line 400 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L400

Added line #L400 was not covered by tests
_out_file.write(_dataset_content)
_out_file.close()

Expand All @@ -412,7 +412,7 @@
_output_file = os.path.join(output_dir, _job_name, _job_id, _stepname, _ddname)
_data_spool_file = self.get_spool_file_contents(_job_correlator, _spoolfile_id)
_dataset_content = _data_spool_file["response"]
_out_file = open(_output_file, "w")
_out_file = open(_output_file, "w", encoding="utf-8")

Check warning on line 415 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L415

Added line #L415 was not covered by tests
_out_file.write(_dataset_content)
_out_file.close()

Expand Down