Conversation
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/3fa81fde-23b2-4404-af80-0fc6925ccf1b Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
- Change do_CSSStyleSheet in serialize.py to return str by decoding after encoding - Update docstrings in cssstylesheet.py (byte string -> text string) - Fix script.py to encode cssText when writing to binary files - Fix examples/website.py to remove .decode() calls (no longer needed) - Update all test files to compare cssText to str instead of bytes - Fix basetest.py do_equal_p to not use str(cssText, 'utf-8') - Fix pre-existing str/bytes comparison bugs in test_cssutils.py - Fix pre-existing incorrect UnicodeDecodeError expectation in test_parse.py Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/3fa81fde-23b2-4404-af80-0fc6925ccf1b Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
cssText return str instead of bytes
|
@copilot Remove the generated files (*.pyc, *.egg-info, LICENSE). Also remove .gitignore - these concerns transcend this repository. See https://blog.jaraco.com/skeleton for how to deal with ignores across projects. |
…acking Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/9ddf299a-6761-4675-a047-5eecc2c923a4 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
Done in 3e38a6a — removed |
|
@copilot Remove LICENSE and .gitignore, FFS. |
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/2a75b3f5-4f44-440e-9f06-82f342cda760 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
|
@copilot Run |
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/662c6470-9068-482c-801d-b50dea6088a7 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
|
@copilot Fix doctest failure ______________________________ [doctest] cssutils ______________________________ And add a news fragment using or mimicking towncrier (removal). |
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/9052b279-b53d-4f33-975d-0979ccd9b363 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/9052b279-b53d-4f33-975d-0979ccd9b363 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
|
|
||
| def _getCssText(self): | ||
| "Textual representation of the stylesheet (a byte string)." | ||
| "Textual representation of the stylesheet (a text string)." |
There was a problem hiding this comment.
@copilot Remove (a text string), redundant (same for line 364 below).
There was a problem hiding this comment.
Done in 8ebbbcf — removed (a text string) from both the _getCssText docstring (line 149) and the cssText property docstring (line 364).
Agent-Logs-Url: https://github.com/jaraco/cssutils/sessions/0ce2b23e-e394-40c4-8bb8-0172e0728a69 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
|
|
||
| # get encoding of sheet, defaults to UTF-8 | ||
| try: | ||
| encoding = stylesheet.cssRules[0].encoding | ||
| except (IndexError, AttributeError): | ||
| encoding = 'UTF-8' | ||
|
|
||
| # TODO: py3 return b str but tests use unicode? | ||
| return text.encode(encoding, 'escapecss') | ||
| return text.encode(encoding, 'escapecss').decode(encoding) |
There was a problem hiding this comment.
@copilot Can this be simplified to simply return text? If not, why not?
There was a problem hiding this comment.
No — simplifying to return text would lose CSS escaping for non-UTF-8 stylesheets. The encodecss error handler converts non-representable characters to CSS escape sequences (e.g. ä → \E4 for an @charset "ascii" sheet). Without the encode/decode step, cssText would return raw Unicode characters that are invalid in the sheet's declared encoding. This is load-bearing for non-UTF-8 correctness.
…99ee-4cb2-b466-8d44199010fa Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
CSSStyleSheet.cssTextreturned bytes, requiring.decode()for basic usage like printing — a Python 2 legacy behavior.Core changes
serialize.py:do_CSSStyleSheetnow returnstext.encode(encoding, 'escapecss').decode(encoding)— encodes with proper CSS escaping for the sheet's charset, then decodes back tostrcss/cssstylesheet.py: Updated docstring to reflectstrreturn typescript.py: EncodecssTextat write time (.encode(sheet.encoding)) when writing to binary filesexamples/website.py: Removed now-unnecessary.decode()callsBefore / After
Test updates
All test comparisons updated from
b'...'/expr.encode()to plainstr. Also fixed two pre-existing Python 3 bugs exposed by this change:test_resolveImports:str == bytescomparisons marked with# py3 TODO— now correctedtest_parseString:('a', 'utf-16')was incorrectly expected to raiseUnicodeDecodeError; removed that caseWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cthedot.de/usr/bin/python python -m pytest tests/test_serialize.py tests/test_parse.py tests/test_cssstylesheet.py tests/test_cssutils.py tests/test_settings.py tests/test_x.py tests/test_medialist.py tests/test_scripts_csscombine.py tests/test_cssimportrule.py -x ils/.git --get tnet/tools/git(dns block)If you need me to access, download, or install something from one of these locations, you can either: