Skip to content

Conversation

@kanterov
Copy link
Collaborator

Changes

Fix the Unicode support in the Python mutator.

By default, json.dump escapes non-ASCII characters. We use the ensure_ascii=False to preserve the Unicode characters.

Why

Fixes #2859

Tests

Acceptance and unit tests

@kanterov kanterov marked this pull request as ready for review May 13, 2025 18:45
@kanterov kanterov temporarily deployed to test-trigger-is May 13, 2025 18:45 — with GitHub Actions Inactive
@kanterov kanterov force-pushed the python-fix-unicode branch from fa5859f to 3e597da Compare May 13, 2025 18:47
@kanterov kanterov temporarily deployed to test-trigger-is May 13, 2025 18:47 — with GitHub Actions Inactive
@kanterov kanterov force-pushed the python-fix-unicode branch from 3e597da to 415631e Compare May 13, 2025 18:50
@kanterov kanterov temporarily deployed to test-trigger-is May 13, 2025 18:50 — with GitHub Actions Inactive
@kanterov kanterov temporarily deployed to test-trigger-is May 13, 2025 18:59 — with GitHub Actions Inactive
resources:
jobs:
job_1:
name: "🔥🔥🔥"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this tests unicode support in general, right? good to have, not specific to python, so I'd split this test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it isn't a problem for Golang code, because it's already using Unicode everywhere. It was just Python having a weird behavior

_write_locations(f, locations)

with open(args.output, "w") as f:
with open(args.output, "w", encoding="utf-8") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than handling this case-by-case, should we set locale-related env vars so that everything in Python process (including libraries and subprocess) works with unicode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it can be weird if we start customizing the Python environment. For example, if customers write unit tests, they will have a different behaviour. We don't have any 3p dependencies and IO is very limited, so I think we should be just carefully specifying encoding where needed.

@kanterov kanterov added this pull request to the merge queue May 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 14, 2025
@pietern pietern added this pull request to the merge queue May 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 14, 2025
@pietern
Copy link
Contributor

pietern commented May 14, 2025

We can try again once #2870 is merged.

@pietern pietern added this pull request to the merge queue May 14, 2025
Merged via the queue into main with commit fa9392d May 14, 2025
16 checks passed
@pietern pietern deleted the python-fix-unicode branch May 14, 2025 09:13
anton-107 pushed a commit that referenced this pull request May 14, 2025
## Changes
Fix the Unicode support in the Python mutator. 

By default, `json.dump` escapes non-ASCII characters. We use the
`ensure_ascii=False` to preserve the Unicode characters.

## Why
Fixes #2859

## Tests
Acceptance and unit tests
deco-sdk-tagging bot added a commit that referenced this pull request May 14, 2025
## Release v0.252.0

### Dependency updates
* Upgraded Go SDK to 0.69.0 ([#2867](#2867))
* Upgraded to TF provider 1.79.0 ([#2869](#2869))

### Bundles
* Remove unused fields from resources.models schema: creation\_timestamp, last\_updated\_timestamp, latest\_versions and user\_id. Using them now raises a warning ([#2828](#2828)).
* Preserve folder structure for app source code in bundle generate ([#2848](#2848))
* Fix normalising requirements file path in dependencies section ([#2861](#2861))
* Fix default-python template not to add environments when serverless=yes and include\_python=no ([#2866](#2866))
* Fix handling of Unicode characters in Python support ([#2873](#2873))
* Add support for secret scopes in DABs ([#2744](#2744))
* Make `artifacts.*.type` optional in bundle JSON schema ([#2881](#2881))
* Fix support for `spot_bid_max_price` field in Python support ([#2883](#2883))
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 this pull request may close these issues.

Error in Python mutator caused by a symbol 'ł' in workspace.current_user fields

4 participants