QPython unicode string - xlwt

In QPython3, a line like s = u"Hello" raises a syntax error for some reason.
I want to install a module that uses such code (namely xlwt) and therefore pip install xlwt fails.
This question is very similar but the workaround does not work since the problem is in 3rd party code.
Weirdly, the install works perfectly fine with QPython2. But I wrote all my code with Python3 features.
Does anyone know how I could get a line unicode strings to work in QPython3 ?
EDIT
I just realised QPython3 is running Python3.2 where the unicode raw strings were still banned and restored with Python3.3.
I am still looking for a workaround or a Python3.3+ interpreter for Android.
If you have an idea, I put a bounty on this question.

If I'm correct about this, "" is a byte string in Python 2, u"" is a Unicode string in Python 2, b"" is a byte string in Python 3, "" is a Unicode string in Python 3.
Is this the answer you want? Or I misunderstood the meaning of the question?

Related

How to correctly target "resolutions" on json and yarn(fixing vulnerabilities)

So I was trying to solve the vulnerabilities of the dependencies in a nuxt project. I am currently working with yarn, but didn't have to do this before, so I was doing a research about how to do, and i read about "resolutions" declaration on the json, so you can target the dependency package directly to try to avoid to break the application(just in case). Point is I ran
yarn audit
So I got the list of 20, from which 4 are marked as "high". Example:
So on my json resolutions, I wrote this:
"resolutions": {
"slice-machine-ui/*/trim-newlines": "3.0.1",
"nuxt/*/glob-parent": "5.1.2",
"nuxt/*/postcss":"8.2.13",
"nuxt/*/nth-check":"2.0.1",
"webpack/*/glob-parent":"5.1.2",
"jquery/*/jquery":"3.5.0",
"slice-machine-ui/*/node-fetch": "2.6.7"
}
After running the yarn install, I got that just one was solved, from 20. So is still 19 appearing on the list, so means I might be doing something wrong. Also in the example i found about this topic, they are using this "*" but no explanation why, or if I need this for all. Can someone help me to clarify this?

jvm argument with "&" fails

I am using a tc-server and I need to set different URLs based on environment. We have this practice of setting it as a jvm argument and using it in the application. When i try the property like below in setenv.sh, the server does not even come up. Below is the jvm arg that I am setting and the error. I hate to split the args just because its not working. Any idea what i need to do make it work as single arg with escaping characters are any?
It works fine if i don't have "&" in the value.
jvm.opts.28=-Dservice.rest.base.url=http://stg.sample.com?key=sample&value=sample
Could not load Logmanager
"com.springsource.tcserver.serviceability.logging.TcServerLogManager"
java.lang.ClassNotFoundException:
com.springsource.tcserver.serviceability.logging.TcServerLogManager
TC server version : 7.0.42.A.RELEASE
JDK: java 7
Have you tried putting single quotes around the URL?
jvm.opts.28=-Dservice.rest.base.url='http://stg.sample.com?key=sample&value=sample'
Looks like it works when you do that.
Can you briefly describe your environment in clear(Ex:what server, what version jdk)?
For the time being, this can shed some light on the real issue.
https://netbeans.org/bugzilla/show_bug.cgi?id=106300

Why do I get a slew of question marks when I parse a string with SuperObject?

I'm trying to parse this string using SuperObject in Delphi 7.
procedure TForm1.btn1Click(Sender: TObject);
var
obj: ISuperObject;
fw:string;
begin
fw:= '{"type":"normal","info":{"Name":"frank","Number":"01","Age":"21","registered":"Yes","Support":"Expired"}}';
obj := TSuperObject.ParseString(PWideChar(fw), false);
mmo1.lines.Add(obj.AsJSon(true,false));
end;
But result in the memo is like this:
"????????????????????????????????????????????????????}"
What am I doing wrong?
fw is a string which in Delphi 7 is 8 bit ANSI encoded. The cast to PWideChar is thus incorrect. It will treat the 8 bit text as if it were UTF-16 encoded.
If the function you are calling really does receive PWideChar then you need to convert to UTF-16 first. For example like this:
PWideChar(WideString(fw))
You also report a separate problem that arises in the super object code. Specifically this line of code:
h := h*129 + ord(k[i]) + $9e370001;
raises an overflow error.
That happens because your project has the overflow checking option enabled (good practice to do so), but the super object code has been written under the assumption that the option is disabled. This is really a flaw in the super object code. You can solve it by disabling overflow checking in the super object code by adding {$OVERFLOWCHECKS OFF}. Ideally this would be disabled very locally for just the code that intentionally overflows. However, unless you fully understand the code it may just be easier to stuff {$OVERFLOWCHECKS OFF} at the top of the unit and move on.
Now, I'm looking at the very latest super object code and right at the top of the unit is {$OVERFLOWCHECKS OFF}. So I wonder if you are perhaps using an out of date version of the code. Pull the latest version from the repo.
I had the same problem using SuperObjects1.2.4 in delphi 7. As many people said, the solution is: to get the latest version. So, to get the lastest SuperObjects version from repository do:
1. Install git (http://git-scm.com/)
2. Right click in some Folder, choose 'Git bash' and paste the following
git clone https://code.google.com/r/steve-superobject/
Done!

Syslog-ng format-json not working

I'm desperately trying to send a message as JSON to a PHP script.
destination d_php {
program("/usr/bin/php -f /data/htdocs/log.php" template("$(format-json)\n") ) ;
};
The php script is fine. Using simple macros works well, but the "format-json" function does always return this:
error in template: $(format-json)
I tried everything I could find in the documentation, but all response I get is "error in template". The official docs (link) even use 2 different spellings, not very promising.
Any ideas?
the format-json and format_json syntax should both work, hyphens and underscores are equivalent in syslog-ng.
As for the actual problem, have you tried setting the scope parameter of format-json, like "$(format_json --scope selected_macros)"? By default, it is empty, which means there is nothing to format.
HTH,
Regards,
Robert Fekete
Found the reason. Apparently, syslog-ng is split into separate packages on Ubuntu (12). I had to install syslog-ng-mod-json.
It's really a shame that syslog-ng doesn't give the slightest hint that the function is missing or unknown, instead of some general error.
If you are compiling from the source, you shall install json-c library first (yum install json-c-devel).

MyModel.new.from_json giving no data in Rails 3.0.3

I have some Rails 2.3.x code that I would like to run on Rails 3.0.3, but it seems to fail in my JSON to ActiveRecord code. Here is what I do:
mymodel = MyModel.new.from_json(json_string)
I get no errors here, but my object is empty as if there was no data in my json_string, but there is. If I look at the API (http://apidock.com/rails/ActiveRecord/Serialization/from_json) then it looks to me as it is not supported in 3.x, or?
I have tried with ActiveSupport::JSON.decode, but that decodes into a hashtable of key/values it seems?
Same problem here. The culprit is https://github.com/rails/rails/commit/c1d73270717f30498f8f4d55d6695509107c2834, here is an explanation: http://www.simonecarletti.com/blog/2010/04/inside-ruby-on-rails-serializing-ruby-objects-with-json/
The solution seems indeed to use
#obj.attributes = ActiveSupport::JSON.decode(json)
instead of "#obj.from_json(json)". At least for ActiveRecord objects, this works for me.