Git Product home page Git Product logo

Comments (12)

Wedge009 avatar Wedge009 commented on June 8, 2024

For the time of writing, both master and 1.18 branches (you didn't say what code you're using), I observe line 27 of https://github.com/wesnoth/wesnoth/blob/master/data/tools/pywmlx/state/wml_states.py to be a comment block.

Can you try removing that block and see if it still complains? If it's not required, I generally advise code-disabled-by-comments to be removed altogether - that's what source control is for.

from wesnoth.

Pentarctagon avatar Pentarctagon commented on June 8, 2024

A couple months ago there was a very similar report from Iris also for wmlxgettext and Python 3.12:

18:25:31 iris@mia ~/Projects/Project Ethea/Ethea-i18n git:master % make pot-update
    POT     wesnoth-Invasion_from_the_Unknown.pot
Traceback (most recent call last):
  File "/Users/iris/Local/bin/wmlxgettext", line 41, in <module>
    import pywmlx
  File "/Users/iris/Projects/wesnoth/data/tools/pywmlx/__init__.py", line 13, in <module>
    import pywmlx.state as statemachine
  File "/Users/iris/Projects/wesnoth/data/tools/pywmlx/state/__init__.py", line 1, in <module>
    from pywmlx.state.machine import setup
  File "/Users/iris/Projects/wesnoth/data/tools/pywmlx/state/machine.py", line 165
    value = re.sub('\\\s*$', '', value)
                   ^^^^^^^^
SyntaxError: (value error) not enough values to unpack (expected 2, got 1)
make: *** [Invasion_from_the_Unknown/wesnoth-Invasion_from_the_Unknown.pot] Error 1

which was fixed in 4be9aa8.

from wesnoth.

sevu avatar sevu commented on June 8, 2024

Indeed deleting the comment solves it. Will push that later.

Interesting that this happens.

from wesnoth.

Wedge009 avatar Wedge009 commented on June 8, 2024

At first glance I thought maybe the interpreter wasn't accepting comment blocks at a different indentation level to what is the then-current class block (for WmlIdleState). But it is strange that the current Python triggers an exception on this, but previous ones don't (maybe a deliberate design decision?).

from wesnoth.

Elvish-Hunter avatar Elvish-Hunter commented on June 8, 2024

I observe line 27 of https://github.com/wesnoth/wesnoth/blob/master/data/tools/pywmlx/state/wml_states.py to be a comment block.

Line 27 isn't a comment block, which in Python don't exist. It's code wrapped inside a multi-line string, so rules for escape characters still apply there. Does marking the string as raw solve the issue?

But it is strange that the current Python triggers an exception on this, but previous ones don't (maybe a deliberate design decision?).

Yes, it's a deliberate decision, although it should only raise a SyntaxWarning for now instead of a SyntaxError: https://docs.python.org/3/whatsnew/3.12.html.

from wesnoth.

Wedge009 avatar Wedge009 commented on June 8, 2024

I'm still relatively new to Python so I might not know the exact terminology, but clearly the intention was to disable code as a comment - regardless of the syntactic detail, I already said this practice isn't good.

Edit: Oh I see what you mean - the regular expression inside the code may have triggered SyntaxError.

from wesnoth.

Elvish-Hunter avatar Elvish-Hunter commented on June 8, 2024

Exactly. Every point of a string where there's a backslash can generate this kind of problem, because it starts an escape sequence, so that's why I suggested marking the string as raw: it forces backslashes to be interpreted as literal characters.
I'd try to fix it, but on Ubuntu 22.04 I don't have access to Python 3.12 (in the repositories there's 3.11 at most) and forcing an update to 24.04 before the first point release is available isn't recommended (there's an issue that can make Thunderbird unusable). It's better if someone else checks the fix.

from wesnoth.

Pentarctagon avatar Pentarctagon commented on June 8, 2024

I use Mint, so it'll probably be at least a couple months until they have a version that's based on Ubuntu 24.04 available.

from wesnoth.

Wedge009 avatar Wedge009 commented on June 8, 2024

I'm still waiting for proper ROCm support for Ubuntu 24.04 before switching to it. ):

from wesnoth.

Wedge009 avatar Wedge009 commented on June 8, 2024

I tested Python 3.11 and 3.12 in Windows, confirmed the issue as reported, and confirm changing the block to a raw string resolves the issue without apparent change for Python 3.11.

I'd make a PR for this, but I'm still inclined to just remove the whole block instead.

from wesnoth.

Pentarctagon avatar Pentarctagon commented on June 8, 2024

If it's just unused code and not meant as an example or to be part of documentation, then I think removing it is fine. Boggles my mind that Python doesn't have actual code comments though...

from wesnoth.

CelticMinstrel avatar CelticMinstrel commented on June 8, 2024

Boggles my mind that Python doesn't have actual code comments though...

It has comments, just not block comments.

from wesnoth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.