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

Beets is haunted, reads info from comment lines? #2565

Closed
RollingStar opened this issue May 16, 2017 · 4 comments · Fixed by #2566
Closed

Beets is haunted, reads info from comment lines? #2565

RollingStar opened this issue May 16, 2017 · 4 comments · Fixed by #2566
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."

Comments

@RollingStar
Copy link
Collaborator

Problem

A lot is going on here. May be many bugs combining? Some thoughts:

  • Beets reading info to the right of a comment indicator # which is unintuitive
  • Information in replace somehow ruining musicbrainz.host
  • Maybe something to do with using git branch rather than latest stable (1.4.3)?
  • Maybe something to do with latest commit?

Running this command in verbose (-vv) mode:

beet -vv
configuration error: musicbrainz.host not found

Setup

  • OS: win10 x64
  • Python version: 3.6
  • beets version: Latest git (9840964)
  • Turning off plugins made problem go away (yes/no): no

My configuration (output of beet config) is:

Causes issue:

library: e:\songs\beetslibrary.bib

replace:
    'qqqqqqq': 'eeeeeeeee'
    #

Works fine:

library: e:\songs\beetslibrary.bib

replace:
    'qqqqqqq': 'eeeeeeeee'
    #
@sampsyo
Copy link
Member

sampsyo commented May 16, 2017

Hmm; that's odd—this one I can't seem to reproduce.

$ cat config.yaml
library: e:\songs\beetslibrary.bib

replace:
    'qqqqqqq': 'eeeeeeeee'
    #”
$ beet -vv config
[...clip...]
Sending event: library_opened
verbose: 2
library: e:\songs\beetslibrary.bib

replace:
    qqqqqqq: eeeeeeeee

Sending event: cli_exit

Based on our experience last time, I also tried removing the newline from the end of the file—still no issue.

I'm kind of stumped. Maybe it has something to do with Windows?

@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label May 16, 2017
@RollingStar
Copy link
Collaborator Author

RollingStar commented May 16, 2017

Happens with or without the newline. Note the troublesome character is U+201D and not a normal quote ". All these don't work.

(This first one fails on Powershell as well as normal CMD. I only tested with normal CMD for the others.)

library: e:\songs\beetslibrary.bib

replace:
    'q': '”'
library: e:\songs\beetslibrary.bib

paths:
    default: '”'
library: e:\songs\beetslibrary.bib

paths:
    default: ”

This works:

library: e:\songs\beetslibrary.bib

paths:
    default: a

So, maybe is being treated as an escape character? If the text handler parses escape characters before comments # that would explain all the results thus far. edit: By escape character, I mean maybe the text handler stops reading the config once it gets to . This leaves beets with a corrupted user config, and it can't find musicbrainz.host. Normally I assume it loads the user config in its entirety, then fills the remainder from the program default config. Or it does it the other way, and this half-loaded user config causes beets to not have a value saved for musicbrainz.host.

edit 2: Delete also causes problems, even in a comment. I thought I used Unicode like this without issue in previous months.

Maybe the latest Win10 Creators Update changed my console settings? Maybe not.

>chcp 65001
Active code page: 65001

>beet -vv
configuration error: musicbrainz.host not found

Still, because it may be a clue, I'll link to #2456.

edit 3: I forgot that in #2456 I made my own patch to Beets and have been using it since today, when I updated from stable to latest Git. I'll check my fix against these latest issues. I'm guessing this issue is a dupe of 2456.

@RollingStar
Copy link
Collaborator Author

Okay. Applying my fix from #2456 fixes my issue with the quotes and DEL and everything else. However, could error handling be improved for other unforseeable errors?

  • Beets reading info to the right of a comment indicator #. Is Beets reading line by line, or the entire file at once? Line by line would have a benefit of being more assured that beets is not reading any line after # appears.
  • The "configuration error" that is thrown. What is happening between program defaults & user config that causes this error?

@sampsyo
Copy link
Member

sampsyo commented May 17, 2017

OK—that sounds like we're dealing with an encoding error.

I'm guessing that the YAML parser is somehow giving up entirely when it encounters a character it doesn't understand. I'm still at a loss to explain why that leads to the configuration error you're seeing—it seems to throw off the whole configuration system, rather than just exiting with a parse error. It's hard to narrow down what's wrong without a way to reproduce the problem.

sampsyo added a commit that referenced this issue May 17, 2017
This lets the YAML library itself deal with the encoding (mostly), which
should address #2456 and #2565, which have to do with `open` giving us a
system-specific encoding by default on Python 3 on Windows when the files
should have been written using UTF-8 per the YAML standard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants