Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fixed bug of method PyString_FromString#670

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 15 commits intopythonnet:masterfromyagweb:bug_of_pystring
Aug 24, 2018

Conversation

yagweb
Copy link
Contributor

What does this implement/fix? Explain your changes.

The second parameter of PyString_FromStringAndSize should be filled with the length of the bytes array, not the the length of the raw string.

This method is a very basic method,sufficient tests should be applied.

Does this close any currently open issues?

#666
A unit test method need be added.

Any other comments?

No.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself toAUTHORS
  • Updated theCHANGELOG

@den-run-ai
Copy link
Contributor

@yagweb failing in python 2.7:

https://travis-ci.org/pythonnet/pythonnet/jobs/377211034

runtime.cs(1213,56): error CS1503: Argument 1: cannot convert from 'System.IntPtr' to 'string'

@codecov
Copy link

codecovbot commentedMay 11, 2018
edited
Loading

Codecov Report

Merging#670 intomaster willdecrease coverage by0.15%.
The diff coverage is100%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #670      +/-   ##==========================================- Coverage    77.4%   77.24%   -0.16%==========================================  Files          63       63                Lines        5589     5590       +1       Branches      892      892              ==========================================- Hits         4326     4318       -8- Misses        970      980      +10+ Partials      293      292       -1
FlagCoverage Δ
#setup_linux69.42% <ø> (ø)⬆️
#setup_windows76.42% <100%> (-0.16%)⬇️
Impacted FilesCoverage Δ
src/runtime/runtime.cs91.4% <100%> (+0.03%)⬆️
src/runtime/CustomMarshaler.cs57.53% <0%> (-12.33%)⬇️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatefb84cd2...050f8cc. Read thecomment docs.

@den-run-ai
Copy link
Contributor

@yagweb need a fix for appveyor pip update:

microsoft/vscode-python#1107

@den-run-ai
Copy link
Contributor

@yagweb this PR still needs a unit test for the failing case before it can be merged. All tests are passing!

@den-run-ai
Copy link
Contributor

@yagweb will this PR fix these 3 disabled tests?

[Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")]

[Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")]

@yagweb
Copy link
ContributorAuthor

yagweb commentedMay 31, 2018
edited
Loading

@denfromufa No.

I also found another bug of PyString/PyAnsiString, the ToString method of a object constructed using PyString(string) don't work with non-ASCII strings.

I will add all these into the checklist and dig deeper when I have time.

Maybe they are the cause of#662.

@den-run-ai
Copy link
Contributor

@yagweb i added the unit test based on reported bug by@EcmaXp in#666 but the issue does not look resolved in Python 2.7, works on all Python 3+ versions:

Travis CI:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xec in position 0: ordinal not in range(128)
https://travis-ci.org/pythonnet/pythonnet/jobs/387536002#L2111

Appveyor CI:

assert test_unicode_str == text_type(world)\x1b[1m\x1b[31mE       AssertionError: assert '\uc548\ub155' == '??'\x1b[0m\x1b[1m\x1b[31mE         - \uc548\ub155\x1b[0mE         + ??src\tests\test_conversion.py:544: AssertionError

https://ci.appveyor.com/project/pythonnet/pythonnet/build/master-1182/job/nvwn4ek3eskteg3m#L220

What do you think? Maybe the test should be modified for Python 2.7?

@filmor
Copy link
Member

I don't think this can work on Py2 without breaking backwards compatibility, as we identifySystem.String withstr while it would need to beunicode.

@den-run-ai
Copy link
Contributor

@filmor agreed, so then skip the last test on PY2?

@filmor
Copy link
Member

I think so, yes. Put a comment there for posterity :)

@@ -1193,7 +1193,11 @@ internal static bool PyString_Check(IntPtr ob)

internal static IntPtr PyString_FromString(string value)
{
#if PYTHON3
return PyUnicode_FromKindAndData(_UCS, value, value.Length);
#elif PYTHON2
return PyString_FromStringAndSize(value, value.Length);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check here whether the string is ASCII? I'm not sure where this one is used, but we should probably distinguish the case where we actually want Unicode (and should also return that on Python 2) from the cases that should be ASCII-only on Python 2 (like identifiers).

Copy link
Contributor

Choose a reason for hiding this comment

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

@filmor can you file a separate issue for this with a suggested fix? this PR is now ready to merge!

@filmorfilmor added this to the2.4.0 milestoneJul 23, 2018
@filmorfilmor merged commitb6417ca intopythonnet:masterAug 24, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@den-run-aiden-run-aiden-run-ai left review comments

@filmorfilmorfilmor approved these changes

@vmuriartvmuriartAwaiting requested review from vmuriart

@dmitriysedmitriyseAwaiting requested review from dmitriyse

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
2.4.0
Development

Successfully merging this pull request may close these issues.

3 participants
@yagweb@den-run-ai@filmor

[8]ページ先頭

©2009-2025 Movatter.jp