diff --git a/NEWS b/NEWS
index 9ae36128..fd3a1e1a 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ Changes from 0.12.1
    * `setv` no longer unnecessarily tries to get attributes
    * `loop` no longer replaces string literals equal to "recur"
    * The REPL now prints the correct value of `do` and `try` forms
+   * Fixed a crash when tokenizing a single quote followed by whitespace
 
    [ Misc. Improvements ]
    * New contrib module `hy-repr`
diff --git a/hy/lex/__init__.py b/hy/lex/__init__.py
index f1a74aae..8a73d874 100644
--- a/hy/lex/__init__.py
+++ b/hy/lex/__init__.py
@@ -34,7 +34,7 @@ def tokenize(buf):
     except LexingError as e:
         pos = e.getsourcepos()
         raise LexException("Could not identify the next token.",
-                           pos.lineno, pos.colno)
+                           pos.lineno, pos.colno, buf)
     except LexException as e:
         if e.source is None:
             e.source = buf
diff --git a/hy/lex/exceptions.py b/hy/lex/exceptions.py
index 4c4b7600..2ef5660a 100644
--- a/hy/lex/exceptions.py
+++ b/hy/lex/exceptions.py
@@ -24,12 +24,12 @@ from hy.errors import HyError
 
 class LexException(HyError):
     """Error during the Lexing of a Hython expression."""
-    def __init__(self, message, lineno, colno):
+    def __init__(self, message, lineno, colno, source=None):
         super(LexException, self).__init__(message)
         self.message = message
         self.lineno = lineno
         self.colno = colno
-        self.source = None
+        self.source = source
         self.filename = '<stdin>'
 
     def __str__(self):

Single quote crashes hy2py
## x.hy

```
'
```

## `hy2py x.hy`

```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "hy/cmdline.py", line 406, in hy2py_main
    if stdin_text is None
  File "hy/cmdline.py", line 186, in pretty_error
    print(e, file=sys.stderr)
  File "hy/lex/exceptions.py", line 43, in __str__
    source = self.source.split("\n")
AttributeError: 'NoneType' object has no attribute 'split'
```
diff --git a/tests/test_lex.py b/tests/test_lex.py
index 96918883..514696b8 100644
--- a/tests/test_lex.py
+++ b/tests/test_lex.py
@@ -63,6 +63,17 @@ def test_unbalanced_exception():
         pass
 
 
+def test_lex_single_quote_err():
+    "Ensure tokenizing \"' \" throws a LexException that can be stringified"
+    # https://github.com/hylang/hy/issues/1252
+    try:
+        tokenize("' ")
+    except LexException as e:
+        assert "Could not identify the next token" in str(e)
+    else:
+        assert False
+
+
 def test_lex_expression_symbols():
     """ Make sure that expressions produce symbols """
     objs = tokenize("(foo bar)")

pip install -e .[dev]
parse_log_pytest
requirements.txt
nose tox pytest
3.6
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
appdirs==1.4.4
args==0.1.0
astor==0.8.1
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
clint==0.5.1
coverage==6.2
distlib==0.3.9
docutils==0.17.1
filelock==3.4.1
flake8==5.0.4
-e git+https://github.com/hylang/hy.git@bb9f543246dfa519e03bb3b315a850973020c503#egg=hy
idna==3.10
imagesize==1.4.1
importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig==1.1.1
Jinja2==3.0.3
MarkupSafe==2.0.1
mccabe==0.7.0
nose==1.3.7
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytz==2025.2
requests==2.27.1
rply==0.7.8
six==1.17.0
snowballstemmer==2.2.0
Sphinx==4.3.2
sphinx-rtd-theme==1.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomli==1.2.3
tox==3.28.0
typing_extensions==4.1.1
urllib3==1.26.20
virtualenv==20.16.2
zipp==3.6.0

name: hy
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - appdirs==1.4.4
      - args==0.1.0
      - astor==0.8.1
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - clint==0.5.1
      - coverage==6.2
      - distlib==0.3.9
      - docutils==0.17.1
      - filelock==3.4.1
      - flake8==5.0.4
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.2.0
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - nose==1.3.7
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytz==2025.2
      - requests==2.27.1
      - rply==0.7.8
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==4.3.2
      - sphinx-rtd-theme==1.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - toml==0.10.2
      - tomli==1.2.3
      - tox==3.28.0
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - virtualenv==20.16.2
      - zipp==3.6.0
prefix: /opt/conda/envs/hy

tests/test_lex.py::test_lex_single_quote_err
tests/test_lex.py::test_lex_exception tests/test_lex.py::test_unbalanced_exception tests/test_lex.py::test_lex_expression_symbols tests/test_lex.py::test_lex_expression_strings tests/test_lex.py::test_lex_expression_integer tests/test_lex.py::test_lex_symbols tests/test_lex.py::test_lex_strings tests/test_lex.py::test_lex_integers tests/test_lex.py::test_lex_fractions tests/test_lex.py::test_lex_expression_float tests/test_lex.py::test_lex_expression_complex tests/test_lex.py::test_lex_digit_separators tests/test_lex.py::test_lex_line_counting tests/test_lex.py::test_lex_line_counting_multi tests/test_lex.py::test_lex_line_counting_multi_inner tests/test_lex.py::test_dicts tests/test_lex.py::test_sets tests/test_lex.py::test_nospace tests/test_lex.py::test_escapes tests/test_lex.py::test_unicode_escapes tests/test_lex.py::test_hashbang tests/test_lex.py::test_complex tests/test_lex.py::test_reader_macro tests/test_lex.py::test_lex_comment_382 tests/test_lex.py::test_lex_mangling_star tests/test_lex.py::test_lex_mangling_hyphen tests/test_lex.py::test_lex_mangling_qmark tests/test_lex.py::test_lex_mangling_bang tests/test_lex.py::test_unmangle tests/test_lex.py::test_simple_cons tests/test_lex.py::test_dotted_list tests/test_lex.py::test_cons_list
NEWS hy/lex/__init__.py hy/lex/exceptions.py
NEWS hy/lex/__init__.py hy/lex/exceptions.py