8000 fix: pass byteLength of string when creating Python String by DjDeveloperr · Pull Request #40 · denosaurs/deno_python · GitHub
[go: up one dir, main page]

Skip to content

fix: pass byteLength of string when creating Python String #40

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

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: pass byteLength of string when creating Python String
instead of character length which is wrong in case character length is not 1.
  • Loading branch information
DjDeveloperr authored Jul 20, 2023
commit 7a8903f52e64e90c90a773ce1da2359dc6951f8b
6 changes: 4 additions & 2 deletions src/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,12 @@ export class PyObject {
case "symbol":
case "string": {
const str = String(v);
const encoder = new TextEncoder();
const u8 = encoder.encode(str);
return new PyObject(
py.PyUnicode_DecodeUTF8(
cstr(str),
str.length,
u8,
u8.byteLength,
null,
),
);
Expand Down
0