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

Error trying to deserialize with bytes_to_var_with_objects #80229

Closed
blackears opened this issue Aug 3, 2023 · 6 comments
Closed

Error trying to deserialize with bytes_to_var_with_objects #80229

blackears opened this issue Aug 3, 2023 · 6 comments

Comments

@blackears
Copy link

blackears commented Aug 3, 2023

Godot version

v4.1.stable.official [9704596]

System information

Windows 10, Compatability

Issue description

I'm trying to turn an object into a PackedByteArray so I can send it across an RPC call. However, when I try to deserialize, it I get an error saying ParserError: Class "Foo" hides a global script class. This only happens if I include the line with bytes_to_var_with_objects in the script.

Steps to reproduce

Just run the following lines. This seems to be causing the error:

	var foo:Foo = Foo.new()
	foo.alpha = 6
	foo.beta = 5
	
	var bytes:PackedByteArray = var_to_bytes_with_objects(foo)
	var foo_clone:Foo = bytes_to_var_with_objects(bytes)

This is Foo:

extends Resource
class_name Foo

var alpha:int
var beta:float

Minimal reproduction project

objectSerialization.zip

@AThousandShips
Copy link
Member

Looks like the same issue as:

@AimiIsFat
Copy link

AimiIsFat commented Sep 26, 2023

This is still an issue and can make some things more complex, especially networking, which uses bytes_to_var_with_objects in put_var if objects are allowed.

Here's a simple reproduction script if it helps:

class_name Foo
extends Node

func _ready() -> void:
	var dict = {object = self}
	
	var encoded = var_to_bytes_with_objects(dict)
	
	var object = bytes_to_var_with_objects(encoded)

Hoping this gets fixed soon. Will probably just use var_to_str and str_to_var on all objects.

@andzejsp
Copy link

andzejsp commented May 6, 2024

no fix yet ? :(

@AThousandShips
Copy link
Member

Please try 4.3.dev6, this might have been fixed assuming it's the same as #68666

@andzejsp
Copy link

andzejsp commented May 7, 2024

Please try 4.3.dev6, this might have been fixed assuming it's the same as #68666

Wow, nice, finally can use this in rpc() functions.

Thanks, keep up the Lords work!!

@dalexeev
Copy link
Member

Thanks for reporting the bug nonetheless!

@dalexeev dalexeev closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants