[issue38975] Add direct anchors to regex syntax documentation
New submission from Baptiste Mispelon : While writing documentation about regexps for a project I help maintain, I wanted to link to some specific aspects of Python's implementation (in my case, non-capturing groups) which are described on https://docs.python.org/3/library/re.html. There are no visible ¶ anchors for the items in the "Regular Expression Syntax" section. Inspecting the generated HTML, there does seem to be auto-generated ids (like `#index-16` for example) but I wouldn't like to rely on those as I'm not sure how stable they are. I couldn't find how to add the ¶ symbol show up next to the titles but I have a PR that adds a bunch of references so that items can be linked directly. -- assignee: docs@python components: Documentation messages: 357831 nosy: bmispelon, docs@python priority: normal severity: normal status: open title: Add direct anchors to regex syntax documentation type: enhancement ___ Python tracker <https://bugs.python.org/issue38975> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38975] Add direct anchors to regex syntax documentation
Baptiste Mispelon added the comment: I've tried using subsection (level 3) for each syntax element and I'm not sure it's a big improvement. Pros: * Visible ¶ anchors which make it easier to copy/paste a reference link Cons: * headings have a slightly different style (bigger font, no background color) * All the added titles show up in the table of content (might not be a problem) * Lots of re-indenting is needed which makes the diff quite noisy (even without reflowing the paragraphs) I'm not sure what's the best way to share this alternative. A new PR? An extra commit on the existing PR? -- ___ Python tracker <https://bugs.python.org/issue38975> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Have date.isocalendar() return a structseq instance
Baptiste Mispelon added the comment: (Apologies if this isn't the right place and/or time for this kind of negative feedback. I'm open to suggestions for a more appropriate venue) I found it disheartening that my work on this ticket has been erased. While I understand that other contributors have worked a lot more on this than I have, I did put in a non-negligible amount of work into this ticket. >From creating the original issue to taking a first stab at writing a patch >(including several rounds of back and forth with core developers). It would have been nice to have been credited in the commit message for example. As-is, it gives me the impression that the only things this project values are pure code contributions. I couldn't find documentation about how this projects credits contributors. If it's standard practice not to credit non-code contributions or non-merged code contributions then I humbly suggest you reconsider this practice. >From my perspective it really discourages me from making further contributions. -- ___ Python tracker <https://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16173] Wrong offset on SyntaxError when identifier contains non-ascii characters
New submission from Baptiste Mispelon: When a syntax error happens, the exception that gets printed has an extra line with a caret that helps locate the error. If the line also contains an identifier with non-ascii characters, then this caret is misaligned (too far on the right). I've investigated briefly and it seems that the offset attribute on the SyntaxError has a wrong value: for varname in ['a', 'é', '蟒']: # 1, 2 and 3 bytes try: exec("%s$" % varname) # SyntaxError except SyntaxError as e: print(e.offset) # should be 2 The example above prints 2, 3, and 4 when it should be printing 2 every time. It seems that the calculation of the offset takes into account the size in bytes instead of the size in characters. I've tested and reproduced the issue on 3.2.2 and on a recent clone of the mercurial repository (dd5e98ddcd39). -- components: Interpreter Core messages: 172470 nosy: bmispelon priority: normal severity: normal status: open title: Wrong offset on SyntaxError when identifier contains non-ascii characters type: behavior versions: Python 3.2, Python 3.4 ___ Python tracker <http://bugs.python.org/issue16173> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20997] Wrong URL fragment identifier in search result
New submission from Baptiste Mispelon: When doing a search for "PYTHONDONTWRITEBYTECODE" on the 2.7 docs (http://docs.python.org/2/search.html?q=PYTHONDONTWRITEBYTECODE), the first (and only) search result is the following link: http://docs.python.org/2/using/cmdline.html?highlight=pythondontwritebytecode#PYTHONDONTWRITEBYTECODE (note the `#PYTHONDONTWRITEBYTECODE` at the end) Clicking this link takes you to the right page but the browser doesn't scroll to the correct position on the page as expected. This is because there's no element with an `id` of `PYTHONDONTWRITEBYTECODE`. The correct id is `envvar-PYTHONDONTWRITEBYTECODE`. Things work as expected when searching on version 3 docs (http://docs.python.org/3/search.html?q=PYTHONDONTWRITEBYTECODE), where the correct fragment identifier is generated in the search results. -- assignee: docs@python components: Documentation messages: 214245 nosy: bmispelon, docs@python priority: normal severity: normal status: open title: Wrong URL fragment identifier in search result type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue20997> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17802] html.HTMLParser raises UnboundLocalError:
New submission from Baptiste Mispelon: When trying to parse the string `a&b`, the parser raises an UnboundLocalError: {{{ >>> from html.parser import HTMLParser >>> p = HTMLParser() >>> p.feed('a&b') >>> p.close() Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.3/html/parser.py", line 149, in close self.goahead(1) File "/usr/lib/python3.3/html/parser.py", line 252, in goahead if k <= i: UnboundLocalError: local variable 'k' referenced before assignment }}} Granted, the HTML is invalid, but this error looks like it might have been an oversight. -- components: Library (Lib) messages: 187414 nosy: bmispelon priority: normal severity: normal status: open title: html.HTMLParser raises UnboundLocalError: type: crash versions: Python 3.3 ___ Python tracker <http://bugs.python.org/issue17802> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
New submission from Baptiste Mispelon: Currently, `date.isocalendar()` returns a plain tuple of (year, week, weekday). It would be a bit more useful if this tuple could be made into a namedtuple (with fields year, week and weekday). -- components: Library (Lib) messages: 245061 nosy: bmispelon priority: normal severity: normal status: open title: Return a namedtuple from date.isocalendar() versions: Python 3.6 ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: As far as I know, using a namedtuple in place of a tuple is fully backwards-compatible. -- ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: I didn't know about issues with pickling. As for the performance issue, is date.isocalendar() really performance critical? I found a precedent for replacing a tuple by a namedtuple: https://hg.python.org/cpython/rev/ef72142eb8a2 I'm trying my hand at writing a patch (I'm a new contributor) but it seems the code is implemented twice: both in Lib/ (python) and in Modules/ (C). I'm having a hard time figuring out how to conjure up a namedutple from the C code. Any hepl is appreciated. Thanks. -- ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: Here's a second attempt at a patch which seems to work. I don't know C at all but I used _decimal.c to try and figure out how to use namedtuple in C. The code compiles and the datetime test suite runs. I've added a test for the new feature and a note in Misc/NEWS as well as a versionadded note in the relevant documentation. Let me know if I've missed anything. -- keywords: +patch Added file: http://bugs.python.org/file39667/issue24416_2.diff ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: Some C code cleanups suggested by haypo. -- Added file: http://bugs.python.org/file39668/issue24416_3.diff ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: For the name, I took (un)inspiration from ParseResult: https://docs.python.org/3/library/urllib.parse.html?highlight=urlparse#urllib.parse.ParseResult Any better suggestion is welcome of course. -- ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: Here's a new patch with the name `IsoCalendarDate` used (it also fixes a wrong version in the `versionadded` section in the docs). Thanks -- Added file: http://bugs.python.org/file39705/issue24416_4.diff ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23511] Broken code example in email module documentation
New submission from Baptiste Mispelon: The first code example at https://docs.python.org/3.5/library/email-examples.html throws an `AttributeError` because `MIMEText`'s constructor expects a `str` object, not a `bytes` one: >>> # Import smtplib for the actual sending function ... import smtplib >>> >>> # Import the email modules we'll need ... from email.mime.text import MIMEText >>> >>> # Open a plain text file for reading. For this example, assume that ... # the text file contains only ASCII characters. ... fp = open(textfile, 'rb') >>> # Create a text/plain message ... msg = MIMEText(fp.read()) Traceback (most recent call last): File "", line 2, in File "/usr/lib/python3.4/email/mime/text.py", line 33, in __init__ _text.encode('us-ascii') AttributeError: 'bytes' object has no attribute 'encode' -- assignee: docs@python components: Documentation messages: 236503 nosy: bmispelon, docs@python priority: normal severity: normal status: open title: Broken code example in email module documentation ___ Python tracker <http://bugs.python.org/issue23511> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23511] Broken code example in email module documentation
Baptiste Mispelon added the comment: Patch attached. -- keywords: +patch Added file: http://bugs.python.org/file38228/issue23511.diff ___ Python tracker <http://bugs.python.org/issue23511> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23511] Broken code example in email module documentation
Baptiste Mispelon added the comment: I wasn't sure if that was going to be out of scope or not. Here's an attached patch that fixes the remaining usages of `open` inside `Doc/includes` to always use a context manager. -- Added file: http://bugs.python.org/file38233/issue23511_open_cm.diff ___ Python tracker <http://bugs.python.org/issue23511> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24416] Return a namedtuple from date.isocalendar()
Baptiste Mispelon added the comment: I updated the patch based on Raymond's feedback. I don't know C at all and I tried to mimic the namedtuple usage of timemodule.c as much as I could (until the code compiled and the test suite passed). I still have two questions: * It seems that the Python implementation (Lib/datetime.py) is not tested when I run `./python -m test test_datetime` (I introduced a deliberate error in datetime.isocalendar() there but the test still succeeded). Is there a particular procedure to trigger those tests? * I'm currently using the name `IsoCalendarDate` as suggested by user taleinat. However, shouldn't it be `ISOCalendarDate`? Thanks. -- Added file: http://bugs.python.org/file44750/issue24416_5.diff ___ Python tracker <http://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com