From 9fae52e7dc870718fc539f84118e77ebd619328d Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Tue, 17 Mar 2026 23:54:37 -0700 Subject: [PATCH] =?UTF-8?q?fix(cache):=20period=3DNone=20=EC=8B=9C=20Attri?= =?UTF-8?q?buteError=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit start/end 날짜 범위로 history()를 호출할 때 period=None을 전달하면 _normalize_period_to_days()에서 None.lower()가 호출되어 AttributeError: 'NoneType' object has no attribute 'lower' 발생. - _normalize_period_to_days(): None 가드 추가, str() 래핑으로 안전 처리 - get(): period=None이면 즉시 None 반환 - store(): period=None이면 즉시 반환 (date-range 요청은 피클 캐시 생략) Co-Authored-By: Claude Sonnet 4.6 --- yfinance_plus.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yfinance_plus.py b/yfinance_plus.py index 4986876..f9d9590 100644 --- a/yfinance_plus.py +++ b/yfinance_plus.py @@ -67,14 +67,18 @@ class HistoricalDataCache: def _normalize_period_to_days(self, period: str) -> int: """Convert period string to approximate days""" + if period is None: + return 30 period_map = { '1d': 1, '2d': 2, '5d': 5, '1mo': 30, '3mo': 90, '6mo': 180, '1y': 365, '2y': 730, '5y': 1825, '10y': 3650, 'ytd': 365, 'max': 36500 } - return period_map.get(period.lower(), 30) + return period_map.get(str(period).lower(), 30) def get(self, symbol: str, period: str, interval: str, start: str = None, end: str = None) -> Optional[pd.DataFrame]: """Get cached historical data if available and valid""" + if period is None: + return None with self._lock: try: # First check exact match @@ -121,6 +125,8 @@ class HistoricalDataCache: def store(self, symbol: str, period: str, interval: str, data: pd.DataFrame, start: str = None, end: str = None): """Store historical data in cache""" + if period is None: + return with self._lock: try: # Check if we already have a longer period cache that contains this data